From 8fef11f172c0fbf4029eab2fb0f7f9a3d1491a61 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G08HS3B\\Lee Yi" <leeyi45@gmail.com> Date: Mon, 3 Mar 2025 02:07:43 -0500 Subject: [PATCH 01/17] Relocate svmc repl prompt --- README.md | 1 - docs/lib/concurrency.js | 32 - docs/md/README_3_CONCURRENT.md | 62 - docs/md/README_CONCURRENCY.md | 10 - docs/md/README_top.md | 4 - docs/specs/Makefile | 2 +- docs/specs/source_3_concurrent.tex | 106 - docs/specs/source_concurrency.tex | 9 - scripts/docs.mjs | 21 - src/constants.ts | 1 - src/createContext.ts | 2 - src/editors/ace/docTooltip/index.ts | 2 - src/index.ts | 9 +- .../preprocessor/__tests__/preprocessor.ts | 2 +- .../transformers/hoistAndMergeImports.ts | 2 +- .../__tests__/transformers/removeExports.ts | 2 +- .../transformProgramToFunctionDeclaration.ts | 2 +- src/repl/__tests__/main.ts | 20 + src/repl/__tests__/svmc.ts | 110 + src/repl/__tests__/transpiler.ts | 66 + src/repl/__tests__/utils.ts | 38 + src/repl/index.ts | 13 +- src/repl/main.ts | 11 + src/repl/svmc.ts | 106 + src/repl/transpiler.ts | 108 +- src/runner/sourceRunner.ts | 56 +- src/schedulers.ts | 105 - src/stdlib/inspector.ts | 22 +- src/transpiler/__tests__/transpiled-code.ts | 2 +- src/types.ts | 19 +- src/utils/{testing.ts => testing/index.ts} | 16 +- src/utils/testing/misc.ts | 27 + src/utils/{ast => testing}/sanitizer.ts | 0 src/vm/__tests__/svml-machine.ts | 1577 -------------- src/vm/svmc.ts | 231 -- src/vm/svml-machine.ts | 1872 ----------------- 36 files changed, 463 insertions(+), 4205 deletions(-) delete mode 100644 docs/lib/concurrency.js delete mode 100644 docs/md/README_3_CONCURRENT.md delete mode 100644 docs/md/README_CONCURRENCY.md delete mode 100644 docs/specs/source_3_concurrent.tex delete mode 100644 docs/specs/source_concurrency.tex create mode 100644 src/repl/__tests__/main.ts create mode 100644 src/repl/__tests__/svmc.ts create mode 100644 src/repl/__tests__/transpiler.ts create mode 100644 src/repl/__tests__/utils.ts create mode 100644 src/repl/main.ts create mode 100644 src/repl/svmc.ts delete mode 100644 src/schedulers.ts rename src/utils/{testing.ts => testing/index.ts} (96%) create mode 100644 src/utils/testing/misc.ts rename src/utils/{ast => testing}/sanitizer.ts (100%) delete mode 100644 src/vm/__tests__/svml-machine.ts delete mode 100644 src/vm/svmc.ts delete mode 100644 src/vm/svml-machine.ts diff --git a/README.md b/README.md index 7121fd7d7..55c79f542 100644 --- a/README.md +++ b/README.md @@ -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 <CODE>f_i</CODE>, - * setup a thread <CODE>t_i</CODE> that executes the body of - * <CODE>f_i</CODE>. Any parameters of <CODE>f_i</CODE> refer - * to <CODE>undefined</CODE> during execution. - * The thread that called <CODE>concurrent_execute</CODE> - * runs concurrently with all <CODE>t_i</CODE>. Returns - * <CODE>undefined</CODE>. 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 <CODE>p</CODE> is a boolean - * <CODE>b</CODE>. Sets the head of <CODE>p</CODE> to - * <CODE>true</CODE>. Returns <CODE>b</CODE>. This is an - * atomic operation. - * @param {array} p - given pair - * @returns {value} - head of pair <CODE>b</CODE> - */ -function test_and_set(p) {} - -/** - * Sets the head of pair <CODE>p</CODE> to - * <CODE>false</CODE>. Returns <CODE>undefined</CODE>. - * 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 -<a href="https://sourceacademy.org/sicpjs">Structure and Interpretation -of Computer Programs, JavaScript Adaptation</a> (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: - <ul> - <li> - <a href="../AUXILIARY/index.html">AUXILIARY</a>: Auxiliary constants and functions - </li> - <li> - <a href="../MISC/index.html">MISC</a>: Miscellaneous constants and functions - </li> - <li> - <a href="../MATH/index.html">MATH</a>: Mathematical constants and functions - </li> - <li> - <a href="../LISTS/index.html">LISTS</a>: Support for lists - </li> - <li> - <a href="../PAIRMUTATORS/index.html">PAIRMUTATORS</a>: Mutating pairs - </li> - <li> - <a href="../ARRAYS/index.html">ARRAYS</a>: Support for arrays - </li> - <li> - <a href="../STREAMS/index.html">STREAMS</a>: Support for streams - </li> - <li> - <a href="../CONCURRENCY/index.html">CONCURRENCY</a>: Support for concurrency - </li> - </ul> - -## What can you do in Source §3 Concurrent? - -You can use all features of -<a href="../source_3/">Source §3</a> and all -features that are introduced in -<a href="https://sourceacademy.org/sicpjs/3.4">chapter 3.4</a> 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 <a href="../CONCURRENCY/">CONCURRENCY</a> 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 -<a href="../source_3_concurrent.pdf">Specification of Source §3 Concurrent</a>. 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 -<a href="https://sourceacademy.org/sicpjs">Structure and Interpretation -of Computer Programs, JavaScript Adaptation</a> (SICP JS) -in -<a href="https://sourceacademy.org/sicpjs/3.4.2">section 3.4.2 Mechanisms for Controlling Concurrency</a>. - 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. #### <a href="source_2_typed/">Source §2 Typed</a> -#### <a href="source_3_concurrent/">Source §3 Concurrent</a> - #### <a href="source_3_typed/">Source §3 Typed</a> #### <a href="source_4_typed/">Source §4 Typed</a> @@ -58,8 +56,6 @@ the Source Academy. #### <a href="source_2_typed.pdf">Specification of Source §2 Typed</a> -#### <a href="source_3_concurrent.pdf">Specification of Source §3 Concurrent</a> - #### <a href="source_3_typed.pdf">Specification of Source §3 Typed</a> #### <a href="source_4_typed.pdf">Specification of Source §4 Typed</a> 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/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/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..8525471ff 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' @@ -121,7 +120,6 @@ const createEmptyDebugger = () => ({ it: (function* (): any { return })(), - scheduler: new AsyncScheduler() } }) 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..799bfa19b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -253,12 +253,9 @@ export async function runFilesInContext( export function resume(result: Result): Finished | ResultError | Promise<Result> { 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/modules/preprocessor/__tests__/preprocessor.ts b/src/modules/preprocessor/__tests__/preprocessor.ts index 5f0baa0af..aa6d5d307 100644 --- a/src/modules/preprocessor/__tests__/preprocessor.ts +++ b/src/modules/preprocessor/__tests__/preprocessor.ts @@ -6,7 +6,7 @@ import { mockContext } from '../../../mocks/context' 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..b86cc64c1 100644 --- a/src/modules/preprocessor/__tests__/transformers/hoistAndMergeImports.ts +++ b/src/modules/preprocessor/__tests__/transformers/hoistAndMergeImports.ts @@ -2,7 +2,7 @@ import { mockContext } from '../../../../mocks/context' 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..c53f9fb44 100644 --- a/src/modules/preprocessor/__tests__/transformers/removeExports.ts +++ b/src/modules/preprocessor/__tests__/transformers/removeExports.ts @@ -2,7 +2,7 @@ import { mockContext } from '../../../../mocks/context' 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..201b0f26d 100644 --- a/src/modules/preprocessor/__tests__/transformers/transformProgramToFunctionDeclaration.ts +++ b/src/modules/preprocessor/__tests__/transformers/transformProgramToFunctionDeclaration.ts @@ -3,7 +3,7 @@ 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/repl/__tests__/main.ts b/src/repl/__tests__/main.ts new file mode 100644 index 000000000..6477a99a0 --- /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]' + ) + } + ) +}) \ No newline at end of file diff --git a/src/repl/__tests__/svmc.ts b/src/repl/__tests__/svmc.ts new file mode 100644 index 000000000..8ec41b934 --- /dev/null +++ b/src/repl/__tests__/svmc.ts @@ -0,0 +1,110 @@ +import { asMockedFunc } from '../../utils/testing/misc' +import { compileToChoices, getSVMCCommand } from '../svmc' +import * as vm from '../../vm/svml-compiler' +import * as fs from 'fs/promises' +import { INTERNAL_FUNCTIONS } from '../../stdlib/vm.prelude' +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 <names>' 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 <names>' argument '{ \\"a\\": 1, \\"b\\": 2}' is invalid. Expected a JSON array of strings! + " + `) + }) + + it('is ignored if variant is concurrent', async () => { + await expectSuccess( + '1+1;', + 'test.js', + '--internals', + '["func1", "func2"]', + '--variant', + 'concurrent' + ) + + expect(vm.compileToIns).toHaveBeenCalledTimes(1) + const [[, , internals]] = asMockedFunc(vm.compileToIns).mock.calls + const expectedNames = INTERNAL_FUNCTIONS.map(([name]) => name) + expect(internals).toEqual(expectedNames) + }) +}) + +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() + }) + }) +}) \ No newline at end of file diff --git a/src/repl/__tests__/transpiler.ts b/src/repl/__tests__/transpiler.ts new file mode 100644 index 000000000..34862d6d1 --- /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') +}) \ No newline at end of file diff --git a/src/repl/__tests__/utils.ts b/src/repl/__tests__/utils.ts new file mode 100644 index 000000000..5cc73689e --- /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<T extends Command<any, any>>(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) +} \ No newline at end of file diff --git a/src/repl/index.ts b/src/repl/index.ts index 72065bc95..14c3f211a 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() \ No newline at end of file diff --git a/src/repl/main.ts b/src/repl/main.ts new file mode 100644 index 000000000..3bfcbdf80 --- /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 }) \ No newline at end of file diff --git a/src/repl/svmc.ts b/src/repl/svmc.ts new file mode 100644 index 000000000..e285a01cf --- /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('<inputFile>', 'File to read code from') + .addOption(getChapterOption(Chapter.SOURCE_3, chapterParser)) + .addOption( + new Option( + '-t, --compileTo <compileOption>', + 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 <outFile>', + stripIndent` + Sets the output filename. + Defaults to the input filename, minus any file extension, plus '.svm'. + ` + ) + .addOption( + new Option( + '-i, --internals <names>', + `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}`) + }) \ No newline at end of file diff --git a/src/repl/transpiler.ts b/src/repl/transpiler.ts index 0f4884d1c..3ab8c9708 100644 --- a/src/repl/transpiler.ts +++ b/src/repl/transpiler.ts @@ -16,63 +16,63 @@ 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 <outFile>', 'Specify a file to write to') - .argument('<filename>') - .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 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 +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 <outFile>', 'Specify a file to write to') + .argument('<filename>') + .action(async (fileName, opts) => { + if (!validateChapterAndVariantCombo(opts)) { + console.log('Invalid language combination!') + return + } - if (!linkerResult.ok) { - console.log(parseError(context.errors, linkerResult.verboseErrors)) - return - } + const fs: typeof fslib = require('fs/promises') + const context = createContext(opts.chapter, opts.variant) + const entrypointFilePath = resolve(fileName) - const { programs, topoOrder } = linkerResult - const bundledProgram = defaultBundler(programs, entrypointFilePath, topoOrder, context) + 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 transpiled = opts.pretranspile - ? generate(bundledProgram) - : transpile(bundledProgram, context).transpiled + if (!linkerResult.ok) { + process.stderr.write(parseError(context.errors, linkerResult.verboseErrors)) + process.exit(1) + } - if (context.errors.length > 0) { - console.log(parseError(context.errors, linkerResult.verboseErrors)) - return - } + const { programs, topoOrder } = linkerResult + const bundledProgram = defaultBundler(programs, entrypointFilePath, topoOrder, context) - if (opts.out) { - const resolvedOut = resolve(opts.out) - await fs.writeFile(resolvedOut, transpiled) - console.log(`Code written to ${resolvedOut}`) - } else { - console.log(transpiled) - } - }) + try { + const transpiled = opts.pretranspile + ? generate(bundledProgram) + : transpile(bundledProgram, context).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/sourceRunner.ts b/src/runner/sourceRunner.ts index e2e91befe..3795a3d1e 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,12 +23,11 @@ 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' @@ -60,29 +57,6 @@ let previousCode: { } | null = null let isPreviousCodeTimeoutError = false -function runConcurrent(program: es.Program, context: Context, options: IOptions): Promise<Result> { - 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 +84,6 @@ function runSubstitution( }) } -function runInterpreter(program: es.Program, context: Context, options: IOptions): Promise<Result> { - 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 +189,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 +197,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 +223,8 @@ 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<Value>, context: Context): Promise<Result> { - 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<Value>, context: Context): Promise<Result> { - 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/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<Value>, - 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/transpiler/__tests__/transpiled-code.ts b/src/transpiler/__tests__/transpiled-code.ts index 5b54c21cb..52688a80b 100644 --- a/src/transpiler/__tests__/transpiled-code.ts +++ b/src/transpiler/__tests__/transpiled-code.ts @@ -2,7 +2,7 @@ import { mockContext } from '../../mocks/context' 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/types.ts b/src/types.ts index 81456b691..b68dcd46b 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<T = any> { status: boolean state: { it: IterableIterator<T> - scheduler: Scheduler } } @@ -274,23 +272,12 @@ export interface Finished { // field instead } -export interface Suspended { - status: 'suspended' - it: IterableIterator<Value> - 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<Value>, context: Context): Promise<Result> -} +export type Result = Finished | Error | SuspendedCseEval /** * StatementSequence : A sequence of statements not surrounded by braces. @@ -510,3 +497,5 @@ export type RecursivePartial<T> = T extends Array<any> [K in keyof T]: RecursivePartial<T[K]> }> : T + +export type NodeTypeToNode<T extends Node['type']> = Extract<Node, { type: T }> \ No newline at end of file diff --git a/src/utils/testing.ts b/src/utils/testing/index.ts similarity index 96% rename from src/utils/testing.ts rename to src/utils/testing/index.ts index f26de4bdc..d8ef83972 100644 --- a/src/utils/testing.ts +++ b/src/utils/testing/index.ts @@ -1,11 +1,11 @@ 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 createContext, { defineBuiltin } from '../../createContext' +import { parseError, Result, runInContext } from '../../' +import { mockContext } from '../../mocks/context' +import type { ImportOptions } from '../../modules/moduleTypes' +import { parse } from '../../parser/parser' +import { transpile } from '../../transpiler/transpiler' import { Chapter, Context, @@ -14,8 +14,8 @@ import { Value, Variant, type Finished -} from '../types' -import { stringify } from './stringify' +} from '../../types' +import { stringify } from '../stringify' export interface CodeSnippetTestCase { name: string diff --git a/src/utils/testing/misc.ts b/src/utils/testing/misc.ts new file mode 100644 index 000000000..4ca9fc519 --- /dev/null +++ b/src/utils/testing/misc.ts @@ -0,0 +1,27 @@ +import type { MockedFunction } from 'jest-mock' +import type { Result } from '../..' +import type { Finished, Value, Node, NodeTypeToNode } from '../../types' + +export function asMockedFunc<T extends (...args: any[]) => any>(func: T) { + return func as MockedFunction<T> +} + +export function expectTrue(cond: boolean): asserts cond { + expect(cond).toEqual(true) +} + +export function expectFinishedResult(result: Result): asserts result is Finished { + expect(result.status).toEqual('finished') +} + +export function expectFinishedResultValue(result: Result, value: Value) { + expectFinishedResult(result) + expect(result.value).toEqual(value) +} + +export function expectNodeType<T extends Node['type']>( + typeStr: T, + node: Node +): asserts node is NodeTypeToNode<T> { + expect(node.type).toEqual(typeStr) +} \ No newline at end of file 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/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<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('GTG works for numbers', () => { - 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", - "\\"<Function>\\"", - ] - `) - }) - - 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, [...<circular>, 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...] <input file> - -Options: --t, --compile-to <option>: [binary] - 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. --c, --chapter <chapter>: [3] - 1, 2, 3. Sets the Source chapter. --v, --variant <variant>: [default] - default: Normal Source - concurrent: Concurrent Source (Assumes and overwrites chosen chapter with 3) --o, --out <filename>: [see below] - Sets the output filename. - Defaults to the input filename, minus any '.js' extension, plus '.svm'. --i, --internals <JSON array of internal names>: ["[]"] - Sets the list of VM-internal functions. The argument should be a JSON array of - strings containing the names of the VM-internal functions. ---: - Signifies the end of arguments, in case your input filename starts with -.`) - process.exitCode = 1 - return - } - - const source = await readFileAsync(options.inputFilename, 'utf8') - const context = createEmptyContext(options.sourceChapter, options.sourceVariant, [], null) - const program = parse(source, context) - - let numWarnings = 0 - let numErrors = 0 - for (const error of context.errors) { - console.error( - '[%s] (%d:%d) %s', - error.severity, - error.location.start.line, - error.location.start.column, - error.explain() - ) - switch (error.severity) { - case 'Warning': - ++numWarnings - break - case 'Error': - ++numErrors - break - } - } - - if (numWarnings > 0 || numErrors > 0) { - console.error('%d warning(s) and %d error(s) produced.', numWarnings, numErrors) - } - - if (program === null) { - process.exitCode = 1 - return - } - - if (options.compileTo === 'ast') { - console.log(JSON.stringify(program, undefined, 2)) - return - } - - if (options.sourceVariant === Variant.CONCURRENT && options.vmInternalFunctions) { - console.warn('Warning: ignoring internal functions specified on command line for concurrent VM') - } - - const vmInternalFunctions = - options.sourceVariant === Variant.CONCURRENT - ? concurrentInternalFunctions.map(([name]) => name) - : options.vmInternalFunctions || [] - - // the current compiler does not differentiate between chapters 1, 2 or 3 - const compiled = compileToIns(program, undefined, vmInternalFunctions) - - if (options.compileTo === 'debug') { - console.log(stringifyProgram(compiled).trimRight()) - return - } else if (options.compileTo === 'json') { - console.log(JSON.stringify(compiled)) - return - } - - const binary = assemble(compiled) - - switch (options.outputFilename) { - case '-': - process.stdout.write(binary) - break - case null: - options.outputFilename = options.inputFilename.replace(/\.js$/i, '') + '.svm' - default: - return writeFileAsync(options.outputFilename, binary) - } -} - -main().catch(err => { - console.error(err) -}) diff --git a/src/vm/svml-machine.ts b/src/vm/svml-machine.ts deleted file mode 100644 index 370f4eec1..000000000 --- a/src/vm/svml-machine.ts +++ /dev/null @@ -1,1872 +0,0 @@ -import { JSSLANG_PROPERTIES } from '../constants' -import { PotentialInfiniteLoopError } from '../errors/timeoutErrors' -import { - BINARY_PRIMITIVES, - EXTERNAL_PRIMITIVES, - INTERNAL_FUNCTIONS, - NULLARY_PRIMITIVES, - UNARY_PRIMITIVES, - VARARGS_NUM_ARGS -} from '../stdlib/vm.prelude' -import { Context } from '../types' -import { locationDummyNode } from '../utils/ast/astCreator' -import { stringify } from '../utils/stringify' -import OpCodes from './opcodes' -import { Address, Instruction, Program, SVMFunction } from './svml-compiler' -import { RoundRobinScheduler, Scheduler, ThreadId } from './svml-scheduler' -import { getName } from './util' - -const LDCI_VALUE_OFFSET = 1 -const LDCF32_VALUE_OFFSET = 1 -const LDCF64_VALUE_OFFSET = 1 -const LGCS_VALUE_OFFSET = 1 -const FUNC_MAX_STACK_SIZE_OFFSET = 0 -const FUNC_ENV_SIZE_OFFSET = 1 -const FUNC_NUM_ARGS_OFFSET = 2 -const FUNC_CODE_OFFSET = 3 -const INS_OPCODE_OFFSET = 0 -const BR_OFFSET = 1 -const LD_ST_INDEX_OFFSET = 1 -const LD_ST_ENV_OFFSET = 2 -const CALL_NUM_ARGS_OFFSET = 1 -const CALLT_NUM_ARGS_OFFSET = 1 -const CALLP_ID_OFFSET = 1 -const CALLP_NUM_ARGS_OFFSET = 2 -const CALLTP_ID_OFFSET = 1 -const CALLTP_NUM_ARGS_OFFSET = 2 -const CALLV_ID_OFFSET = 1 -const CALLV_NUM_ARGS_OFFSET = 2 -const CALLTV_ID_OFFSET = 1 -const CALLTV_NUM_ARGS_OFFSET = 2 -const NEWC_ADDR_OFFSET = 1 -const ADDR_FUNC_INDEX_OFFSET = 0 -const NEWENV_NUM_ARGS_OFFSET = 1 -const NEWCP_ID_OFFSET = 1 -const NEWCV_ID_OFFSET = 1 - -// VIRTUAL MACHINE - -// "registers" are the global variables of our machine. -// These contain primitive values (numbers or boolean -// values) or arrays of primitive values - -// PROG contains the entire SVML JSON formatted program -let PROG: Program -// FUNC contains the function array, for easier access -let FUNC: SVMFunction[] -// INTERNAL is the function array for internal functions -const INTERNAL: [string, OpCodes, number, boolean][] = INTERNAL_FUNCTIONS -const INTERNAL_OPCODE_SLOT = 1 -const INTERNAL_NUM_ARGS_SLOT = 2 -const INTERNAL_HAS_RETURN_VAL_SLOT = 3 - -// GLOBAL_ENV is the env that contains all the primitive functions -let GLOBAL_ENV = -1 -// HEAP is array containing all dynamically allocated data structures -let HEAP: any[] = [] -// next free slot in heap -let FREE = 0 -// temporary value, used by PUSH and POP; initially a dummy value -let RES = -Infinity - -// THREAD STATE - -// P contains the instructions to be executed in the current function call -let P: Instruction[] -// PC is program counter: index of the next instruction in P -let PC = 0 -// ENV is address of current environment in HEAP; initially a dummy value -let ENV = -1 -// OS is address of current operand stack in HEAP; initially a dummy value -let OS = -Infinity -// RTS contains the call stack -let RTS: any[] = [] -// top index of RTS stack -let TOP_RTS = -1 - -/** - * when executing concurrent code - */ -// TO is timeout counter: how many instructions are left for a thread to run -let TO = 0 - -// some general-purpose registers -let A: any = 0 -let B: any = 0 -let C: any = 0 -let D: any = 0 -let E: any = 0 -let F: any = 0 -let G: any = 0 -let H: any = 0 -let I: any = 0 -let J: any = 0 -let K: any = 0 - -function show_executing(s: string) { - let str = '' - str += '--- RUN ---' + s + '\n' - str += 'PC :' + PC + '\n' - str += 'instr:' + getName(P[PC][INS_OPCODE_OFFSET]) - return str -} - -// for debugging: show all registers -export function show_registers(s: string, isShowExecuting = true) { - let str = '' - if (isShowExecuting) { - str = show_executing(s) + '\n' - } - str += '--- REGISTERS ---' + s + '\n' - str += 'RES:' + RES + '\n' - str += 'A :' + A + '\n' - str += 'B :' + B + '\n' - str += 'C :' + C + '\n' - str += 'D :' + D + '\n' - str += 'E :' + E + '\n' - str += 'F :' + F + '\n' - str += 'G :' + G + '\n' - str += 'H :' + H + '\n' - str += 'I :' + I + '\n' - str += 'OS :' + OS + '\n' - str += 'ENV:' + ENV + '\n' - str += 'RTS:' + RTS + '\n' - str += 'TOP_RTS:' + TOP_RTS + '\n' - str += 'TO:' + TO + '\n' - str += 'scheduler_state:' + scheduler_state_string() + '\n' - return str -} - -// register that says if machine is running -let RUNNING = true - -const NORMAL = 0 -const DIV_ERROR = 1 -const TYPE_ERROR = 2 -const NUM_ARGS_ERROR = 3 -const CALL_NON_FUNCTION_ERROR = 4 - -let ERROR_MSG_ARGS: any[] = [] - -let STATE = NORMAL - -// general node layout -const TAG_SLOT = 0 -const SIZE_SLOT = 1 -const FIRST_CHILD_SLOT = 2 -const LAST_CHILD_SLOT = 3 - -// NEW expects tag in A and size in B -function NEW() { - HEAP[FREE + TAG_SLOT] = A - HEAP[FREE + SIZE_SLOT] = B - RES = FREE - FREE = FREE + B -} - -// boxed nodes -const BOXED_VALUE_SLOT = 4 - -// number nodes layout -// -// 0: tag = -100 -// 1: size = 5 -// 2: offset of first child from the tag: 6 (no children) -// 3: offset of last child from the tag: 5 (must be less than first) -// 4: value - -const NUMBER_TAG = -100 -const NUMBER_SIZE = 5 -const NUMBER_VALUE_SLOT = 4 - -// changes A, B, C, expects number in A -function NEW_NUMBER() { - C = A - A = NUMBER_TAG - B = NUMBER_SIZE - NEW() - HEAP[RES + FIRST_CHILD_SLOT] = 6 - HEAP[RES + LAST_CHILD_SLOT] = 5 // no children - HEAP[RES + NUMBER_VALUE_SLOT] = C -} - -// bool nodes layout -// -// 0: tag = -101 -// 1: size = 5 -// 2: offset of first child from the tag: 6 (no children) -// 3: offset of last child from the tag: 5 (must be less than first) -// 4: value - -const BOOL_TAG = -101 -const BOOL_SIZE = 5 -const BOOL_VALUE_SLOT = 4 - -// changes A, B, C, expects boolean value in A -function NEW_BOOL() { - C = A - A = BOOL_TAG - B = BOOL_SIZE - NEW() - HEAP[RES + FIRST_CHILD_SLOT] = 6 - HEAP[RES + LAST_CHILD_SLOT] = 5 // no children - HEAP[RES + BOOL_VALUE_SLOT] = C -} - -// string nodes layout -// -// 0: tag = -107 -// 1: size = 5 -// 2: offset of first child from the tag: 6 (no children) -// 3: offset of last child from the tag: 5 (must be less than first) -// 4: value - -const STRING_TAG = -107 -const STRING_SIZE = 5 -const STRING_VALUE_SLOT = 4 - -// changes A, B, C, expects string literal in A -function NEW_STRING() { - C = A - A = STRING_TAG - B = STRING_SIZE - NEW() - HEAP[RES + FIRST_CHILD_SLOT] = 6 - HEAP[RES + LAST_CHILD_SLOT] = 5 // no children - HEAP[RES + STRING_VALUE_SLOT] = C -} - -// array nodes layout -// -// 0: tag = -108 -// 1: size = 5 -// 2: offset of first child from the tag: 6 (no children) -// 3: offset of last child from the tag: 5 (must be less than first) -// 4: value (JS array, each element is the address of the element's node in the heap) -// 5: current size of array (largest index assigned) - -const ARRAY_TAG = -108 -const ARRAY_SIZE = 6 -const ARRAY_VALUE_SLOT = 4 -const ARRAY_SIZE_SLOT = 5 - -// changes A, B -function NEW_ARRAY() { - A = ARRAY_TAG - B = ARRAY_SIZE - NEW() - HEAP[RES + FIRST_CHILD_SLOT] = 6 - HEAP[RES + LAST_CHILD_SLOT] = 5 // no children - HEAP[RES + ARRAY_VALUE_SLOT] = [] - HEAP[RES + ARRAY_SIZE_SLOT] = 0 -} - -// undefined nodes layout -// -// 0: tag = -106 -// 1: size = 4 -// 2: offset of first child from the tag: 5 (no children) -// 3: offset of last child from the tag: 4 (must be less than first) - -const UNDEFINED_TAG = -106 -const UNDEFINED_SIZE = 4 - -function NEW_UNDEFINED() { - A = UNDEFINED_TAG - B = UNDEFINED_SIZE - NEW() - HEAP[RES + FIRST_CHILD_SLOT] = 5 - HEAP[RES + LAST_CHILD_SLOT] = 4 // no children -} - -// null nodes layout -// -// 0: tag = -109 -// 1: size = 4 -// 2: offset of first child from the tag: 5 (no children) -// 3: offset of last child from the tag: 4 (must be less than first) - -const NULL_TAG = -109 -const NULL_SIZE = 4 - -// changes A, B. -function NEW_NULL() { - A = NULL_TAG - B = NULL_SIZE - NEW() - HEAP[RES + FIRST_CHILD_SLOT] = 5 - HEAP[RES + LAST_CHILD_SLOT] = 4 // no children -} - -// operandstack nodes layout -// -// 0: tag = -105 -// 1: size = maximal number of entries + 4 -// 2: first child slot = 4 -// 3: last child slot = current top of stack; initially 3 (empty stack) -// 4: first entry -// 5: second entry -// ... - -const OS_TAG = -105 - -// changes A, B, C, expects max size in A -function NEW_OS() { - C = A - A = OS_TAG - B = C + 4 - NEW() - HEAP[RES + FIRST_CHILD_SLOT] = 4 - // operand stack initially empty - HEAP[RES + LAST_CHILD_SLOT] = 3 -} - -// PUSH and POP are convenient subroutines that operate on -// the operand stack OS -// PUSH expects its argument in A -// changes B -function PUSH_OS() { - B = HEAP[OS + LAST_CHILD_SLOT] // address of current top of OS - B = B + 1 - HEAP[OS + LAST_CHILD_SLOT] = B // update address of current top of OS - HEAP[OS + B] = A -} - -// POP puts the top-most value into RES -// changes B -function POP_OS() { - B = HEAP[OS + LAST_CHILD_SLOT] // address of current top of OS - HEAP[OS + LAST_CHILD_SLOT] = B - 1 // update address of current top of OS - RES = HEAP[OS + B] -} - -// closure nodes layout -// -// 0: tag = -103 -// 1: size = 7 -// 2: offset of first child from the tag: 6 (only environment) -// 3: offset of last child from the tag: 6 -// 4: type of function (normal, primitive, internal) -// 5: index = index of function in program function array -// 6: environment - -const CLOSURE_TAG = -103 -const CLOSURE_SIZE = 7 -const CLOSURE_NORMAL_TYPE = 0 -// not necessary right now due to the way primitives are handled -// const CLOSURE_PRIMITIVE_TYPE = 1 -const CLOSURE_INTERNAL_TYPE = 2 -const CLOSURE_TYPE_SLOT = 4 -const CLOSURE_FUNC_INDEX_SLOT = 5 -const CLOSURE_ENV_SLOT = 6 - -// changes A, B, E, F -// expects index of function in FUNC / INTERNAL in A -// expects type of function in B -export function NEW_FUNCTION() { - E = A - F = B - A = CLOSURE_TAG - B = CLOSURE_SIZE - NEW() - HEAP[RES + FIRST_CHILD_SLOT] = CLOSURE_ENV_SLOT - HEAP[RES + LAST_CHILD_SLOT] = CLOSURE_ENV_SLOT - HEAP[RES + CLOSURE_TYPE_SLOT] = F - HEAP[RES + CLOSURE_FUNC_INDEX_SLOT] = E - HEAP[RES + CLOSURE_ENV_SLOT] = ENV -} - -// stackframe nodes layout -// -// 0: tag = -104 -// 1: size = 7 -// 2: offset of first child from the tag: 5 (environment) -// 3: offset of last child from the tag: 6 (operand stack) -// 4: program counter = return address -// 5: environment -// 6: operand stack -// 7: current function code array - -const RTS_FRAME_TAG = -104 -const RTS_FRAME_SIZE = 8 -const RTS_FRAME_PC_SLOT = 4 -const RTS_FRAME_ENV_SLOT = 5 -const RTS_FRAME_OS_SLOT = 6 -const RTS_FRAME_FUNC_INS_SLOT = 7 - -// changes A, B, expects current PC, ENV, OS, P, TOP_RTS in their registers -function NEW_RTS_FRAME() { - A = RTS_FRAME_TAG - B = RTS_FRAME_SIZE - NEW() - HEAP[RES + FIRST_CHILD_SLOT] = RTS_FRAME_ENV_SLOT - HEAP[RES + LAST_CHILD_SLOT] = RTS_FRAME_OS_SLOT - HEAP[RES + RTS_FRAME_PC_SLOT] = PC + 1 // next instruction! - HEAP[RES + RTS_FRAME_ENV_SLOT] = ENV - HEAP[RES + RTS_FRAME_OS_SLOT] = OS - HEAP[RES + RTS_FRAME_FUNC_INS_SLOT] = P -} - -// expects stack frame in A -function PUSH_RTS() { - TOP_RTS = TOP_RTS + 1 - RTS[TOP_RTS] = A -} - -// places stack frame into RES -function POP_RTS() { - RES = RTS[TOP_RTS] - TOP_RTS = TOP_RTS - 1 -} - -// environment nodes layout -// -// 0: tag = -102 -// 1: size = number of entries + 5 -// 2: first child = 5 -// 3: last child -// 4: previous env -// 5: first entry -// 6: second entry -// ... - -const ENV_TAG = -102 -// Indicates previous environment -const PREVIOUS_ENV_SLOT = 4 -const NIL = -1 - -// expects number of env entries in A, previous env in B -// changes A, B, C -function NEW_ENVIRONMENT() { - C = A - D = B - A = ENV_TAG - B = C + 5 - NEW() - HEAP[RES + FIRST_CHILD_SLOT] = 5 - HEAP[RES + LAST_CHILD_SLOT] = 4 + C - HEAP[RES + PREVIOUS_ENV_SLOT] = D -} - -// expect operands to check equality for in C and D -// return result as boolean literal in A -function CHECK_EQUAL() { - A = C === D // same reference (for arrays and normal functions) - B = HEAP[C + TAG_SLOT] === HEAP[D + TAG_SLOT] // check same type - E = HEAP[C + TAG_SLOT] === UNDEFINED_TAG - A = A || (B && E) // check undefined - E = HEAP[C + TAG_SLOT] === NULL_TAG - A = A || (B && E) // check null - - E = HEAP[C + TAG_SLOT] === CLOSURE_TAG // check functions - if (B && E) { - // if internal, compare index - E = HEAP[C + CLOSURE_TYPE_SLOT] === HEAP[D + CLOSURE_TYPE_SLOT] - E = E && HEAP[C + CLOSURE_FUNC_INDEX_SLOT] === HEAP[D + CLOSURE_FUNC_INDEX_SLOT] - A = A || E - } - - E = HEAP[C + TAG_SLOT] === NUMBER_TAG - E = E || HEAP[C + TAG_SLOT] === STRING_TAG - E = E || HEAP[C + TAG_SLOT] === BOOL_TAG - E = E && B // check same type and has boxed value - C = HEAP[C + BOXED_VALUE_SLOT] - D = HEAP[D + BOXED_VALUE_SLOT] - E = E && C === D - A = A || E -} - -const NORMAL_CALL = 0 -const TAIL_CALL = 1 -const PRIMITIVE_CALL = 2 -const PRIMITIVE_TAIL_CALL = 3 -const INTERNAL_CALL = 4 -const INTERNAL_TAIL_CALL = 5 - -// expect number of arguments in G, closure (index for internal) in F, -// type of call in J -// currently only checks number of arguments for variadic functions -// uses A,B,C,D,E,F,G,H,I,J,K -function FUNCTION_CALL() { - if ( - J === INTERNAL_CALL || - J === INTERNAL_TAIL_CALL || - ((J === NORMAL_CALL || J === TAIL_CALL) && - HEAP[F + CLOSURE_TYPE_SLOT] === CLOSURE_INTERNAL_TYPE) - ) { - if (J === NORMAL_CALL || J === TAIL_CALL) { - F = HEAP[F + CLOSURE_FUNC_INDEX_SLOT] - } - INTERNAL_FUNCTION_CALL() - } else { - // prep for new environment - B = HEAP[F + CLOSURE_ENV_SLOT] - // A is now env to be extended - H = HEAP[F + CLOSURE_FUNC_INDEX_SLOT] - H = FUNC[H] - // H is now the function header of the function to call - I = H[FUNC_NUM_ARGS_OFFSET] - A = H[FUNC_ENV_SIZE_OFFSET] - // A is now the environment extension count - NEW_ENVIRONMENT() // after this, RES is new env - E = RES - - // for varargs (-1), put all elements into an array. hacky implementation - if (I === VARARGS_NUM_ARGS) { - NEW_ARRAY() - I = RES - for (C = G - 1; C >= 0; C = C - 1) { - POP_OS() - HEAP[I + ARRAY_VALUE_SLOT][C] = RES - } - HEAP[I + ARRAY_SIZE_SLOT] = G // manually update array length - D = E + HEAP[E + FIRST_CHILD_SLOT] - HEAP[D] = I - } else if (I === G) { - D = E + HEAP[E + FIRST_CHILD_SLOT] + G - 1 - // D is now address where last argument goes in new env - for (C = D; C > D - G; C = C - 1) { - POP_OS() // now RES has the address of the next arg - HEAP[C] = RES // copy argument into new env - } - } else { - STATE = NUM_ARGS_ERROR - ERROR_MSG_ARGS[0] = I - ERROR_MSG_ARGS[1] = G - RUNNING = false - } - - if (J === NORMAL_CALL || J === TAIL_CALL) { - POP_OS() // closure is on top of OS; pop it as not needed - } - if (J === NORMAL_CALL || J === PRIMITIVE_CALL) { - // normal calls need to push to RTS - NEW_RTS_FRAME() // saves PC+1, ENV, OS, P - A = RES - PUSH_RTS() - } - PC = 0 - P = H[FUNC_CODE_OFFSET] - A = H[FUNC_MAX_STACK_SIZE_OFFSET] - NEW_OS() - OS = RES - ENV = E - } -} - -// expects type of call in J, internal function id in F -// number of arguments in G -// actually no difference between tail and normal -function INTERNAL_FUNCTION_CALL() { - F = INTERNAL[F] - K = F // save the internal function - if (K[INTERNAL_NUM_ARGS_SLOT] !== VARARGS_NUM_ARGS && K[INTERNAL_NUM_ARGS_SLOT] !== G) { - STATE = NUM_ARGS_ERROR - ERROR_MSG_ARGS[0] = K[INTERNAL_NUM_ARGS_SLOT] - ERROR_MSG_ARGS[1] = G - RUNNING = false - } else { - M[K[INTERNAL_OPCODE_SLOT]]() // call subroutine directly - - if (K[INTERNAL_HAS_RETURN_VAL_SLOT]) { - // pop return value if present - POP_OS() - D = RES - } else { - NEW_UNDEFINED() - D = RES - } - if (J === NORMAL_CALL || J === TAIL_CALL) { - POP_OS() // pop closure - } - A = D - PUSH_OS() // push return value back - PC = PC + 1 - } -} - -type Thread = [ - number, // OS - number, // ENV - number, // PC - Instruction[], // P - any[], // RTS - number // TOP_RTS -] - -let scheduler: Scheduler = new RoundRobinScheduler() -const threads: Map<ThreadId, Thread> = new Map() -let currentThreadId: ThreadId = -1 - -// Initialize the scheduler (do this before running code) -function INIT_SCHEDULER() { - scheduler = new RoundRobinScheduler() - threads.clear() -} - -// Schedule new thread for later execution using the thread state currently in VM -// You will want to pop another thread, restore thread state, etc. -// after calling this, as the current thread state should not be running -function NEW_THREAD() { - const newId = scheduler.newThread() - threads.set(newId, [OS, ENV, PC, P, RTS, TOP_RTS]) -} - -// Schedule current thread for later execution -// You will want to pop another thread, restore thread state, etc. -// after calling this, as the current thread state should not be running -function PAUSE_THREAD() { - // Save state to threads map - threads.set(currentThreadId, [OS, ENV, PC, P, RTS, TOP_RTS]) - - // Pause thread in scheduler - scheduler.pauseThread(currentThreadId) -} - -function DELETE_CURRENT_THREAD() { - // Clear state from threads map - threads.delete(currentThreadId) - - // Delete thread from scheduler - scheduler.deleteCurrentThread(currentThreadId) - currentThreadId = -1 -} - -// Get thread from scheduler and run it -function RUN_THREAD() { - ;[currentThreadId, TO] = scheduler.runThread()! - - // Load thread state - ;[OS, ENV, PC, P, RTS, TOP_RTS] = threads.get(currentThreadId)! -} - -// Returns the number of threads in the scheduler -function GET_NUM_IDLE_THREADS() { - RES = scheduler.numIdle() -} - -function scheduler_state_string() { - return new Array(scheduler.idleThreads).toString() -} - -// debugging: show current heap -function is_node_tag(x: number) { - return x !== undefined && x <= -100 && x >= -110 -} -function node_kind(x: number) { - return x === NUMBER_TAG - ? 'number' - : x === BOOL_TAG - ? 'boolean' - : x === CLOSURE_TAG - ? 'closure' - : x === RTS_FRAME_TAG - ? 'RTS frame' - : x === OS_TAG - ? 'OS' - : x === ENV_TAG - ? 'environment' - : x === UNDEFINED_TAG - ? 'undefined' - : x === NULL_TAG - ? 'null' - : x === STRING_TAG - ? 'string' - : x === ARRAY_TAG - ? 'array' - : ' (unknown node kind)' -} -export function show_heap(s: string) { - const len = HEAP.length - let i = 0 - let str = '' - str += '--- HEAP --- ' + s + '\n' - while (i < len) { - str += - i + - ': ' + - HEAP[i] + // TODO is_number(HEAP[i]) && - (is_node_tag(HEAP[i]) ? ' (' + node_kind(HEAP[i]) + ')' : '') + - '\n' - i = i + 1 - } - return str -} - -export function show_heap_value(address: number) { - return ( - 'result: heap node of type = ' + - node_kind(HEAP[address]) + - ', value = ' + - HEAP[address + NUMBER_VALUE_SLOT] - ) -} - -// SVML implementation - -// We implement our machine with an array M that -// contains subroutines. Each subroutine implements -// a machine instruction, using a nullary function. -// The machine can then index into M using the op-codes -// of the machine instructions. To be implementable on -// common hardware, the subroutines have the -// following structure: -// * they have no parameters -// * they do not return any results -// * they do not have local variables -// * they do not call other functions except the -// subroutines PUSH and POP -// * each line is very simple, for example an array access -// Ideally, each line can be implemented directly with a -// machine instruction of a real computer. In that case, -// the subroutines could become machine language macros, -// and the compiler could generate real machine code. -// There are some exceptions due to the need to support -// primitive functions or certain behavior - -const M: (() => void)[] = [] - -M[OpCodes.NOP] = () => { - PC = PC + 1 -} - -M[OpCodes.LGCI] = () => { - A = P[PC][LDCI_VALUE_OFFSET] - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.LGCF32] = () => { - A = P[PC][LDCF32_VALUE_OFFSET] - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.LGCF64] = () => { - A = P[PC][LDCF64_VALUE_OFFSET] - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.LGCB0] = () => { - A = false - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.LGCB1] = () => { - A = true - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.LGCU] = () => { - NEW_UNDEFINED() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.LGCN] = () => { - NEW_NULL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.LGCS] = () => { - A = P[PC][LGCS_VALUE_OFFSET] - NEW_STRING() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.POPG] = () => { - POP_OS() - PC = PC + 1 -} - -// type check here as we need to know whether number or string -M[OpCodes.ADDG] = () => { - POP_OS() - I = RES - POP_OS() - G = RES - H = HEAP[I + TAG_SLOT] === HEAP[G + TAG_SLOT] - D = HEAP[I + TAG_SLOT] === NUMBER_TAG - F = H && D - if (F) { - A = HEAP[I + NUMBER_VALUE_SLOT] - A = HEAP[G + NUMBER_VALUE_SLOT] + A - NEW_NUMBER() - } - E = HEAP[I + TAG_SLOT] === STRING_TAG - F = H && E - if (F) { - A = HEAP[I + STRING_VALUE_SLOT] - A = HEAP[G + STRING_VALUE_SLOT] + A - NEW_STRING() - } - A = RES - PUSH_OS() - PC = PC + 1 - J = D || E - J = !(J && H) - if (J) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'string and string or number and number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[G + TAG_SLOT])} and ${node_kind(HEAP[I + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = '+' - RUNNING = false - } -} - -M[OpCodes.SUBG] = () => { - POP_OS() - D = RES - POP_OS() - E = RES - A = HEAP[D + NUMBER_VALUE_SLOT] - A = HEAP[E + NUMBER_VALUE_SLOT] - A - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === HEAP[E + TAG_SLOT] - G = G && HEAP[D + TAG_SLOT] === NUMBER_TAG - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'number and number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[E + TAG_SLOT])} and ${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = '-' - RUNNING = false - } -} - -M[OpCodes.MULG] = () => { - POP_OS() - D = RES - POP_OS() - E = RES - A = HEAP[D + NUMBER_VALUE_SLOT] - A = HEAP[E + NUMBER_VALUE_SLOT] * A - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === HEAP[E + TAG_SLOT] - G = G && HEAP[D + TAG_SLOT] === NUMBER_TAG - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'number and number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[E + TAG_SLOT])} and ${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = '*' - RUNNING = false - } -} - -M[OpCodes.DIVG] = () => { - POP_OS() - D = RES - POP_OS() - E = RES - A = HEAP[D + NUMBER_VALUE_SLOT] - F = A - A = HEAP[E + NUMBER_VALUE_SLOT] / A - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === HEAP[E + TAG_SLOT] - G = G && HEAP[D + TAG_SLOT] === NUMBER_TAG - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'number and number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[E + TAG_SLOT])} and ${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = '/' - RUNNING = false - } - - F = G && F === 0 - if (F) { - STATE = DIV_ERROR - RUNNING = false - } -} - -M[OpCodes.MODG] = () => { - POP_OS() - D = RES - POP_OS() - E = RES - A = HEAP[D + NUMBER_VALUE_SLOT] - A = HEAP[E + NUMBER_VALUE_SLOT] % A - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === HEAP[E + TAG_SLOT] - G = E && HEAP[D + TAG_SLOT] === NUMBER_TAG - if (!G) { - STATE = TYPE_ERROR - RUNNING = false - } -} - -M[OpCodes.NEGG] = () => { - POP_OS() - D = RES - A = -HEAP[D + NUMBER_VALUE_SLOT] - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === NUMBER_TAG - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = '-' - RUNNING = false - } -} - -M[OpCodes.NOTG] = () => { - POP_OS() - D = RES - A = !HEAP[D + BOOL_VALUE_SLOT] - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === BOOL_TAG - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'boolean' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = '!' - RUNNING = false - } -} - -// for comparisons, assume both string or both nums -M[OpCodes.LTG] = () => { - POP_OS() - D = RES - POP_OS() - E = RES - A = HEAP[D + BOXED_VALUE_SLOT] - A = HEAP[E + BOXED_VALUE_SLOT] < A - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === HEAP[E + TAG_SLOT] - G = G && (HEAP[D + TAG_SLOT] === NUMBER_TAG || HEAP[D + TAG_SLOT] === STRING_TAG) - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'string and string or number and number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[E + TAG_SLOT])} and ${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = '<' - RUNNING = false - } -} - -M[OpCodes.GTG] = () => { - POP_OS() - D = RES - POP_OS() - E = RES - A = HEAP[D + BOXED_VALUE_SLOT] - A = HEAP[E + BOXED_VALUE_SLOT] > A - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === HEAP[E + TAG_SLOT] - G = G && (HEAP[D + TAG_SLOT] === NUMBER_TAG || HEAP[D + TAG_SLOT] === STRING_TAG) - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'string and string or number and number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[E + TAG_SLOT])} and ${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = '>' - RUNNING = false - } -} - -M[OpCodes.LEG] = () => { - POP_OS() - D = RES - POP_OS() - E = RES - A = HEAP[D + BOXED_VALUE_SLOT] - A = HEAP[E + BOXED_VALUE_SLOT] <= A - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === HEAP[E + TAG_SLOT] - G = G && (HEAP[D + TAG_SLOT] === NUMBER_TAG || HEAP[D + TAG_SLOT] === STRING_TAG) - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'string and string or number and number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[E + TAG_SLOT])} and ${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = '<=' - RUNNING = false - } -} - -M[OpCodes.GEG] = () => { - POP_OS() - D = RES - POP_OS() - E = RES - A = HEAP[D + BOXED_VALUE_SLOT] - A = HEAP[E + BOXED_VALUE_SLOT] >= A - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === HEAP[E + TAG_SLOT] - G = G && (HEAP[D + TAG_SLOT] === NUMBER_TAG || HEAP[D + TAG_SLOT] === STRING_TAG) - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'string and string or number and number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[E + TAG_SLOT])} and ${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = '>=' - RUNNING = false - } -} - -// check type here as undefined and null need to be differentiated by nodes -// unless if we add one more slot to undefined and null -M[OpCodes.EQG] = () => { - POP_OS() - C = RES - POP_OS() - D = RES - CHECK_EQUAL() - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.NEQG] = () => { - POP_OS() - C = RES - POP_OS() - D = RES - CHECK_EQUAL() - A = !A - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.NEWC] = () => { - A = (P[PC][NEWC_ADDR_OFFSET] as Address)[ADDR_FUNC_INDEX_OFFSET] - B = CLOSURE_NORMAL_TYPE - NEW_FUNCTION() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.NEWA] = () => { - NEW_ARRAY() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.LDLG] = () => { - C = ENV - A = HEAP[C + HEAP[C + FIRST_CHILD_SLOT] + P[PC][LD_ST_INDEX_OFFSET]] - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.STLG] = () => { - POP_OS() - C = ENV - HEAP[C + HEAP[C + FIRST_CHILD_SLOT] + P[PC][LD_ST_INDEX_OFFSET]] = RES - PC = PC + 1 -} - -M[OpCodes.LDPG] = () => { - B = P[PC][LD_ST_ENV_OFFSET] // index of env to lookup - C = ENV - for (; B > 0; B = B - 1) { - C = HEAP[C + PREVIOUS_ENV_SLOT] - } - A = HEAP[C + HEAP[C + FIRST_CHILD_SLOT] + P[PC][LD_ST_INDEX_OFFSET]] - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.STPG] = () => { - POP_OS() - B = P[PC][LD_ST_ENV_OFFSET] // index of env to lookup - C = ENV - for (; B > 0; B = B - 1) { - C = HEAP[C + PREVIOUS_ENV_SLOT] - } - HEAP[C + HEAP[C + FIRST_CHILD_SLOT] + P[PC][LD_ST_INDEX_OFFSET]] = RES - PC = PC + 1 -} - -M[OpCodes.LDAG] = () => { - POP_OS() - D = RES - POP_OS() - E = RES - G = HEAP[E + TAG_SLOT] === ARRAY_TAG - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'array' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[E + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = 'array access' - RUNNING = false - return - } - - A = HEAP[D + NUMBER_VALUE_SLOT] - A = HEAP[E + ARRAY_VALUE_SLOT][A] - if (A === undefined) { - NEW_UNDEFINED() - A = RES - } - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === NUMBER_TAG - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = 'array index' - RUNNING = false - } -} - -M[OpCodes.STAG] = () => { - POP_OS() - D = RES - POP_OS() - E = RES - A = HEAP[E + NUMBER_VALUE_SLOT] // index - POP_OS() - F = RES - G = HEAP[F + TAG_SLOT] === ARRAY_TAG - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'array' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[F + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = 'array access' - RUNNING = false - return - } - HEAP[F + ARRAY_VALUE_SLOT][A] = D - - // update array size - D = HEAP[F + ARRAY_SIZE_SLOT] - if (D < A + 1) { - D = A + 1 - } - HEAP[F + ARRAY_SIZE_SLOT] = D - PC = PC + 1 - - G = HEAP[E + TAG_SLOT] === NUMBER_TAG - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'number' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[E + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = 'array index' - RUNNING = false - } -} - -M[OpCodes.BRT] = () => { - POP_OS() - A = HEAP[RES + BOOL_VALUE_SLOT] - if (A) { - PC = PC + (P[PC][BR_OFFSET] as number) - } else { - PC = PC + 1 - } -} - -M[OpCodes.BRF] = () => { - POP_OS() - A = HEAP[RES + BOOL_VALUE_SLOT] - if (!A) { - PC = PC + (P[PC][BR_OFFSET] as number) - } else { - PC = PC + 1 - } -} - -M[OpCodes.BR] = () => { - PC = PC + (P[PC][BR_OFFSET] as number) -} - -M[OpCodes.CALL] = () => { - G = P[PC][CALL_NUM_ARGS_OFFSET] // lets keep number of arguments in G - // we peek down OS to get the closure - F = HEAP[OS + HEAP[OS + LAST_CHILD_SLOT] - G] - - E = HEAP[F + TAG_SLOT] === CLOSURE_TAG - if (E) { - J = NORMAL_CALL - FUNCTION_CALL() - } else { - STATE = CALL_NON_FUNCTION_ERROR - ERROR_MSG_ARGS[0] = convertToJsFormat(F) - RUNNING = false - } -} - -M[OpCodes.CALLT] = () => { - G = P[PC][CALLT_NUM_ARGS_OFFSET] // lets keep number of arguments in G - // we peek down OS to get the closure - F = HEAP[OS + HEAP[OS + LAST_CHILD_SLOT] - G] - - E = HEAP[F + TAG_SLOT] === CLOSURE_TAG - if (E) { - J = TAIL_CALL - FUNCTION_CALL() - } else { - STATE = CALL_NON_FUNCTION_ERROR - ERROR_MSG_ARGS[0] = convertToJsFormat(F) - RUNNING = false - } -} - -M[OpCodes.CALLP] = () => { - G = P[PC][CALLP_NUM_ARGS_OFFSET] // lets keep number of arguments in G - F = P[PC][CALLP_ID_OFFSET] // lets keep primitiveCall Id in F - F = HEAP[GLOBAL_ENV + HEAP[GLOBAL_ENV + FIRST_CHILD_SLOT] + F] // get closure - - E = HEAP[F + TAG_SLOT] === CLOSURE_TAG - if (E) { - J = PRIMITIVE_CALL - FUNCTION_CALL() - } else { - STATE = CALL_NON_FUNCTION_ERROR - ERROR_MSG_ARGS[0] = convertToJsFormat(F) - RUNNING = false - } -} - -M[OpCodes.CALLTP] = () => { - G = P[PC][CALLTP_NUM_ARGS_OFFSET] // lets keep number of arguments in G - F = P[PC][CALLTP_ID_OFFSET] // lets keep primitiveCall Id in F - F = HEAP[GLOBAL_ENV + HEAP[GLOBAL_ENV + FIRST_CHILD_SLOT] + F] // get closure - - E = HEAP[F + TAG_SLOT] === CLOSURE_TAG - if (E) { - J = PRIMITIVE_TAIL_CALL - FUNCTION_CALL() - } else { - STATE = CALL_NON_FUNCTION_ERROR - ERROR_MSG_ARGS[0] = convertToJsFormat(F) - RUNNING = false - } -} - -M[OpCodes.CALLV] = () => { - G = P[PC][CALLV_NUM_ARGS_OFFSET] - F = P[PC][CALLV_ID_OFFSET] - - E = F < INTERNAL_FUNCTIONS.length - if (E) { - J = INTERNAL_CALL - FUNCTION_CALL() - } else { - STATE = CALL_NON_FUNCTION_ERROR - ERROR_MSG_ARGS[0] = convertToJsFormat(F) - RUNNING = false - } -} - -M[OpCodes.CALLTV] = () => { - G = P[PC][CALLTV_NUM_ARGS_OFFSET] - F = P[PC][CALLTV_ID_OFFSET] - - E = F < INTERNAL_FUNCTIONS.length - if (E) { - J = INTERNAL_TAIL_CALL - FUNCTION_CALL() - } else { - STATE = CALL_NON_FUNCTION_ERROR - ERROR_MSG_ARGS[0] = convertToJsFormat(F) - RUNNING = false - } -} - -M[OpCodes.RETG] = () => { - POP_RTS() - H = RES - PC = HEAP[H + RTS_FRAME_PC_SLOT] - ENV = HEAP[H + RTS_FRAME_ENV_SLOT] - P = HEAP[H + RTS_FRAME_FUNC_INS_SLOT] - POP_OS() - A = RES - OS = HEAP[H + RTS_FRAME_OS_SLOT] - PUSH_OS() -} - -M[OpCodes.DUP] = () => { - POP_OS() - A = RES - PUSH_OS() - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.NEWENV] = () => { - B = ENV - A = P[PC][NEWENV_NUM_ARGS_OFFSET] // lets keep number of arguments in A - NEW_ENVIRONMENT() // after this, RES is new env - ENV = RES - PC = PC + 1 -} - -M[OpCodes.POPENV] = () => { - ENV = HEAP[ENV + PREVIOUS_ENV_SLOT] // restore to parent env - PC = PC + 1 -} - -// for now, we treat all primitive functions as normal functions -// until we find a way to deal with streams. -// problem with streams is that they create nullary functions, which -// will be called using CALL, and are considered normal functions by -// the compiler and machine -M[OpCodes.NEWCP] = () => { - A = P[PC][NEWCP_ID_OFFSET] - A = HEAP[GLOBAL_ENV + HEAP[GLOBAL_ENV + FIRST_CHILD_SLOT] + A] - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.NEWCV] = () => { - A = P[PC][NEWCV_ID_OFFSET] - B = CLOSURE_INTERNAL_TYPE - NEW_FUNCTION() - A = RES - PUSH_OS() - PC = PC + 1 -} - -// all opcodes from here onwards are custom to this implementation (3 Concurrent) -M[OpCodes.ARRAY_LEN] = () => { - POP_OS() - D = RES - A = HEAP[D + ARRAY_SIZE_SLOT] - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 - - G = HEAP[D + TAG_SLOT] === ARRAY_TAG - if (!G) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'array' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = 'array_length' - RUNNING = false - } -} - -M[OpCodes.DISPLAY] = () => { - POP_OS() - C = RES - POP_OS() - D = RES - externalFunctions.get(OpCodes.DISPLAY)(convertToJsFormat(D), convertToJsFormat(C)) - A = D - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.DRAW_DATA] = () => { - POP_OS() - externalFunctions.get(OpCodes.DRAW_DATA)(...convertToJsFormat(RES)) - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.ERROR] = () => { - POP_OS() - C = RES - POP_OS() - D = RES - externalFunctions.get(OpCodes.ERROR)(convertToJsFormat(D), convertToJsFormat(C)) - // terminates so don't do anything else - // A = D - // PUSH_OS() - // PC = PC + 1 -} - -M[OpCodes.IS_ARRAY] = () => { - POP_OS() - A = HEAP[RES + TAG_SLOT] === ARRAY_TAG - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.IS_BOOL] = () => { - POP_OS() - A = HEAP[RES + TAG_SLOT] === BOOL_TAG - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.IS_FUNC] = () => { - POP_OS() - A = HEAP[RES + TAG_SLOT] === CLOSURE_TAG - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.IS_NULL] = () => { - POP_OS() - A = HEAP[RES + TAG_SLOT] === NULL_TAG - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.IS_NUMBER] = () => { - POP_OS() - A = HEAP[RES + TAG_SLOT] === NUMBER_TAG - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.IS_STRING] = () => { - POP_OS() - A = HEAP[RES + TAG_SLOT] === STRING_TAG - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.IS_UNDEFINED] = () => { - POP_OS() - A = HEAP[RES + TAG_SLOT] === UNDEFINED_TAG - NEW_BOOL() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.MATH_HYPOT] = () => { - POP_OS() - A = Math.hypot(...convertToJsFormat(RES)) - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.STRINGIFY] = () => { - POP_OS() - A = stringify(convertToJsFormat(RES)) - NEW_STRING() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.PROMPT] = () => { - POP_OS() - A = externalFunctions.get(OpCodes.PROMPT)(convertToJsFormat(RES)) - NEW_STRING() - A = RES - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.DISPLAY_LIST] = () => { - POP_OS() - C = RES - POP_OS() - D = RES - externalFunctions.get(OpCodes.DISPLAY_LIST)(convertToJsFormat(D), convertToJsFormat(C)) - A = D - PUSH_OS() - PC = PC + 1 -} - -M[OpCodes.ARITY] = () => { - POP_OS() - D = RES - G = HEAP[D + TAG_SLOT] === CLOSURE_TAG - if (G) { - H = HEAP[D + CLOSURE_FUNC_INDEX_SLOT] - H = FUNC[H] - A = H[FUNC_NUM_ARGS_OFFSET] - if (A === VARARGS_NUM_ARGS) { - A = 0 - } - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 - } else { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'closure' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = 'arity' - RUNNING = false - } -} - -addPrimitiveOpCodeHandlers() - -// Internal functions. They are called directly in internal function calls -// All internal functions should not use register J or K, and can find -// the number of arguments in G. They should also not increment PC. - -// expects num args in G -M[OpCodes.EXECUTE] = () => { - I = G - E = OS // we need the values in OS, so store in E first - G = [OS, ENV, PC, P, RTS, TOP_RTS] // store current state first - // Keep track of registers first to restore present state after saving threads - for (; I > 0; I = I - 1) { - RTS = [] - TOP_RTS = -1 - OS = E - POP_OS() - H = RES // store closure in H - F = HEAP[H + CLOSURE_FUNC_INDEX_SLOT] - F = FUNC[F] // store function header in F - A = F[FUNC_MAX_STACK_SIZE_OFFSET] - NEW_OS() - OS = RES - A = F[FUNC_ENV_SIZE_OFFSET] - B = HEAP[H + CLOSURE_ENV_SLOT] - NEW_ENVIRONMENT() - ENV = RES - P = F[FUNC_CODE_OFFSET] - // enqueue to thread queue - PC = 0 - NEW_THREAD() - } - ;[OS, ENV, PC, P, RTS, TOP_RTS] = G // restore state -} - -M[OpCodes.TEST_AND_SET] = () => { - POP_OS() - D = RES // array - E = HEAP[D + TAG_SLOT] === ARRAY_TAG - if (!E) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'array' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = 'test_and_set' - RUNNING = false - } else { - E = HEAP[D + ARRAY_VALUE_SLOT][0] // get old boolean value - A = true - NEW_BOOL() - HEAP[D + ARRAY_VALUE_SLOT][0] = RES - A = E - PUSH_OS() // push old value to os - } -} - -M[OpCodes.CLEAR] = () => { - POP_OS() - D = RES // array - E = HEAP[D + TAG_SLOT] === ARRAY_TAG - if (!E) { - STATE = TYPE_ERROR - ERROR_MSG_ARGS[0] = 'array' - ERROR_MSG_ARGS[1] = `${node_kind(HEAP[D + TAG_SLOT])}` - ERROR_MSG_ARGS[2] = 'clear' - RUNNING = false - } else { - A = false - NEW_BOOL() - HEAP[D + ARRAY_VALUE_SLOT][0] = RES - } -} - -// called whenever the machine is first run -function INITIALIZE() { - D = FUNC[PROG[0]] // put function header in D - A = D[FUNC_MAX_STACK_SIZE_OFFSET] - P = D[FUNC_CODE_OFFSET] - NEW_OS() - OS = RES - A = D[FUNC_ENV_SIZE_OFFSET] - B = NIL - NEW_ENVIRONMENT() - ENV = RES - GLOBAL_ENV = ENV - PC = 0 -} - -// called during concurrent execution -function RUN_INSTRUCTION() { - if (TOP_RTS > -1 || P[PC][INS_OPCODE_OFFSET] !== OpCodes.RETG) { - // execute normally - if (M[P[PC][INS_OPCODE_OFFSET]] === undefined) { - throw Error('unknown op-code: ' + P[PC][INS_OPCODE_OFFSET]) - } - M[P[PC][INS_OPCODE_OFFSET]]() - TO = TO - 1 - } else { - // end of current thread, try to setup another thread - DELETE_CURRENT_THREAD() - GET_NUM_IDLE_THREADS() - if (RES === 0) { - // end if no more threads - RUNNING = false - } else { - // setup next thread - RUN_THREAD() - } - } -} - -function TIMEOUT_THREAD() { - // enqueue to thread queue - PAUSE_THREAD() - RUN_THREAD() -} - -function run(): any { - const MAX_TIME = JSSLANG_PROPERTIES.maxExecTime - const startTime = Date.now() - - // startup - INITIALIZE() - - while (RUNNING) { - // infinite loop protection - if (Date.now() - startTime > MAX_TIME) { - throw new PotentialInfiniteLoopError(locationDummyNode(-1, -1, null), MAX_TIME) - } - - if (TO > 0) { - // show_registers("run loop"); - // show_heap("run loop"); - // show_executing('') - RUN_INSTRUCTION() - } else if (TO === 0) { - // when exhausted time quanta - TIMEOUT_THREAD() - } else { - throw Error('TO cannot be negative') - } - } - - // handle errors - if (STATE !== NORMAL) { - throw Error('execution aborted: ' + getErrorType()) - } - - POP_OS() - // show_heap_value(RES) - // return convertToJsFormat(RES) - // Source 3 Concurrent programs do not return anything. - return 'all threads terminated' -} - -function getErrorType(): string { - switch (STATE) { - case DIV_ERROR: - return 'division by 0' - case TYPE_ERROR: - // 0: expected types - // 1: received types - // 2: operator - return `Expected ${ERROR_MSG_ARGS[0]}, got ${ERROR_MSG_ARGS[1]} for ${ERROR_MSG_ARGS[2]}.` - case NUM_ARGS_ERROR: - return `Expected ${ERROR_MSG_ARGS[0]} arguments, but got ${ERROR_MSG_ARGS[1]}.` - case CALL_NON_FUNCTION_ERROR: - return `calling non-function value ${ERROR_MSG_ARGS[0]}.` - default: - throw Error('invalid error type') - } -} - -function convertToJsFormat(node: number, refs?: Map<number, any>): any { - if (refs !== undefined && refs.has(node)) { - return refs.get(node) - } - const kind = node_kind(HEAP[node + TAG_SLOT]) - switch (kind) { - case 'undefined': - return undefined - - case 'null': - return null - - case 'number': - case 'string': - case 'boolean': - return HEAP[node + BOXED_VALUE_SLOT] - - case 'array': { - if (refs === undefined) { - refs = new Map<number, any>() - } - const arr: number[] = HEAP[node + BOXED_VALUE_SLOT] - const res: any[] = [] - refs.set(node, res) - for (let i = 0; i < arr.length; i++) { - res[i] = convertToJsFormat(arr[i], refs) - } - return res - } - case 'closure': - return '<Function>' - default: - throw Error('Encountered unexpressible type: ' + kind) - } -} - -// if program has primitive calls, prelude must be included. -// this implementation also assumes a correct program, and does not -// currently check for type correctness -// an incorrect program will have undefined behaviors -export function runWithProgram(p: Program, context: Context): any { - PROG = p - FUNC = PROG[1] // list of SVMFunctions - P = [] - PC = -1 - HEAP = [] - FREE = 0 - GLOBAL_ENV = NIL - ENV = NIL - OS = -Infinity - RES = -Infinity - RTS = [] - TO = 0 - TOP_RTS = -1 - STATE = NORMAL - RUNNING = true - ERROR_MSG_ARGS = [] - - INIT_SCHEDULER() - - A = 0 - B = 0 - C = 0 - D = 0 - E = 0 - F = 0 - G = 0 - H = 0 - I = 0 - J = 0 - K = 0 - - // setup externalBuiltins - // certain functions are imported from cadet-frontend - // so import them first every time - const externals = context.nativeStorage.builtins - if (externals.size > 0) { - EXTERNAL_PRIMITIVES.forEach(func => extractExternalBuiltin(func, externals)) - } - - return run() -} - -function addPrimitiveOpCodeHandlers() { - function addNullaryHandler(opcode: number, f: () => number) { - M[opcode] = () => { - A = f() - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 - } - } - function addUnaryHandler(opcode: number, f: (x: number) => number) { - M[opcode] = () => { - POP_OS() - A = HEAP[RES + NUMBER_VALUE_SLOT] - A = f(A) - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 - } - } - // string as well due to parseInt. Only works due to current - // representation of strings. Must change if the machine changes - // to a more authentic representation of strings - function addBinaryHandler(opcode: number, f: (x: number | string, y: number) => number) { - M[opcode] = () => { - POP_OS() - C = HEAP[RES + NUMBER_VALUE_SLOT] - POP_OS() - D = HEAP[RES + BOXED_VALUE_SLOT] - A = f(D, C) - NEW_NUMBER() - A = RES - PUSH_OS() - PC = PC + 1 - } - } - - NULLARY_PRIMITIVES.forEach(func => { - if (func[2]) addNullaryHandler(func[1], func[2]) - }) - UNARY_PRIMITIVES.forEach(func => { - if (func[2]) addUnaryHandler(func[1], func[2]) - }) - BINARY_PRIMITIVES.concat([ - ['', OpCodes.MATH_MAX, Math.max], // only want the handler - ['', OpCodes.MATH_MIN, Math.min] - ]).forEach(func => { - if (func[2]) addBinaryHandler(func[1], func[2]) - }) -} - -const externalFunctions = new Map<number, any>() -function extractExternalBuiltin(func: [string, number], externals: Map<string, any>) { - const name = func[0] - const opcode = func[1] - externalFunctions.set(opcode, externals.get(name)) -} From 81f19d0141290a2276bb784de50f951883732682 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G08HS3B\\Lee Yi" <leeyi45@gmail.com> Date: Mon, 3 Mar 2025 02:08:04 -0500 Subject: [PATCH 02/17] Run format --- src/createContext.ts | 2 +- src/index.ts | 2 +- src/repl/__tests__/main.ts | 2 +- src/repl/__tests__/svmc.ts | 2 +- src/repl/__tests__/transpiler.ts | 2 +- src/repl/__tests__/utils.ts | 2 +- src/repl/index.ts | 2 +- src/repl/main.ts | 2 +- src/repl/svmc.ts | 2 +- src/repl/transpiler.ts | 5 +---- src/runner/sourceRunner.ts | 5 ++++- src/types.ts | 2 +- src/utils/testing/misc.ts | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/createContext.ts b/src/createContext.ts index 8525471ff..ac4a8ece0 100644 --- a/src/createContext.ts +++ b/src/createContext.ts @@ -119,7 +119,7 @@ const createEmptyDebugger = () => ({ state: { it: (function* (): any { return - })(), + })() } }) diff --git a/src/index.ts b/src/index.ts index 799bfa19b..46028b898 100644 --- a/src/index.ts +++ b/src/index.ts @@ -253,7 +253,7 @@ export async function runFilesInContext( export function resume(result: Result): Finished | ResultError | Promise<Result> { if (result.status === 'finished' || result.status === 'error') { return result - } + } const value = resumeEvaluate(result.context) return CSEResultPromise(result.context, value) } diff --git a/src/repl/__tests__/main.ts b/src/repl/__tests__/main.ts index 6477a99a0..421e136e8 100644 --- a/src/repl/__tests__/main.ts +++ b/src/repl/__tests__/main.ts @@ -17,4 +17,4 @@ describe('Make sure each subcommand can be run', () => { ) } ) -}) \ No newline at end of file +}) diff --git a/src/repl/__tests__/svmc.ts b/src/repl/__tests__/svmc.ts index 8ec41b934..80bc98884 100644 --- a/src/repl/__tests__/svmc.ts +++ b/src/repl/__tests__/svmc.ts @@ -107,4 +107,4 @@ describe('Test output options', () => { expect(contents).toMatchSnapshot() }) }) -}) \ No newline at end of file +}) diff --git a/src/repl/__tests__/transpiler.ts b/src/repl/__tests__/transpiler.ts index 34862d6d1..753f98cb3 100644 --- a/src/repl/__tests__/transpiler.ts +++ b/src/repl/__tests__/transpiler.ts @@ -63,4 +63,4 @@ test('pretranspile option', async () => { const [[fileName, contents]] = mockedWriteFile.mock.calls expect(fileName).toEqual('out.js') expect(contents).toEqual('1 + 1;\n') -}) \ No newline at end of file +}) diff --git a/src/repl/__tests__/utils.ts b/src/repl/__tests__/utils.ts index 5cc73689e..fb944018e 100644 --- a/src/repl/__tests__/utils.ts +++ b/src/repl/__tests__/utils.ts @@ -35,4 +35,4 @@ export function expectWritten(f: (contents: string) => any) { expect(f).toHaveBeenCalledTimes(1) const [[contents]] = asMockedFunc(f).mock.calls return expect(contents) -} \ No newline at end of file +} diff --git a/src/repl/index.ts b/src/repl/index.ts index 14c3f211a..a1c7aefd7 100644 --- a/src/repl/index.ts +++ b/src/repl/index.ts @@ -1,4 +1,4 @@ #!/bin/env/node import { getMainCommand } from './main' -getMainCommand().parseAsync() \ No newline at end of file +getMainCommand().parseAsync() diff --git a/src/repl/main.ts b/src/repl/main.ts index 3bfcbdf80..6ca6834ae 100644 --- a/src/repl/main.ts +++ b/src/repl/main.ts @@ -8,4 +8,4 @@ export const getMainCommand = () => new Command() .addCommand(getSVMCCommand()) .addCommand(getTranspilerCommand()) - .addCommand(getReplCommand(), { isDefault: true }) \ No newline at end of file + .addCommand(getReplCommand(), { isDefault: true }) diff --git a/src/repl/svmc.ts b/src/repl/svmc.ts index e285a01cf..5cba0dd37 100644 --- a/src/repl/svmc.ts +++ b/src/repl/svmc.ts @@ -103,4 +103,4 @@ strings containing the names of the VM-internal functions.` const outputFileName = opts.out ?? `${basename(inputFile, extToRemove)}${ext}` await fs.writeFile(outputFileName, output) console.log(`Output written to ${outputFileName}`) - }) \ No newline at end of file + }) diff --git a/src/repl/transpiler.ts b/src/repl/transpiler.ts index 3ab8c9708..a65edfc30 100644 --- a/src/repl/transpiler.ts +++ b/src/repl/transpiler.ts @@ -20,10 +20,7 @@ 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('-p, --pretranspile', "only pretranspile and don't perform Source -> JS transpilation") .option('-o, --out <outFile>', 'Specify a file to write to') .argument('<filename>') .action(async (fileName, opts) => { diff --git a/src/runner/sourceRunner.ts b/src/runner/sourceRunner.ts index 3795a3d1e..99ed0445a 100644 --- a/src/runner/sourceRunner.ts +++ b/src/runner/sourceRunner.ts @@ -223,7 +223,10 @@ async function sourceRunner( return runCSEMachine(program, context, theOptions) } - assert(context.executionMethod !== 'auto', 'Execution method should have been properly determined!') + assert( + context.executionMethod !== 'auto', + 'Execution method should have been properly determined!' + ) return runNative(program, context, theOptions) } diff --git a/src/types.ts b/src/types.ts index b68dcd46b..4473caa88 100644 --- a/src/types.ts +++ b/src/types.ts @@ -498,4 +498,4 @@ export type RecursivePartial<T> = T extends Array<any> }> : T -export type NodeTypeToNode<T extends Node['type']> = Extract<Node, { type: T }> \ No newline at end of file +export type NodeTypeToNode<T extends Node['type']> = Extract<Node, { type: T }> diff --git a/src/utils/testing/misc.ts b/src/utils/testing/misc.ts index 4ca9fc519..c6e0cc1e7 100644 --- a/src/utils/testing/misc.ts +++ b/src/utils/testing/misc.ts @@ -24,4 +24,4 @@ export function expectNodeType<T extends Node['type']>( node: Node ): asserts node is NodeTypeToNode<T> { expect(node.type).toEqual(typeStr) -} \ No newline at end of file +} From 423bff4ac49445f65384ee37e619f57675da2360 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G08HS3B\\Lee Yi" <leeyi45@gmail.com> Date: Mon, 3 Mar 2025 02:19:31 -0500 Subject: [PATCH 03/17] Remove interpreter --- .../__snapshots__/interpreter-errors.ts.snap | 1106 ---------------- .../__tests__/interpreter-errors.ts | 1127 ----------------- src/interpreter/closure.ts | 138 -- src/interpreter/interpreter.ts | 858 ------------- 4 files changed, 3229 deletions(-) delete mode 100644 src/interpreter/__tests__/__snapshots__/interpreter-errors.ts.snap delete mode 100644 src/interpreter/__tests__/interpreter-errors.ts delete mode 100644 src/interpreter/closure.ts delete mode 100644 src/interpreter/interpreter.ts 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 <number> * <nonnumber>, error line at <number>, not <nonnumber>: 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 = <T extends FunctionLike>(func: T) => func as MockedFunction<T> -// 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 <number> * <nonnumber>, error line at <number>, not <nonnumber>', () => { - 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<null | Node> { - 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<T extends Node> = (node: T, context: Context) => IterableIterator<Value> - -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<Node> } = { - /** 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 -} From 2066efa8dca9bfe2cf28fa94e6f0527b0a030737 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G08HS3B\\Lee Yi" <leeyi45@gmail.com> Date: Mon, 3 Mar 2025 15:38:54 -0500 Subject: [PATCH 04/17] Remove interpreter and refactor tests --- .../__snapshots__/block-scoping.ts.snap | 216 - src/__tests__/__snapshots__/display.ts.snap | 184 - src/__tests__/__snapshots__/draw_data.ts.snap | 49 - src/__tests__/__snapshots__/index.ts.snap | 783 - src/__tests__/__snapshots__/inspect.ts.snap | 2761 - .../__snapshots__/return-regressions.ts.snap | 359 - src/__tests__/__snapshots__/stdlib.ts.snap | 828 +- src/__tests__/__snapshots__/stringify.ts.snap | 543 - .../__snapshots__/tailcall-return.ts.snap | 169 - src/__tests__/block-scoping.ts | 30 +- src/__tests__/display.ts | 77 +- src/__tests__/environment.ts | 7 +- src/__tests__/environmentTree.ts | 4 +- src/__tests__/index.ts | 294 +- src/__tests__/inspect.ts | 483 - src/__tests__/return-regressions.ts | 30 +- src/__tests__/stdlib.ts | 5 +- src/__tests__/stringify-benchmark.ts | 3 +- src/__tests__/stringify.ts | 54 +- src/__tests__/tailcall-return.ts | 33 +- src/alt-langs/__tests__/mapper.ts | 2 +- .../scheme/__tests__/scheme-parser.ts | 2 +- .../cse-machine-callcc-js.ts.snap | 77 - .../__snapshots__/cse-machine-callcc.ts.snap | 100 - .../__snapshots__/cse-machine-errors.ts.snap | 1049 - .../cse-machine-return-regressions.ts.snap | 359 - .../__snapshots__/cse-machine-stdlib.ts.snap | 620 +- .../__snapshots__/cse-machine.ts.snap | 568 - .../__snapshots__/cset-machine-apply.ts.snap | 84 - .../__snapshots__/cset-machine-eval.ts.snap | 224 - .../__snapshots__/cset-machine-macros.ts.snap | 97 - .../__snapshots__/cset-machine.ts.snap | 376 - src/cse-machine/__tests__/continuations.ts | 2 +- .../__tests__/cse-machine-errors.ts | 28 +- src/cse-machine/__tests__/cse-machine-heap.ts | 6 +- .../__tests__/cse-machine-runtime-context.ts | 2 +- .../__tests__/cse-machine-stdlib.ts | 6 +- .../__tests__/cse-machine-unique-id.ts | 2 +- src/index.ts | 1 - src/infiniteLoops/__tests__/errors.ts | 2 +- src/infiniteLoops/__tests__/instrument.ts | 36 +- src/infiniteLoops/__tests__/runtime.ts | 2 +- src/modules/loader/__tests__/loader.ts | 4 +- .../loader/__tests__/requireProvider.ts | 2 +- .../preprocessor/__tests__/analyzer.ts | 2 +- src/modules/preprocessor/__tests__/linker.ts | 2 +- .../preprocessor/__tests__/preprocessor.ts | 2 +- .../transformers/hoistAndMergeImports.ts | 2 +- .../__tests__/transformers/removeExports.ts | 2 +- .../transformProgramToFunctionDeclaration.ts | 2 +- src/name-extractor/__tests__/modules.ts | 4 +- .../__snapshots__/allowed-syntax.ts.snap | 423173 ++++++++++++++- .../__snapshots__/disallowed-syntax.ts.snap | 1471 - .../__tests__/__snapshots__/tokenize.ts.snap | 262 - src/parser/__tests__/allowed-syntax.ts | 16 +- src/parser/__tests__/disallowed-syntax.ts | 8 +- src/parser/__tests__/fullTS.ts | 2 +- src/parser/__tests__/python.ts | 2 +- src/parser/__tests__/tokenize.ts | 56 +- src/repl/__tests__/__snapshots__/svmc.ts.snap | 138 + .../__snapshots__/transpiler.ts.snap | 199 + src/repl/__tests__/repl.ts | 2 +- src/repl/__tests__/svmc.ts | 19 +- src/repl/__tests__/transpiler.ts | 4 +- src/runner/__tests__/files.ts | 2 +- src/runner/__tests__/modules.ts | 4 +- src/runner/__tests__/runners.ts | 14 +- src/runner/sourceRunner.ts | 3 +- .../__tests__/__snapshots__/list.ts.snap | 1098 - .../__snapshots__/localImport.ts.snap | 116 - .../__tests__/__snapshots__/misc.ts.snap | 280 - .../__snapshots__/parser-errors.ts.snap | 27 - .../__tests__/__snapshots__/parser.ts.snap | 131804 +++++ .../__tests__/__snapshots__/pylib.ts.snap | 352 - .../__tests__/__snapshots__/stream.ts.snap | 303 - src/stdlib/__tests__/list-benchmark.ts | 1 - src/stdlib/__tests__/list.ts | 279 +- src/stdlib/__tests__/localImport.ts | 12 +- src/stdlib/__tests__/misc.ts | 22 +- src/stdlib/__tests__/parser.ts | 32 +- src/stdlib/__tests__/pylib.ts | 54 +- src/stdlib/__tests__/stream.ts | 113 +- src/stdlib/misc.ts | 2 +- src/stepper/__tests__/stepper.ts | 2 +- src/stepper/converter.ts | 4 +- src/transpiler/__tests__/native.ts | 2 +- src/transpiler/__tests__/transpiled-code.ts | 2 +- .../__tests__/source1Typed.test.ts | 2 +- .../__tests__/source2Typed.test.ts | 2 +- .../__tests__/source3Typed.test.ts | 2 +- .../__tests__/source4Typed.test.ts | 2 +- .../__tests__/source4TypedModules.test.ts | 2 +- src/utils/__tests__/rttc.ts | 2 +- src/utils/stringify.ts | 2 +- src/utils/testing/__tests__/testing.ts | 47 + src/utils/testing/index.ts | 439 +- src/utils/testing/misc.ts | 20 +- .../context.ts => utils/testing/mocks.ts} | 35 +- src/utils/testing/types.ts | 23 + .../__tests__/__snapshots__/validator.ts.snap | 32 - src/validator/__tests__/validator.ts | 2 +- .../__snapshots__/svml-machine.ts.snap | 1735 - 102 files changed, 551865 insertions(+), 20941 deletions(-) delete mode 100644 src/__tests__/__snapshots__/block-scoping.ts.snap delete mode 100644 src/__tests__/__snapshots__/display.ts.snap delete mode 100644 src/__tests__/__snapshots__/draw_data.ts.snap delete mode 100644 src/__tests__/__snapshots__/inspect.ts.snap delete mode 100644 src/__tests__/__snapshots__/return-regressions.ts.snap delete mode 100644 src/__tests__/__snapshots__/stringify.ts.snap delete mode 100644 src/__tests__/__snapshots__/tailcall-return.ts.snap delete mode 100644 src/__tests__/inspect.ts delete mode 100644 src/cse-machine/__tests__/__snapshots__/cse-machine-callcc-js.ts.snap delete mode 100644 src/cse-machine/__tests__/__snapshots__/cse-machine-callcc.ts.snap delete mode 100644 src/cse-machine/__tests__/__snapshots__/cse-machine-errors.ts.snap delete mode 100644 src/cse-machine/__tests__/__snapshots__/cse-machine-return-regressions.ts.snap delete mode 100644 src/cse-machine/__tests__/__snapshots__/cse-machine.ts.snap delete mode 100644 src/cse-machine/__tests__/__snapshots__/cset-machine-apply.ts.snap delete mode 100644 src/cse-machine/__tests__/__snapshots__/cset-machine-eval.ts.snap delete mode 100644 src/cse-machine/__tests__/__snapshots__/cset-machine-macros.ts.snap delete mode 100644 src/cse-machine/__tests__/__snapshots__/cset-machine.ts.snap delete mode 100644 src/parser/__tests__/__snapshots__/disallowed-syntax.ts.snap delete mode 100644 src/parser/__tests__/__snapshots__/tokenize.ts.snap create mode 100644 src/repl/__tests__/__snapshots__/svmc.ts.snap create mode 100644 src/repl/__tests__/__snapshots__/transpiler.ts.snap delete mode 100644 src/stdlib/__tests__/__snapshots__/list.ts.snap delete mode 100644 src/stdlib/__tests__/__snapshots__/localImport.ts.snap delete mode 100644 src/stdlib/__tests__/__snapshots__/misc.ts.snap delete mode 100644 src/stdlib/__tests__/__snapshots__/parser-errors.ts.snap create mode 100644 src/stdlib/__tests__/__snapshots__/parser.ts.snap delete mode 100644 src/stdlib/__tests__/__snapshots__/pylib.ts.snap delete mode 100644 src/stdlib/__tests__/__snapshots__/stream.ts.snap create mode 100644 src/utils/testing/__tests__/testing.ts rename src/{mocks/context.ts => utils/testing/mocks.ts} (64%) create mode 100644 src/utils/testing/types.ts delete mode 100644 src/vm/__tests__/__snapshots__/svml-machine.ts.snap 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<String>, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`debugger; pauses for 2`] = ` -Object { - "head": Object { - "_copy_of_i": 0, - }, - "id": Any<String>, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`debugger; pauses for 3`] = ` -Object { - "head": Object { - "i": 0, - }, - "id": Any<String>, - "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<String>, - "name": "a", - "tail": null, -} -`; - -exports[`debugger; pauses for 5`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "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<String>, - "name": "a", - "tail": null, -} -`; - -exports[`debugger; pauses while 2`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; pauses while 4`] = `""`; - -exports[`debugger; statement basic test 1`] = ` -Object { - "head": Object { - "a": 2, - }, - "id": Any<String>, - "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<String>, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement basic test 3`] = `""`; - -exports[`debugger; statement execution sequence 1`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "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<String>, - "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<String>, - "name": "a", - "tail": null, -} -`; - -exports[`debugger; statement hoisting 3`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "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<String>, - "name": "a", - "tail": null, -} -`; - -exports[`debugger; statement in function 2`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "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<String>, - "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<String>, - "name": "a", - "tail": null, -} -`; - -exports[`debugger; statement test function scope 3`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "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<String>, - "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<String>, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine basic 3`] = `""`; - -exports[`setBreakpointAtLine for loops 1`] = ` -Object { - "head": Object { - "b": Symbol(Used to implement hoisting), - }, - "id": Any<String>, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine for loops 2`] = ` -Object { - "head": Object { - "i": 1, - }, - "id": Any<String>, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine for loops 3`] = ` -Object { - "head": Object { - "_copy_of_i": 1, - }, - "id": Any<String>, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine for loops 4`] = ` -Object { - "head": Object { - "i": 1, - }, - "id": Any<String>, - "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<String>, - "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<String>, - "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<String>, - "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<String>, - "name": "a", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 2 2`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 2 4`] = `""`; - -exports[`setBreakpointAtLine function 3 1`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 3 3`] = `""`; - -exports[`setBreakpointAtLine function 4 1`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "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<String>, - "name": "a", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 1 2`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "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<String>, - "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<String>, - "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<String>, - "name": "a", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 2 4`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "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<String>, - "name": "a", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 3 2`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any<String>, - "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<String>, - "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<String>, - "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<String>, - "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, ...<circular>]]], -[[2, [3, [1, ...<circular>]]], [[3, [1, [2, ...<circular>]]], 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\\": ...<circular>}", - "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: () => '<RUNE>' }; -stringify(o);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "<RUNE>", - "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<x; i=i+1){ - 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('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<Result>).then(obj2 => { - return (resume(obj2) as Promise<Result>).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<Result>).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<Result>).then(obj2 => { - expect(flattenEnvironments(obj2)).toMatchSnapshot() - expect(obj2.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj2) as Promise<Result>).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<Result>).then(obj2 => { - expect(flattenEnvironments(obj2)).toMatchSnapshot() - expect(obj2.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj2) as Promise<Result>).then(obj3 => { - expect(flattenEnvironments(obj3)).toMatchSnapshot() - expect(obj3.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj3) as Promise<Result>).then(obj4 => { - expect(flattenEnvironments(obj4)).toMatchSnapshot() - expect(obj4.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj4) as Promise<Result>).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<Result>).then(obj2 => { - expect(flattenEnvironments(obj2)).toMatchSnapshot() - expect(obj2.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj2) as Promise<Result>).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, ...<circular>]]], [[2, [3, [1, ...<circular>]]], [[3, [1, [2, ...<circular>]]], 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: () => '<RUNE>' }; stringify(o); `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toMatchInlineSnapshot(`"<RUNE>"`) }) @@ -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\\": ...<circular>}"`) }) @@ -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/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 <number> * <nonnumber>, error line at <number>, not <nonnumber>: 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/index.ts b/src/index.ts index 46028b898..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 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/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..5fd064f92 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' diff --git a/src/modules/preprocessor/__tests__/preprocessor.ts b/src/modules/preprocessor/__tests__/preprocessor.ts index aa6d5d307..4c5c06d28 100644 --- a/src/modules/preprocessor/__tests__/preprocessor.ts +++ b/src/modules/preprocessor/__tests__/preprocessor.ts @@ -2,7 +2,7 @@ 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 '..' diff --git a/src/modules/preprocessor/__tests__/transformers/hoistAndMergeImports.ts b/src/modules/preprocessor/__tests__/transformers/hoistAndMergeImports.ts index b86cc64c1..1f8dbbb88 100644 --- a/src/modules/preprocessor/__tests__/transformers/hoistAndMergeImports.ts +++ b/src/modules/preprocessor/__tests__/transformers/hoistAndMergeImports.ts @@ -1,4 +1,4 @@ -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' diff --git a/src/modules/preprocessor/__tests__/transformers/removeExports.ts b/src/modules/preprocessor/__tests__/transformers/removeExports.ts index c53f9fb44..37f252101 100644 --- a/src/modules/preprocessor/__tests__/transformers/removeExports.ts +++ b/src/modules/preprocessor/__tests__/transformers/removeExports.ts @@ -1,4 +1,4 @@ -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' diff --git a/src/modules/preprocessor/__tests__/transformers/transformProgramToFunctionDeclaration.ts b/src/modules/preprocessor/__tests__/transformers/transformProgramToFunctionDeclaration.ts index 201b0f26d..a5659651b 100644 --- a/src/modules/preprocessor/__tests__/transformers/transformProgramToFunctionDeclaration.ts +++ b/src/modules/preprocessor/__tests__/transformers/transformProgramToFunctionDeclaration.ts @@ -1,4 +1,4 @@ -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' 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" =>