├── .gitattributes ├── .github └── workflows │ └── bundle.yaml ├── .gitignore ├── .gitmodules ├── .valgrindrc ├── LICENSE ├── doc ├── bench-amd3600-nov-2020.png ├── koka.css ├── logo │ ├── koka-banner.png │ ├── koka-logo-100.png │ ├── koka-logo-200.png │ ├── koka-logo-400.png │ ├── koka-logo-filled.png │ ├── koka-logo-url.png │ ├── koka-logo-v2-100.png │ ├── koka-logo-v2-200.png │ ├── koka-logo-v2-400.png │ ├── koka-logo-v2-800.png │ ├── koka-logo.png │ └── logo.docx ├── rise4fun │ ├── guide.kk.md │ ├── guide.kkdoc │ └── risekoka.css ├── snippet-rbtree.png ├── snippet-yield.png ├── spec │ ├── arm64.json │ ├── book-style.md │ ├── book.kk.md │ ├── getstarted.kk.md │ ├── grammar │ │ ├── lexer.l │ │ ├── parser.y │ │ └── readme.md │ ├── ignores.dic │ ├── images │ │ ├── logo-alpine.svg │ │ ├── logo-arch.svg │ │ ├── logo-debian.svg │ │ ├── logo-freebsd.svg │ │ ├── penrose-tiling.png │ │ ├── perceus-perf-bw.png │ │ ├── perceus-perf.png │ │ ├── perceus3.jpg │ │ ├── vscode-caesar.png │ │ ├── vscode-codelens.png │ │ ├── vscode-commands.png │ │ ├── vscode-inlay-off.png │ │ ├── vscode-inlay-on.png │ │ ├── vscode-install-compiler.png │ │ ├── vscode-install.png │ │ └── vscode-rbtree.png │ ├── index.kk.md │ ├── install.mdk │ ├── koka.bib │ ├── koka.json │ ├── news.mdk │ ├── scripts │ │ └── book.js │ ├── spec.kk.md │ ├── styles │ │ ├── book.css │ │ ├── koka-logo.png │ │ ├── webanchors.mdk │ │ └── webtoc.mdk │ ├── tour.kk.md │ ├── unchecked.json │ └── why.kk.md └── system-logos.png ├── kklib ├── CMakeLists.txt ├── ide │ ├── vs2019 │ │ ├── kklib-test-effbayes.vcxproj │ │ ├── kklib-test-effbayes.vcxproj.filters │ │ ├── kklib-test-effbayes.vcxproj.user │ │ ├── kklib-test-interactive.vcxproj │ │ ├── kklib-test-interactive.vcxproj.filters │ │ ├── kklib-test-interactive.vcxproj.interactive │ │ ├── kklib-test-interactive.vcxproj.user │ │ ├── kklib-test.vcxproj │ │ ├── kklib-test.vcxproj.filters │ │ ├── kklib-test.vcxproj.user │ │ ├── kklib.natvis │ │ ├── kklib.sln │ │ ├── kklib.vcxproj │ │ ├── kklib.vcxproj.filters │ │ └── kklib.vcxproj.user │ └── vs2022 │ │ ├── kklib-test-effbayes.vcxproj │ │ ├── kklib-test-effbayes.vcxproj.filters │ │ ├── kklib-test-interactive.vcxproj │ │ ├── kklib-test-interactive.vcxproj.filters │ │ ├── kklib-test.vcxproj │ │ ├── kklib-test.vcxproj.filters │ │ ├── kklib.natvis │ │ ├── kklib.sln │ │ ├── kklib.vcxproj │ │ └── kklib.vcxproj.filters ├── include │ ├── kklib.h │ └── kklib │ │ ├── atomic.h │ │ ├── bits.h │ │ ├── box.h │ │ ├── bytes.h │ │ ├── integer.h │ │ ├── lazy.h │ │ ├── maybe.h │ │ ├── os.h │ │ ├── platform.h │ │ ├── process.h │ │ ├── random.h │ │ ├── ref.h │ │ ├── string.h │ │ ├── thread.h │ │ └── vector.h ├── src │ ├── all.c │ ├── bits.c │ ├── box.c │ ├── bytes.c │ ├── init.c │ ├── integer.c │ ├── lazy.c │ ├── os.c │ ├── process.c │ ├── random.c │ ├── ref.c │ ├── refcount.c │ ├── string.c │ ├── thread.c │ ├── time.c │ └── vector.c └── test │ ├── main.c │ ├── time.c │ └── time.h ├── koka.cabal ├── lib ├── package.std.json ├── std │ ├── async │ │ ├── file.kk │ │ └── readline.kk │ ├── core.kk │ ├── core │ │ ├── bool.kk │ │ ├── char.kk │ │ ├── console.kk │ │ ├── debug.kk │ │ ├── delayed.kk │ │ ├── either.kk │ │ ├── exn.kk │ │ ├── hnd.kk │ │ ├── inline │ │ │ ├── console.js │ │ │ ├── core.c │ │ │ ├── core.cs │ │ │ ├── core.h │ │ │ ├── debug.c │ │ │ ├── exn.c │ │ │ ├── exn.h │ │ │ ├── exn.js │ │ │ ├── hnd.c │ │ │ ├── hnd.h │ │ │ ├── hnd.js │ │ │ ├── int.h │ │ │ ├── int.js │ │ │ ├── sslice.c │ │ │ ├── sslice.h │ │ │ ├── sslice.js │ │ │ ├── string.c │ │ │ ├── string.h │ │ │ ├── string.js │ │ │ ├── types-cctx.c │ │ │ ├── types-cctx.h │ │ │ ├── types-cctx.js │ │ │ ├── types.js │ │ │ ├── vector.c │ │ │ ├── vector.h │ │ │ └── vector.js │ │ ├── int.kk │ │ ├── lazy.kk │ │ ├── list.kk │ │ ├── maybe.kk │ │ ├── maybe2.kk │ │ ├── order.kk │ │ ├── show.kk │ │ ├── sslice.kk │ │ ├── string.kk │ │ ├── tuple.kk │ │ ├── types.kk │ │ ├── undiv.kk │ │ ├── unsafe.kk │ │ └── vector.kk │ ├── data │ │ ├── array.kk │ │ ├── dict.kk │ │ ├── imap.kk │ │ ├── iset.kk │ │ ├── map.kk │ │ └── set.kk │ ├── num │ │ ├── ddouble.kk │ │ ├── decimal.kk │ │ ├── float64-inline.c │ │ ├── float64-inline.h │ │ ├── float64-inline.js │ │ ├── float64.kk │ │ ├── int32-inline.c │ │ ├── int32.kk │ │ ├── int64-inline.c │ │ ├── int64.kk │ │ ├── random-inline.js │ │ └── random.kk │ ├── os │ │ ├── dir-inline.c │ │ ├── dir.kk │ │ ├── env.kk │ │ ├── file-inline.c │ │ ├── file-inline.js │ │ ├── file.kk │ │ ├── flags.kk │ │ ├── null.kk │ │ ├── path-inline.cs │ │ ├── path-inline.js │ │ ├── path.kk │ │ ├── process-inline.c │ │ ├── process.kk │ │ ├── readline-inline.c │ │ ├── readline-inline.js │ │ ├── readline.kk │ │ └── task.kk │ ├── text │ │ ├── parse.kk │ │ ├── regex-inline.c │ │ ├── regex-inline.cs │ │ ├── regex-inline.js │ │ ├── regex.kk │ │ ├── unicode-inline.cs │ │ ├── unicode-inline.js │ │ └── unicode.kk │ ├── time.kk │ └── time │ │ ├── astro.kk │ │ ├── calendar-inline.c │ │ ├── calendar-inline.cs │ │ ├── calendar-inline.js │ │ ├── calendar.kk │ │ ├── calendars.kk │ │ ├── chrono-inline.c │ │ ├── chrono-inline.cs │ │ ├── chrono-inline.js │ │ ├── chrono.kk │ │ ├── date.kk │ │ ├── download.kk │ │ ├── duration.kk │ │ ├── format.kk │ │ ├── instant.kk │ │ ├── locale.kk │ │ ├── parse.kk │ │ ├── time.kk │ │ ├── timer-inline.c │ │ ├── timer-inline.cs │ │ ├── timer-inline.js │ │ ├── timer.kk │ │ ├── timescales.png │ │ ├── timestamp.kk │ │ ├── timezone-inline.js │ │ ├── timezone.kk │ │ ├── ut1.kk │ │ └── utc.kk ├── toc.kk └── v1 │ ├── demo │ ├── chatbot.kk │ ├── collatz.kk │ ├── dom │ │ ├── conway.kk │ │ ├── flyingDivs.kk │ │ ├── microsoftLogo.kk │ │ ├── starfield.kk │ │ └── tile.kk │ ├── fib.kk │ ├── garsiaWachs.kk │ ├── node │ │ ├── chatMoebius.kk │ │ └── chatRpc.kk │ └── nqueens.kk │ └── std │ ├── async-inline.cs │ ├── async-inline.js │ ├── async.kk │ ├── crypto-inline.cs │ ├── crypto-inline.js │ ├── crypto.kk │ ├── data │ ├── array.kk │ ├── dict-inline.js │ └── dict.kk │ ├── log.kk │ ├── net │ ├── http-inline.js │ └── http.kk │ ├── os │ ├── file-inline.cs │ ├── file-inline.js │ ├── file.kk │ ├── readline-inline.cs │ ├── readline-inline.js │ └── readline.kk │ ├── sys │ ├── dom.kk │ ├── dom │ │ ├── anonXmlHttpRequest.kk │ │ ├── attr.kk │ │ ├── booleanArray.kk │ │ ├── byteArray.kk │ │ ├── caretPosition.kk │ │ ├── characterData.kk │ │ ├── comment.kk │ │ ├── css │ │ │ ├── counter.kk │ │ │ ├── css2Properties.kk │ │ │ ├── cssCharsetRule.kk │ │ │ ├── cssColorComponentValue.kk │ │ │ ├── cssComponentValue.kk │ │ │ ├── cssFontFaceRule.kk │ │ │ ├── cssIdentifierComponentValue.kk │ │ │ ├── cssImportRule.kk │ │ │ ├── cssKeywordComponentValue.kk │ │ │ ├── cssLengthComponentValue.kk │ │ │ ├── cssMapValue.kk │ │ │ ├── cssMediaRule.kk │ │ │ ├── cssNamespaceRule.kk │ │ │ ├── cssPageRule.kk │ │ │ ├── cssPercentageComponentValue.kk │ │ │ ├── cssPrimitiveValue.kk │ │ │ ├── cssPropertyValue.kk │ │ │ ├── cssPropertyValueList.kk │ │ │ ├── cssRule.kk │ │ │ ├── cssStringComponentValue.kk │ │ │ ├── cssStyleDeclaration.kk │ │ │ ├── cssStyleDeclarationValue.kk │ │ │ ├── cssStyleRule.kk │ │ │ ├── cssStyleSheet.kk │ │ │ ├── cssUnknownRule.kk │ │ │ ├── cssUrlComponentValue.kk │ │ │ ├── cssValue.kk │ │ │ ├── cssValueList.kk │ │ │ ├── documentCss.kk │ │ │ ├── domImplementationCss.kk │ │ │ ├── elementCssInlineStyle.kk │ │ │ ├── rect.kk │ │ │ └── rgbColor.kk │ │ ├── document.kk │ │ ├── documentFragment.kk │ │ ├── documentType.kk │ │ ├── domElementMap.kk │ │ ├── domException.kk │ │ ├── domImplementation.kk │ │ ├── domSettableTokenList.kk │ │ ├── domStringList.kk │ │ ├── domStringMap.kk │ │ ├── domTokenList.kk │ │ ├── doubleArray.kk │ │ ├── element.kk │ │ ├── events │ │ │ ├── compositionEvent.kk │ │ │ ├── customEvent.kk │ │ │ ├── customEventInit.kk │ │ │ ├── event.kk │ │ │ ├── eventException.kk │ │ │ ├── eventInit.kk │ │ │ ├── eventListener.kk │ │ │ ├── eventTarget.kk │ │ │ ├── focusEvent.kk │ │ │ ├── keyboardEvent.kk │ │ │ ├── mouseEvent.kk │ │ │ ├── mutationEvent.kk │ │ │ ├── mutationNameEvent.kk │ │ │ ├── progressEvent.kk │ │ │ ├── textEvent.kk │ │ │ ├── uiEvent.kk │ │ │ └── wheelEvent.kk │ │ ├── eventsource │ │ │ └── eventSource.kk │ │ ├── file │ │ │ ├── blob.kk │ │ │ ├── file.kk │ │ │ ├── fileCallback.kk │ │ │ ├── fileError.kk │ │ │ ├── fileException.kk │ │ │ ├── fileList.kk │ │ │ ├── fileReader.kk │ │ │ └── fileReaderSync.kk │ │ ├── floatArray.kk │ │ ├── formData.kk │ │ ├── html │ │ │ ├── applicationCache.kk │ │ │ ├── audioTrack.kk │ │ │ ├── audioTrackList.kk │ │ │ ├── barProp.kk │ │ │ ├── beforeUnloadEvent.kk │ │ │ ├── blobCallback.kk │ │ │ ├── canvasGradient.kk │ │ │ ├── canvasPattern.kk │ │ │ ├── canvasPixelArray.kk │ │ │ ├── canvasRenderingContext2d.kk │ │ │ ├── dataTransfer.kk │ │ │ ├── dataTransferItem.kk │ │ │ ├── dataTransferItemList.kk │ │ │ ├── dragEvent.kk │ │ │ ├── external_.kk │ │ │ ├── function.kk │ │ │ ├── functionStringCallback.kk │ │ │ ├── hashChangeEvent.kk │ │ │ ├── history.kk │ │ │ ├── htmlAllCollection.kk │ │ │ ├── htmlAnchorElement.kk │ │ │ ├── htmlAppletElement.kk │ │ │ ├── htmlAreaElement.kk │ │ │ ├── htmlAudioElement.kk │ │ │ ├── htmlBaseElement.kk │ │ │ ├── htmlBaseFontElement.kk │ │ │ ├── htmlBodyElement.kk │ │ │ ├── htmlBrElement.kk │ │ │ ├── htmlButtonElement.kk │ │ │ ├── htmlCanvasElement.kk │ │ │ ├── htmlCollection.kk │ │ │ ├── htmlCommandElement.kk │ │ │ ├── htmlDListElement.kk │ │ │ ├── htmlDataListElement.kk │ │ │ ├── htmlDetailsElement.kk │ │ │ ├── htmlDirectoryElement.kk │ │ │ ├── htmlDivElement.kk │ │ │ ├── htmlDocument.kk │ │ │ ├── htmlElement.kk │ │ │ ├── htmlEmbedElement.kk │ │ │ ├── htmlFieldSetElement.kk │ │ │ ├── htmlFontElement.kk │ │ │ ├── htmlFormControlsCollection.kk │ │ │ ├── htmlFormElement.kk │ │ │ ├── htmlFrameElement.kk │ │ │ ├── htmlFrameSetElement.kk │ │ │ ├── htmlHeadElement.kk │ │ │ ├── htmlHeadingElement.kk │ │ │ ├── htmlHrElement.kk │ │ │ ├── htmlHtmlElement.kk │ │ │ ├── htmlIframeElement.kk │ │ │ ├── htmlImageElement.kk │ │ │ ├── htmlInputElement.kk │ │ │ ├── htmlKeygenElement.kk │ │ │ ├── htmlLabelElement.kk │ │ │ ├── htmlLegendElement.kk │ │ │ ├── htmlLiElement.kk │ │ │ ├── htmlLinkElement.kk │ │ │ ├── htmlMapElement.kk │ │ │ ├── htmlMarqueeElement.kk │ │ │ ├── htmlMediaElement.kk │ │ │ ├── htmlMenuElement.kk │ │ │ ├── htmlMetaElement.kk │ │ │ ├── htmlMeterElement.kk │ │ │ ├── htmlModElement.kk │ │ │ ├── htmlOListElement.kk │ │ │ ├── htmlObjectElement.kk │ │ │ ├── htmlOptGroupElement.kk │ │ │ ├── htmlOptionElement.kk │ │ │ ├── htmlOptionsCollection.kk │ │ │ ├── htmlOutputElement.kk │ │ │ ├── htmlParagraphElement.kk │ │ │ ├── htmlParamElement.kk │ │ │ ├── htmlPreElement.kk │ │ │ ├── htmlProgressElement.kk │ │ │ ├── htmlPropertiesCollection.kk │ │ │ ├── htmlQuoteElement.kk │ │ │ ├── htmlScriptElement.kk │ │ │ ├── htmlSelectElement.kk │ │ │ ├── htmlSourceElement.kk │ │ │ ├── htmlSpanElement.kk │ │ │ ├── htmlStyleElement.kk │ │ │ ├── htmlTableCaptionElement.kk │ │ │ ├── htmlTableCellElement.kk │ │ │ ├── htmlTableColElement.kk │ │ │ ├── htmlTableDataCellElement.kk │ │ │ ├── htmlTableElement.kk │ │ │ ├── htmlTableHeaderCellElement.kk │ │ │ ├── htmlTableRowElement.kk │ │ │ ├── htmlTableSectionElement.kk │ │ │ ├── htmlTextAreaElement.kk │ │ │ ├── htmlTimeElement.kk │ │ │ ├── htmlTitleElement.kk │ │ │ ├── htmlTrackElement.kk │ │ │ ├── htmlUListElement.kk │ │ │ ├── htmlUnknownElement.kk │ │ │ ├── htmlVideoElement.kk │ │ │ ├── imageData.kk │ │ │ ├── localMediaStream.kk │ │ │ ├── location.kk │ │ │ ├── mediaController.kk │ │ │ ├── mediaError.kk │ │ │ ├── mediaQueryList.kk │ │ │ ├── mediaQueryListListener.kk │ │ │ ├── mediaStream.kk │ │ │ ├── mediaStreamRecorder.kk │ │ │ ├── messageChannel.kk │ │ │ ├── messageEvent.kk │ │ │ ├── messagePort.kk │ │ │ ├── mutableTextTrack.kk │ │ │ ├── navigator.kk │ │ │ ├── navigatorUserMediaError.kk │ │ │ ├── navigatorUserMediaErrorCallback.kk │ │ │ ├── navigatorUserMediaSuccessCallback.kk │ │ │ ├── pageTransitionEvent.kk │ │ │ ├── peerConnection.kk │ │ │ ├── popStateEvent.kk │ │ │ ├── propertyNodeList.kk │ │ │ ├── radioNodeList.kk │ │ │ ├── screen.kk │ │ │ ├── signalingCallback.kk │ │ │ ├── streamEvent.kk │ │ │ ├── streamTrack.kk │ │ │ ├── textMetrics.kk │ │ │ ├── textTrack.kk │ │ │ ├── textTrackCue.kk │ │ │ ├── textTrackCueList.kk │ │ │ ├── timeRanges.kk │ │ │ ├── transferable.kk │ │ │ ├── undoManager.kk │ │ │ ├── undoManagerEvent.kk │ │ │ ├── validityState.kk │ │ │ ├── videoTrack.kk │ │ │ ├── videoTrackList.kk │ │ │ ├── window.kk │ │ │ └── windowModal.kk │ │ ├── longArray.kk │ │ ├── longLongArray.kk │ │ ├── node.kk │ │ ├── nodeList.kk │ │ ├── octetArray.kk │ │ ├── processingInstruction.kk │ │ ├── ranges │ │ │ ├── documentRange.kk │ │ │ ├── range.kk │ │ │ └── rangeException.kk │ │ ├── shortArray.kk │ │ ├── stylesheets │ │ │ ├── linkStyle.kk │ │ │ ├── mediaList.kk │ │ │ └── styleSheet.kk │ │ ├── text.kk │ │ ├── traversal │ │ │ ├── documentTraversal.kk │ │ │ ├── nodeFilter.kk │ │ │ ├── nodeIterator.kk │ │ │ └── treeWalker.kk │ │ ├── typedarray │ │ │ ├── arrayBuffer.kk │ │ │ ├── arrayBufferView.kk │ │ │ ├── dataView.kk │ │ │ ├── float32Array.kk │ │ │ ├── float64Array.kk │ │ │ ├── int16Array.kk │ │ │ ├── int32Array.kk │ │ │ ├── int8Array.kk │ │ │ ├── uint16Array.kk │ │ │ ├── uint32Array.kk │ │ │ └── uint8Array.kk │ │ ├── types.kk │ │ ├── unsignedByteArray.kk │ │ ├── unsignedLongArray.kk │ │ ├── unsignedLongLongArray.kk │ │ ├── unsignedShortArray.kk │ │ ├── views │ │ │ ├── clientRect.kk │ │ │ └── clientRectList.kk │ │ ├── xmlHttpRequest.kk │ │ ├── xmlHttpRequestEventTarget.kk │ │ └── xmlHttpRequestUpload.kk │ └── node │ │ ├── tiersplit-inline.js │ │ └── tiersplit.kk │ └── text │ ├── atom-inline.cs │ ├── atom-inline.js │ ├── atom.kk │ └── string.kk ├── package.yaml ├── readme.md ├── samples ├── all.kk ├── basic │ ├── caesar.kk │ ├── fibonacci.kk │ ├── garsia-wachs.kk │ ├── rbtree-fbip.kk │ ├── rbtree.cpp │ └── rbtree.kk ├── handlers │ ├── ambient.kk │ ├── basic.kk │ ├── named │ │ ├── ask-poly.kk │ │ ├── ask.kk │ │ ├── file-scoped.kk │ │ ├── file.kk │ │ ├── heap.kk │ │ └── unify.kk │ ├── nim.kk │ ├── parser.kk │ ├── scoped.kk │ ├── unix.kk │ ├── vec.kk │ └── yield.kk ├── learn │ ├── basic.kk │ ├── contexts.kk │ ├── fip.kk │ ├── handler.kk │ ├── implicits.kk │ ├── lazycons.kk │ ├── qualifiers.kk │ └── with.kk └── readme.md ├── src ├── Backend │ ├── C │ │ ├── Box.hs │ │ ├── FromCore.hs │ │ ├── Parc.hs │ │ ├── ParcReuse.hs │ │ └── ParcReuseSpec.hs │ ├── CSharp │ │ └── FromCore.hs │ └── JavaScript │ │ └── FromCore.hs ├── Common │ ├── ColorScheme.hs │ ├── Error.hs │ ├── Failure.hs │ ├── File.hs │ ├── Id.hs │ ├── IdMap.hs │ ├── IdNice.hs │ ├── IdSet.hs │ ├── Message.hs │ ├── Name.hs │ ├── NameMap.hs │ ├── NamePrim.hs │ ├── NameSet.hs │ ├── QNameMap.hs │ ├── Range.hs │ ├── ResumeKind.hs │ ├── Syntax.hs │ └── Unique.hs ├── Compile │ ├── Build.hs │ ├── BuildContext.hs │ ├── CodeGen.hs │ ├── Module.hs │ ├── Optimize.hs │ ├── Options.hs │ ├── Package.hs │ └── TypeCheck.hs ├── Core │ ├── AnalysisCCtx.hs │ ├── AnalysisMatch.hs │ ├── AnalysisResume.hs │ ├── BindingGroups.hs │ ├── Borrowed.hs │ ├── CTail.hs │ ├── Check.hs │ ├── CheckFBIP.hs │ ├── Core.hs │ ├── CoreVar.hs │ ├── Divergent.hs │ ├── FunLift.hs │ ├── Inline.hs │ ├── Inlines.hs │ ├── Monadic.hs │ ├── MonadicLift.hs │ ├── OpenResolve.hs │ ├── Parse.hs │ ├── Pretty.hs │ ├── Simplify.hs │ ├── Specialize.hs │ ├── UnReturn.hs │ ├── Uniquefy.hs │ └── Unroll.hs ├── Interpreter │ ├── Command.hs │ └── Interpret.hs ├── Kind │ ├── Assumption.hs │ ├── Constructors.hs │ ├── ImportMap.hs │ ├── Infer.hs │ ├── InferKind.hs │ ├── InferMonad.hs │ ├── Kind.hs │ ├── Newtypes.hs │ ├── Pretty.hs │ ├── Repr.hs │ ├── Synonym.hs │ └── Unify.hs ├── Lib │ ├── JSON.hs │ ├── PPrint.hs │ ├── Printer.hs │ ├── Scc.hs │ └── Trace.hs ├── Main │ ├── README.md │ ├── Run.hs │ ├── langserver │ │ ├── LanguageServer │ │ │ ├── Conversions.hs │ │ │ ├── Handler │ │ │ │ ├── CodeAction.hs │ │ │ │ ├── Commands.hs │ │ │ │ ├── Completion.hs │ │ │ │ ├── Definition.hs │ │ │ │ ├── DocumentSymbol.hs │ │ │ │ ├── Folding.hs │ │ │ │ ├── Hover.hs │ │ │ │ ├── InlayHints.hs │ │ │ │ ├── Pretty.hs │ │ │ │ ├── SignatureHelp.hs │ │ │ │ └── TextDocument.hs │ │ │ ├── Handlers.hs │ │ │ ├── Monad.hs │ │ │ └── Run.hs │ │ └── Main.hs │ └── plain │ │ └── Main.hs ├── Platform │ ├── cpp │ │ └── Platform │ │ │ ├── Config.hs │ │ │ ├── Console.hs │ │ │ ├── Filetime.hs │ │ │ ├── GetOptions.hs │ │ │ ├── ReadLine.hs │ │ │ ├── Runtime.hs │ │ │ ├── Var.hs │ │ │ ├── cconsole.c │ │ │ └── cconsole.h │ ├── haddock │ │ └── Platform │ │ │ ├── Config.hs │ │ │ ├── Console.hs │ │ │ ├── GetOptions.hs │ │ │ ├── ReadLine.hs │ │ │ ├── Runtime.hs │ │ │ └── Var.hs │ └── hugs │ │ └── Platform │ │ ├── Config.hs │ │ ├── Console.hs │ │ ├── Filetime.hs │ │ ├── GetOptions.hs │ │ ├── ReadLine.hs │ │ ├── Runtime.hs │ │ └── Var.hs ├── Static │ ├── BindingGroups.hs │ └── FixityResolve.hs ├── Syntax │ ├── Colorize.hs │ ├── GenDoc.hs │ ├── Highlight.hs │ ├── Layout.hs │ ├── Lexeme.hs │ ├── Lexer.x │ ├── Parse.hs │ ├── Pretty.hs │ ├── Promote.hs │ ├── RangeMap.hs │ └── Syntax.hs └── Type │ ├── Assumption.hs │ ├── InfGamma.hs │ ├── Infer.hs │ ├── InferMonad.hs │ ├── Kind.hs │ ├── Operations.hs │ ├── Pretty.hs │ ├── Type.hs │ ├── TypeVar.hs │ └── Unify.hs ├── stack.yaml ├── support ├── atom │ ├── grammars │ │ └── koka.json │ ├── package.json │ ├── settings │ │ └── language-koka.cson │ └── styles │ │ └── koka.less ├── emacs │ └── koka-mode.el ├── markdown │ └── markedxmp.js ├── pygments │ └── koka.py ├── sublime-text │ ├── Color Scheme - Default │ │ └── Snow.tmTheme │ ├── Jake-Haskell.sublime-build │ ├── Koka │ │ ├── Comments.tmPreferences │ │ ├── for.tmSnippet │ │ ├── foreach.tmSnippet │ │ ├── fun.tmSnippet │ │ ├── function.tmSnippet │ │ ├── if.tmSnippet │ │ ├── ife.tmSnippet │ │ ├── koka.JSON-tmLanguage │ │ ├── koka.sublime-settings │ │ ├── koka.tmLanguage │ │ ├── kokadoc.JSON-tmLanguage │ │ ├── kokadoc.sublime-settings │ │ ├── kokadoc.tmLanguage │ │ ├── main.tmSnippet │ │ ├── map.tmSnippet │ │ ├── match.tmSnippet │ │ ├── repeat.tmSnippet │ │ ├── struct.tmSnippet │ │ ├── type.tmSnippet │ │ ├── val.tmSnippet │ │ ├── var.tmSnippet │ │ └── while.tmSnippet │ └── readme.md ├── vim │ ├── README.md │ ├── ftdetect │ │ └── koka.vim │ ├── ftplugin │ │ └── koka.vim │ ├── indent │ │ └── koka.vim │ └── syntax │ │ └── koka.vim └── vscode │ ├── README.md │ └── koka.language-koka │ ├── LICENSE.md │ ├── README.md │ ├── images │ ├── codelens.png │ ├── impliciteq.png │ ├── inlayhints-off.png │ ├── inlayhints.png │ ├── koka-logo-filled-dark.svg │ ├── koka-logo-filled-light.svg │ ├── koka-logo-filled.png │ └── koka-logo-filled.svg │ ├── koka-configuration.json │ ├── package.json │ ├── src │ ├── code-lens.ts │ ├── debugger.ts │ ├── extension.ts │ ├── lang-server.ts │ └── workspace.ts │ ├── syntaxes │ └── koka.json │ ├── tsconfig.json │ └── webpack.config.js ├── test ├── Spec.hs ├── algeff │ ├── common.kk │ ├── config.json │ ├── cps-cgen1.kk │ ├── cps-cgen1a.kk │ ├── cps1.kk │ ├── cps1.kk.out │ ├── cps2.kk │ ├── cps2.kk.out │ ├── cps3.kk │ ├── cps3.kk.out │ ├── cps4.kk │ ├── cps4.kk.out │ ├── cps5.kk │ ├── cps5.kk.out │ ├── diverge.kk │ ├── eff-constant.kk │ ├── eff-constant.kk.out │ ├── eff-constant2.kk │ ├── eff-constant2.kk.out │ ├── eff-poly1.kk │ ├── eff-poly2.kk │ ├── eff-rec2.kk │ ├── eff-rec2.kk.out │ ├── effs-exists1.kk │ ├── effs-exists2.kk │ ├── effs-exists3.kk │ ├── effs1.kk │ ├── effs1.kk.out │ ├── effs1a.kk │ ├── effs1a.kk.out │ ├── effs1b.kk │ ├── effs1b.kk.out │ ├── effs2.kk │ ├── effs2.kk.out │ ├── effs3.kk │ ├── effs3.kk.out │ ├── effs3b.kk │ ├── effs3b.kk.out │ ├── effs3c.kk │ ├── effs3c.kk.out │ ├── effs4.kk │ ├── effs4.kk.out │ ├── effs5.kk │ ├── effs5.kk.out │ ├── effs5a.kk │ ├── exn1.kk │ ├── exn1.kk.out │ ├── exn2.kk │ ├── exn2.kk.out │ ├── exn3.kk │ ├── exn3.kk.out │ ├── expr.kk │ ├── expr.kk.out │ ├── finalize1.kk │ ├── implicits.kk │ ├── implicits.kk.out │ ├── issue305.kk │ ├── issue305.kk.out │ ├── linear1.kk │ ├── linear1.kk.out │ ├── linear2.kk │ ├── linear2.kk.out │ ├── linear3.kk │ ├── linear3.kk.out │ ├── mask1.kk │ ├── mask1.kk.out │ ├── match-error.kk │ ├── match-error.kk.out │ ├── mon-amb2.kk │ ├── muniq.kk │ ├── named-heap-shallow.kk │ ├── nim.kk │ ├── nim.kk.out │ ├── nim1a.kk │ ├── noyield1.kk │ ├── noyield1.kk.out │ ├── noyield2.kk │ ├── noyield2.kk.out │ ├── open1.kk │ ├── open1.kk.out │ ├── open1a.kk │ ├── open1a.kk.out │ ├── open2.kk │ ├── open2.kk.out │ ├── open3.kk │ ├── open3.kk.out │ ├── open3a.kk │ ├── open4.kk │ ├── open4a.kk │ ├── parser.kk │ ├── parser.kk.out │ ├── perf1-inline1.js │ ├── perf1.kk │ ├── perf1.kk.flags │ ├── perf1a.kk │ ├── perf1a.kk.flags │ ├── perf1b.kk │ ├── perf1c.kk │ ├── perf1d.kk │ ├── perf1e.kk │ ├── perf2.kk │ ├── perf2.kk.flags │ ├── perf2.kk.out │ ├── rcontrol1.kk │ ├── rcontrol1.kk.out │ ├── scheduler1.kk │ ├── scoped.flags │ ├── scoped.kk │ ├── scoped.kk.flags │ ├── scoped.kk.out │ ├── scoped2.kk │ ├── scoped2.kk.out │ ├── shallow1.kk │ ├── shallow1.kk.out │ ├── svars1.kk │ └── wrong │ │ ├── eff-rec1.kk │ │ ├── eff-rec1.kk.out │ │ ├── eff-rec1.out │ │ ├── eff-rec2.kk │ │ ├── eff-rec2.kk.out │ │ ├── eff-rec3.kk │ │ ├── eff-rec3.kk.out │ │ ├── eff-rec4.kk │ │ ├── eff-rec4.kk.out │ │ ├── eff-rec5.kk │ │ ├── eff-rec5.kk.out │ │ ├── eff-rec6.kk │ │ ├── eff-rec6.kk.out │ │ ├── linear1.kk │ │ ├── linear1.kk.out │ │ ├── linear2.kk │ │ ├── linear2.kk.out │ │ ├── mask1.kk │ │ ├── mask1.kk.out │ │ ├── ops1.kk │ │ ├── ops1.kk.out │ │ ├── ops2.kk │ │ ├── ops2.kk.out │ │ ├── ops4.kk │ │ ├── ops4.kk.out │ │ ├── ops5.kk │ │ ├── ops5.kk.out │ │ ├── reject-mono.kk │ │ ├── reject-poly.kk │ │ ├── reject-poly2.kk │ │ ├── reject-poly3.kk │ │ ├── scoped1.kk │ │ ├── scoped1.kk.out │ │ ├── type1.kk │ │ └── type1.kk.out ├── async │ ├── async-cancel1.kk │ ├── async-cancel2.kk │ ├── async-cancel2a.kk │ ├── async-cancel3.kk │ ├── async-cancel3a.kk │ ├── async-promise1.kk │ ├── async1.kk │ ├── async1.kk.out │ ├── async1a.kk │ ├── async2.kk │ ├── async2.kk.out │ ├── async3.kk │ ├── async3.kk.out │ ├── async3a.kk │ ├── async4.kk │ ├── async4.kk.out │ ├── async4a.kk │ ├── async4a.kk.out │ ├── async4b.kk │ ├── async4b.kk.out │ ├── async5.kk │ ├── async5.kk.out │ ├── async5a.kk │ ├── async5b.kk │ ├── async5c.kk │ ├── async5d.kk │ ├── async6.kk │ ├── async6.kk.out │ ├── async7.kk │ ├── async7.kk.out │ └── config.json ├── bayes │ ├── bayes.html │ └── bayes.kk ├── bench │ ├── .gitignore │ ├── CMakeLists.txt │ ├── Dockerfile │ ├── README.md │ ├── bench.kk │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── binarytrees.cpp │ │ ├── binarytrees2.c │ │ ├── binarytrees3.c │ │ ├── binarytrees3.cpp │ │ ├── binarytrees4.cpp │ │ ├── binarytrees5.cpp │ │ ├── binarytrees7.cpp │ │ ├── binarytrees9.cpp │ │ ├── cfold.cpp │ │ ├── deriv.cpp │ │ ├── nqueens.cpp │ │ ├── rbtree-ck.cpp │ │ ├── rbtree-del.cpp │ │ └── rbtree.cpp │ ├── haskell │ │ ├── CMakeLists.txt │ │ ├── binarytrees.hs │ │ ├── cfold.hs │ │ ├── deriv.hs │ │ ├── nqueens.hs │ │ ├── qsort.hs │ │ ├── rbtree-ck.hs │ │ ├── rbtree-del.hs │ │ ├── rbtree.hs │ │ └── rbtree2.hs │ ├── intbench.sh │ ├── java │ │ ├── CMakeLists.txt │ │ ├── binarytrees.java │ │ ├── cfold.java │ │ ├── deriv.java │ │ ├── nqueens.java │ │ ├── rbtree.java │ │ └── rbtreeck.java │ ├── koka │ │ ├── CMakeLists.txt │ │ ├── binarytrees-fbip.kk │ │ ├── binarytrees.kk │ │ ├── binarytrees32.kk │ │ ├── borrowlist.kk │ │ ├── cfold.kk │ │ ├── counter-int.kk │ │ ├── counter.kk │ │ ├── counter1.kk │ │ ├── counter10.kk │ │ ├── deriv.kk │ │ ├── hamming-int.kk │ │ ├── hamming.kk │ │ ├── kkfree.kk │ │ ├── lookup-borrow.kk │ │ ├── lookup-owned.kk │ │ ├── mstate-int.kk │ │ ├── mstate.kk │ │ ├── nqueens-int.kk │ │ ├── nqueens.kk │ │ ├── pyth-int.kk │ │ ├── pyth.kk │ │ ├── rbtree-ck.kk │ │ ├── rbtree-del.kk │ │ ├── rbtree-del32.kk │ │ ├── rbtree-fbip-ck.kk │ │ ├── rbtree-fbip.kk │ │ ├── rbtree-int.kk │ │ ├── rbtree-poly.kk │ │ ├── rbtree.kk │ │ ├── rbtreex.kk │ │ ├── sfib-int.kk │ │ ├── sfib.kk │ │ ├── tak-int.kk │ │ └── tak.kk │ ├── lean │ │ ├── deriv.lean │ │ ├── leancompile.sh │ │ ├── rbtree-ck.lean │ │ ├── rbtree.lean │ │ └── rbtree4.lean │ ├── ocaml │ │ ├── CMakeLists.txt │ │ ├── binarytrees.ml │ │ ├── binarytrees_mc.ml │ │ ├── binarytrees_nomc.ml │ │ ├── cfold.ml │ │ ├── deriv.ml │ │ ├── nqueens.ml │ │ ├── qsort.ml │ │ ├── rbtree-ck.ml │ │ ├── rbtree-del.ml │ │ └── rbtree.ml │ ├── readme-icfp22.txt.md │ ├── readme-pldi40.txt.md │ └── swift │ │ ├── CMakeLists.txt │ │ ├── binarytrees.swift │ │ ├── cfold.swift │ │ ├── deriv.swift │ │ ├── nqueens.swift │ │ ├── qsort.swift │ │ ├── rbtree-ck.swift │ │ └── rbtree.swift ├── cgen │ ├── apply1.kk │ ├── assign1.kk │ ├── assign1.kk.out │ ├── box-int8.kk │ ├── box-int8.kk.out │ ├── box1.kk │ ├── box2.kk │ ├── box3.kk │ ├── box3a.kk │ ├── box4.kk │ ├── box4.kk.out │ ├── code1.kk │ ├── code2.kk │ ├── comments1.kk │ ├── comments1.kk.out │ ├── config.json │ ├── ctail-tree.kk │ ├── ctail1.kk │ ├── ctail10.kk │ ├── ctail11.kk │ ├── ctail11.kk.out │ ├── ctail11a.kk │ ├── ctail11a.kk.out │ ├── ctail1a.kk │ ├── ctail2.kk │ ├── ctail2a.kk │ ├── ctail3.kk │ ├── ctail3a.kk │ ├── ctail3b.kk │ ├── ctail4.kk │ ├── ctail5.kk │ ├── ctail5a.kk │ ├── ctail6.kk │ ├── ctail7a.kk │ ├── ctail7a.kk.out │ ├── ctail7b.kk │ ├── ctail7b.kk.out │ ├── ctail7c.kk │ ├── ctail7c.kk.out │ ├── ctail8.kk │ ├── ctail8.kk.out │ ├── ctail9.kk │ ├── data1.kk │ ├── dep1.kk │ ├── dep1.kk.out │ ├── dep2.kk │ ├── dep2.kk.out │ ├── eff-name.kk │ ├── eff-name.kk.out │ ├── effect1.kk │ ├── exists1.kk │ ├── external1.kk │ ├── external2.kk │ ├── external3.kk │ ├── external4.kk │ ├── field1.kk │ ├── field1.kk.out │ ├── fmaybe.kk │ ├── hidden1.kk │ ├── hidden2.kk │ ├── higherkind0.kk │ ├── higherkind0.kk.out │ ├── higherkind1.kk │ ├── higherkind1.kk.out │ ├── higherkind2.kk │ ├── higherkind2.kk.out │ ├── higherkind3.kk │ ├── host.kk │ ├── host.kk.out │ ├── inline1.kk │ ├── inline2.kk │ ├── inline3.kk │ ├── inline4.kk │ ├── javascript.kk │ ├── javascript.kk.out │ ├── lift2.kk │ ├── localrec1.kk │ ├── monad1.kk │ ├── monadic1.kk │ ├── monadic2.kk │ ├── monoid1.kk │ ├── monoid2.kk │ ├── mutual1.kk │ ├── mutual1.kk.out │ ├── open0.kk │ ├── open1.kk │ ├── open1.kk.out │ ├── open1a.kk │ ├── open2.kk │ ├── open3.kk │ ├── open4.kk │ ├── open4.kk.out │ ├── pat1.kk │ ├── rec1.kk │ ├── rec1.kk.out │ ├── rec2.kk │ ├── rec2.kk.out │ ├── rec3.kk │ ├── rec3.kk.out │ ├── rec4.kk │ ├── rec4.kk.out │ ├── rec4a.kk │ ├── rec4a.kk.out │ ├── rec5.kk │ ├── rec5.kk.out │ ├── return1.kk │ ├── return1.kk.out │ ├── return2.kk │ ├── return2.kk.out │ ├── return3.kk │ ├── return3.kk.out │ ├── return4.kk │ ├── return4.kk.out │ ├── return5.kk │ ├── return5.kk.out │ ├── return6.kk │ ├── return6.kk.out │ ├── returnscrut.kk │ ├── returnscrut.kk.out │ ├── reused-names.kk │ ├── reused-names.kk.out │ ├── shortcircuit1.kk │ ├── shortcircuit1.kk.out │ ├── spec1.kk │ ├── specialize-map6.kk │ ├── specialize-showlist.kk │ ├── specialize │ │ ├── bintree.kk │ │ ├── bintree.kk.out │ │ ├── branch.kk │ │ ├── branch.kk.out │ │ ├── config.json │ │ ├── fold1.kk │ │ ├── fold1.kk.out │ │ ├── fold2.kk │ │ ├── fold2.kk.out │ │ ├── localdef.kk │ │ ├── localdef.kk.out │ │ ├── map-alias.kk │ │ ├── map-alias.kk.out │ │ ├── map.kk │ │ ├── map.kk.out │ │ ├── map2.kk │ │ ├── map2.kk.out │ │ ├── map3.kk │ │ ├── map3.kk.out │ │ ├── map4.kk │ │ ├── map4.kk.out │ │ ├── map5.kk │ │ ├── map5.kk.out │ │ ├── maptwice.kk │ │ ├── maptwice.kk.out │ │ ├── sieve.kk │ │ ├── sieve.kk.out │ │ ├── tree-list.kk │ │ ├── tree-list.kk.out │ │ ├── twostep-large.kk │ │ ├── twostep-large.kk.out │ │ ├── twostep-large2.kk │ │ ├── twostep-large2.kk.out │ │ ├── while.kk │ │ ├── while.kk.out │ │ ├── zipwithacc.kk │ │ └── zipwithacc.kk.out │ ├── tail.kk │ ├── tail.kk.out │ ├── tail2.kk │ ├── tail2.kk.out │ ├── trace1.kk │ ├── unicode1.kk │ ├── unicode1.kk.out │ ├── unicode2.kk │ ├── unicode2.kk.out │ ├── unicode3.kk │ ├── unicode3.kk.out │ ├── unique1.kk │ ├── unreturn1.kk │ ├── vector1.kk │ ├── vector1.kk.out │ └── wrong │ │ ├── assign1.kk │ │ ├── assign1.kk.out │ │ ├── ctail7.kk │ │ ├── exists1.kk │ │ ├── exists1.kk.out │ │ ├── exists1a.kk │ │ ├── exists1a.kk.out │ │ ├── rec2.kk │ │ ├── recval.kk │ │ └── recval.kk.out ├── finally │ ├── config.json │ ├── file1.kk │ ├── file1a.kk │ ├── finally1.kk │ ├── finally1.kk.out │ ├── finally1a.kk │ ├── finally1a.kk.out │ ├── finally2.kk │ ├── finally2.kk.out │ ├── finally2a.kk │ ├── finally2a.kk.out │ ├── finally2b.kk │ ├── finally2b.kk.out │ ├── finally3.kk │ ├── finally3.kk.out │ ├── finally3a.kk │ ├── finally3a.kk.out │ ├── finally3b.kk │ ├── finally3b.kk.out │ ├── finally4.kk │ ├── finally4.kk.out │ ├── generative1.kk │ ├── initially1.kk │ ├── initially1.kk.out │ ├── initially2.kk │ ├── initially2.kk.out │ ├── initially2a.kk │ ├── initially2a.kk.out │ ├── initially2b.kk │ └── initially2b.kk.out ├── fip │ ├── README.md │ ├── bench.sh │ └── src │ │ ├── ftree │ │ ├── ftree-fip.kk │ │ └── ftree-std.kk │ │ ├── msort │ │ ├── msort-fip.kk │ │ └── msort-std.kk │ │ ├── qsort │ │ ├── qsort-fip.kk │ │ └── qsort-std.kk │ │ ├── rbtree │ │ ├── rbtree-clrs-full.c │ │ ├── rbtree-clrs.c │ │ ├── rbtree-fip-clrs.kk │ │ ├── rbtree-fip-icfp.kk │ │ ├── rbtree-fip.kk │ │ ├── rbtree-std.kk │ │ └── rbtree-stl.cpp │ │ └── tmap │ │ ├── tmap-fip.c │ │ ├── tmap-fip.kk │ │ ├── tmap-std.c │ │ └── tmap-std.kk ├── jsgen │ ├── config.json │ ├── err.kk │ ├── err.kk.out │ ├── exn.kk │ ├── exn.kk.out │ ├── parse-int.kk │ ├── parse-int.kk.out │ ├── vector-assign.kk │ └── vector-assign.kk.out ├── kind │ ├── alias1.kk │ ├── alias1.kk.out │ ├── alias2.kk │ ├── alias2.kk.out │ ├── alias3.kk │ ├── alias3.kk.out │ ├── alias4.kk │ ├── alias4.kk.out │ ├── bgroup1.kk │ ├── bgroup1.kk.out │ ├── bgroup2.kk │ ├── bgroup2.kk.out │ ├── bgroup3.kk │ ├── bgroup3.kk.out │ ├── config.json │ ├── fix1.kk │ ├── fix1.kk.out │ ├── fix1a.kk │ ├── fix1a.kk.out │ ├── fix2.kk │ ├── fix2.kk.out │ ├── type1.kk │ ├── type1.kk.out │ ├── type10.kk │ ├── type10.kk.out │ ├── type2.kk │ ├── type2.kk.out │ ├── type3.kk │ ├── type3.kk.out │ ├── type4.kk │ ├── type4.kk.out │ ├── type5.kk │ ├── type5.kk.out │ ├── type6.kk │ ├── type6.kk.out │ ├── type7.kk │ ├── type7.kk.out │ ├── type8.kk │ ├── type8.kk.out │ ├── type9.kk │ ├── type9.kk.out │ └── wrong │ │ ├── alias1.kk │ │ ├── alias1.kk.out │ │ ├── negative2.kk │ │ ├── negative2.kk.out │ │ ├── rec1.kk │ │ ├── rec1.kk.out │ │ ├── rec2.kk │ │ ├── rec2.kk.out │ │ ├── type1.kk │ │ ├── type1.kk.out │ │ ├── type2.kk │ │ ├── type2.kk.out │ │ ├── type3.kk │ │ ├── type3.kk.out │ │ ├── type4.kk │ │ ├── type4.kk.out │ │ ├── type7.kk │ │ └── type7.kk.out ├── lazy │ ├── indirect-compress.kk │ ├── queue │ │ ├── bankers.kk │ │ ├── batched.kk │ │ ├── bench.kk │ │ ├── physicists-stack.kk │ │ ├── realtime-fip.kk │ │ ├── realtime-fip2.kk │ │ └── realtime.kk │ ├── sieve.kk │ └── wrong │ │ ├── lazy1.kk │ │ └── lazy2.kk ├── lib │ ├── bigint1.kk │ ├── bigint1.kk.out │ ├── bigint2.kk │ ├── bigint2.kk.out │ ├── bigint3.kk │ ├── bigint3.kk.out │ ├── calendar.hs │ ├── calendar.kk │ ├── config.json │ ├── ddouble1.kk │ ├── ddouble1.kk.out │ ├── ddouble2.kk │ ├── ddouble2.kk.out │ ├── ddouble3.kk │ ├── ddouble3.kk.out │ ├── decimal1.kk │ ├── decimal1.kk.out │ ├── dir.kk │ ├── dir.kk.out │ ├── dir │ │ ├── file-a.txt │ │ └── file-b │ ├── double1.kk │ ├── double1.kk.out │ ├── double2.kk │ ├── double2.kk.out │ ├── double3.kk │ ├── double3.kk.out │ ├── double4.kk │ ├── double4.kk.out │ ├── file1.kk │ ├── file1.kk.out │ ├── http-server1.kk │ ├── isomonth.hs │ ├── isomonth.kk │ ├── jaro.kk │ ├── jaro.kk.out │ ├── jaro2.kk │ ├── jaro2.kk.out │ ├── range1.kk │ ├── range1.kk.out │ ├── ref-modify.kk │ ├── ref-modify.kk.out │ ├── ref-vector-set.kk │ ├── ref-vector-set.kk.out │ ├── slice.kk │ ├── slice.kk.out │ ├── string.kk │ ├── string.kk.out │ ├── time-parse.kk │ ├── time-parse.kk.out │ ├── time-utc1.kk │ ├── time1.kk │ ├── time1.kk.out │ ├── time10.kk │ ├── time10.kk.out │ ├── time11.kk │ ├── time11.kk.out │ ├── time2.kk │ ├── time2.kk.out │ ├── time2main.kk │ ├── time3.kk │ ├── time3.kk.out │ ├── time4.kk │ ├── time4.kk.out │ ├── time5.kk │ ├── time5.kk.out │ ├── time6.kk │ ├── time6.kk.out │ ├── time7.kk │ ├── time7.kk.out │ ├── time8.kk │ ├── time8.kk.out │ ├── time9.kk │ ├── time9.kk.out │ ├── vector1.kk │ └── vector1.kk.out ├── mask │ ├── config.json │ ├── inject-behind1.kk │ ├── inject-behind1.kk.out │ ├── inject1.kk │ ├── inject1.kk.out │ ├── inject2.kk │ ├── inject2.kk.out │ ├── inject3.kk │ ├── inject3.kk.out │ ├── inject4.kk │ ├── inject4.kk.out │ ├── inject4.out │ ├── inject4a.kk │ ├── inject4a.kk.out │ ├── inject4a.out │ ├── inject4b.kk │ └── inject4b.out ├── medium │ ├── allsamples.kk │ ├── allsamples.kk.out │ ├── caesar.kk │ ├── caesar.kk.out │ ├── collatz.kk │ ├── collatz.kk.out │ ├── config.json │ ├── fibonacci.kk │ ├── fibonacci.kk.out │ ├── garcia-wachs-nosemi.kk │ ├── garcia-wachs.kk │ ├── garcia-wachs.kk.out │ ├── gcd.kk │ ├── gcd.kk.out │ ├── nqueens.kk.out │ └── splaytree.kk ├── misc │ ├── ambients │ │ ├── acommon.kk │ │ ├── aheap1.kk │ │ ├── aheap2.kk │ │ ├── aheap3.kk │ │ ├── aheap4.kk │ │ ├── ambient1.kk │ │ ├── ambient2.kk │ │ ├── ambient3.kk │ │ ├── anim.kk │ │ ├── aparser.kk │ │ ├── ashallow.kk │ │ ├── astate.kk │ │ ├── context3.kk │ │ └── tunnel.kk │ ├── evidence │ │ ├── ev-examples1.kk │ │ ├── ev1.kk │ │ ├── ev2.kk │ │ ├── ev3.kk │ │ ├── ev4.kk │ │ ├── ev5.kk │ │ ├── evscoped1.kk │ │ ├── evscoped2.kk │ │ ├── evscoped3.kk │ │ ├── scopedresume1.kk │ │ ├── yld.js │ │ ├── yld4.js │ │ └── yld5.js │ └── instance │ │ ├── corrl1.kk │ │ ├── corrl2.kk │ │ ├── effdup1.kk │ │ ├── file1.kk │ │ ├── heap1.kk │ │ ├── instance1.kk │ │ ├── instance2.kk │ │ ├── instance3.kk │ │ ├── instance4.kk │ │ ├── instance4a.kk │ │ ├── namedh-named.kk │ │ ├── namedh-namedscoped.kk │ │ ├── namedh-scoped.kk │ │ ├── namedh-umbrella.kk │ │ ├── rec-type1.kk │ │ ├── rec-type2.kk │ │ ├── state1.kk │ │ ├── state3.kk │ │ ├── state4.kk │ │ └── wrong │ │ ├── inject1.kk │ │ ├── inject1.out │ │ ├── resource1.kk │ │ ├── resource1a.flags │ │ ├── resource1a.kk │ │ ├── resource1a.out │ │ ├── resource2b.kk │ │ ├── resource4.kk │ │ └── resource4a.kk ├── overload │ ├── blowup1.kk │ ├── blowup2.kk │ ├── config.json │ ├── eq1.kk │ ├── eqcmp1.kk │ ├── eta1.kk │ ├── eta1.kk.out │ ├── eta2.kk │ ├── eta2.kk.out │ ├── extensible-types.kk │ ├── hello.kk │ ├── implicit1.kk │ ├── monad1.kk │ ├── monad2.kk │ ├── monad3.kk │ ├── monad3a.kk │ ├── monoid1.kk │ ├── monoid2.kk │ ├── num1.kk │ ├── num1.kk.out │ ├── over1.kk │ ├── over2.kk │ ├── set1.kk │ ├── show1.kk │ ├── show2.kk │ ├── show3.kk │ ├── show4.kk │ ├── testA.kk │ └── testB.kk ├── parc │ ├── beans.kk │ ├── config.json │ ├── hcounter.kk │ ├── hqueens.kk │ ├── inline1.kk │ ├── inline2.kk │ ├── inline3.kk │ ├── inline4.kk │ ├── inline5.kk │ ├── parc-leak1.kk │ ├── parc-leak1b.kk │ ├── parc1.kk │ ├── parc1.kk.out │ ├── parc10.kk │ ├── parc10.kk.out │ ├── parc11.kk │ ├── parc11.kk.out │ ├── parc12.kk │ ├── parc12.kk.out │ ├── parc13.kk │ ├── parc13.kk.out │ ├── parc14.kk │ ├── parc14.kk.out │ ├── parc15.kk │ ├── parc15.kk.out │ ├── parc16.kk │ ├── parc16.kk.out │ ├── parc17.kk │ ├── parc17.kk.out │ ├── parc18.kk │ ├── parc18.kk.out │ ├── parc19.kk │ ├── parc19.kk.out │ ├── parc2.kk │ ├── parc2.kk.out │ ├── parc20.kk │ ├── parc20.kk.out │ ├── parc21.kk │ ├── parc21.kk.out │ ├── parc22.kk │ ├── parc22.kk.out │ ├── parc23.kk │ ├── parc23.kk.out │ ├── parc3.kk │ ├── parc3.kk.out │ ├── parc4.kk │ ├── parc4.kk.out │ ├── parc5.kk │ ├── parc5.kk.out │ ├── parc6.kk │ ├── parc6.kk.out │ ├── parc7.kk │ ├── parc7.kk.out │ ├── parc8.kk │ ├── parc8.kk.out │ ├── parc9.kk │ ├── parc9.kk.out │ ├── reuse-spec1.kk │ ├── reuse1.kk │ ├── reuse2.kk │ ├── reuse3.kk │ └── reuse4.kk ├── perf │ ├── benchmark.kk │ ├── csv.kk │ ├── heaps │ │ ├── base.kk │ │ ├── binomial-heaps-okasaki.kk │ │ ├── haskell-sort.kk │ │ ├── leftist-heaps-okasaki.kk │ │ ├── pairing-heaps-okasaki.kk │ │ ├── pairing-heaps-tailcall.kk │ │ ├── splay-heaps-fbip.kk │ │ ├── splay-heaps-okasaki.kk │ │ ├── testsuite.kk │ │ └── weight-biased-leftist-heaps-okasaki.kk │ ├── run-benchmarks.kk │ └── sets │ │ ├── HaskellBench.hs │ │ ├── ZipSet.hs │ │ ├── b-trees-pad-full.kk │ │ ├── b-trees-pad-separate-fast-path.kk │ │ ├── b-trees-pad-separate.kk │ │ ├── b-trees.kk │ │ ├── base.kk │ │ ├── patricia-tree-big-endian-okasaki.kk │ │ ├── patricia-tree-data-intset-clz.kk │ │ ├── patricia-tree-data-intset.kk │ │ ├── patricia-tree-little-endian-okasaki.kk │ │ ├── rbtree-fbip.kk │ │ ├── rbtree-okasaki.kk │ │ ├── skip-list-imperative.kk │ │ ├── skip-list-vector.kk │ │ ├── splay-trees-fbip.kk │ │ ├── testsuite.kk │ │ ├── weight-balanced-data-set.kk │ │ ├── weight-balanced-fbip-int.kk │ │ ├── weight-balanced-fbip.kk │ │ ├── weight-balanced-hirai.kk │ │ └── zip-trees-fbip.kk ├── readme.md ├── static │ ├── config.json │ ├── div1.kk │ ├── div1.kk.out │ ├── div2-ack.kk │ ├── div2-ack.kk.out │ ├── div3.kk │ ├── div3.kk.out │ ├── modA.kk │ ├── modA.kk.out │ ├── modAWrong.kk │ ├── modAWrong.kk.out │ ├── modB.kk │ ├── modB.kk.out │ ├── module1.kk │ ├── module1.kk.out │ ├── module1a.kk │ ├── module1a.kk.out │ ├── recursive1.kk │ ├── recursive1.kk.out │ ├── shadow3a.kk │ ├── shadow3a.kk.out │ ├── shadow3b.kk │ ├── shadow3b.kk.out │ ├── wrong │ │ ├── alias1.kk │ │ ├── alias1.kk.out │ │ ├── case1.kk │ │ ├── case1.kk.out │ │ ├── case2.kk │ │ ├── case2.kk.out │ │ ├── case4.kk │ │ ├── case4.kk.out │ │ ├── case5.kk │ │ ├── case5.kk.out │ │ ├── case5a.kk │ │ ├── case5a.kk.out │ │ ├── case6.kk │ │ ├── case6.kk.out │ │ ├── config.json │ │ ├── duplicate1.kk │ │ ├── duplicate1.kk.out │ │ ├── duplicate2.kk │ │ ├── duplicate2.kk.out │ │ ├── duplicate3.kk │ │ ├── duplicate3.kk.out │ │ ├── duplicate3a.kk │ │ ├── duplicate3a.kk.out │ │ ├── duplicate3b.kk │ │ ├── duplicate3b.kk.out │ │ ├── module1.kk │ │ ├── module1.kk.out │ │ ├── module2.kk │ │ ├── module2.kk.out │ │ ├── rec1.kk │ │ ├── rec1.kk.out │ │ ├── shadow1.kk │ │ ├── shadow1.kk.out │ │ ├── shadow2.kk │ │ ├── shadow2.kk.out │ │ ├── shadow3.kk │ │ ├── shadow3.kk.out │ │ ├── shadow4.kk │ │ └── shadow4.kk.out │ ├── xcase1.kk │ └── xcase1.kk.out ├── syntax │ ├── braces1.kk │ ├── comment1.kk │ ├── comment1.kk.out │ ├── config.json │ ├── final-ctl.kk │ ├── final-ctl.kk.out │ ├── layout1.kk │ ├── layout1.kk.out │ ├── layout2.kk │ ├── layout2.kk.out │ ├── syntax1.kk │ ├── syntax1.kk.out │ ├── trailing1.kk │ ├── trailing1.kk.out │ ├── trailing2.kk │ ├── trailing2.kk.out │ ├── type1.kk │ ├── type1.kk.out │ ├── use1.kk │ ├── use1.kk.out │ ├── use2.kk │ ├── use2.kk.out │ ├── utf1.kk │ ├── utf1.kk.out │ ├── utf2.kk │ ├── utf2.kk.out │ └── wrong │ │ ├── braces1.kk │ │ ├── braces1.kk.out │ │ ├── braces2.kk │ │ ├── braces2.kk.out │ │ ├── unused1.kk │ │ ├── unused1.kk.out │ │ ├── unused2.kk │ │ ├── unused2.kk.out │ │ ├── unused3.kk │ │ ├── unused3.kk.out │ │ ├── utf1.kk │ │ └── utf1.kk.out └── type │ ├── alias.kk │ ├── alias.kk.out │ ├── args1.kk │ ├── args1.kk.out │ ├── config.json │ ├── data1.kk │ ├── data2.kk │ ├── eff-rec1.kk │ ├── eff-rec1.kk.out │ ├── eff-rec1a.kk │ ├── eff-rec1a.kk.out │ ├── eff1.kk │ ├── eff1.kk.out │ ├── eff2.kk │ ├── eff2.kk.out │ ├── eff3.kk │ ├── eff3.kk.out │ ├── eff4.kk │ ├── eff4.kk.out │ ├── eff4a.kk │ ├── eff4a.kk.out │ ├── eff4b.kk │ ├── eff4b.kk.out │ ├── eff4c.kk │ ├── eff4c.kk.out │ ├── eff5.kk │ ├── eff5.kk.out │ ├── eff5a.kk │ ├── eff5a.kk.out │ ├── eff6.kk │ ├── eff6.kk.out │ ├── eff6a.kk │ ├── eff6a.kk.out │ ├── eff6b.kk │ ├── eff6b.kk.out │ ├── eff7.kk │ ├── eff7.kk.out │ ├── eff7a.kk │ ├── eff7a.kk.out │ ├── eff8.kk │ ├── eff8.kk.out │ ├── eff8a.kk │ ├── eff8a.kk.out │ ├── eff8b.kk │ ├── eff8b.kk.out │ ├── eff9.kk │ ├── eff9.kk.out │ ├── exp1.kk │ ├── higherrank2.kk │ ├── higherrank2.kk.out │ ├── higherrank3.kk │ ├── higherrank3.kk.out │ ├── hm1.kk │ ├── hm1.kk.out │ ├── hm2.kk │ ├── hm2.kk.out │ ├── hm3.kk │ ├── hm3.kk.out │ ├── hr1.kk │ ├── hr1.kk.out │ ├── hr1a.kk │ ├── hr1a.kk.out │ ├── hr2.kk │ ├── hr2.kk.out │ ├── hr3.kk │ ├── hr3.kk.out │ ├── hr3a.kk │ ├── hr3a.kk.out │ ├── hr3b.kk │ ├── hr3b.kk.out │ ├── hr3c.kk │ ├── hr3c.kk.out │ ├── hr6.kk │ ├── hr6.kk.out │ ├── hr7.kk │ ├── hr7.kk.out │ ├── import-alias.kk │ ├── import-alias.kk.out │ ├── inf1.kk │ ├── inf1.kk.out │ ├── masklocal1.kk │ ├── masklocal1.kk.out │ ├── masklocal2.kk │ ├── masklocal2.kk.out │ ├── masklocal3.kk │ ├── masklocal3.kk.out │ ├── match1.kk │ ├── match1.kk.out │ ├── matchcon1.kk │ ├── matchcon1.kk.out │ ├── opt1.kk │ ├── opt1.kk.out │ ├── opt2.kk │ ├── opt2.kk.out │ ├── pat1.kk │ ├── talpin-jouvelot1.kk │ ├── talpin-jouvelot1.kk.out │ ├── warn1.kk │ ├── warn1.kk.out │ └── wrong │ ├── div1.kk │ ├── div1.kk.out │ ├── div2.kk │ ├── div2.kk.out │ ├── div3.kk │ ├── div3.kk.out │ ├── effect1.kk │ ├── effect2.kk │ ├── higherrank1.kk │ ├── higherrank1.kk.out │ ├── higherrank2.kk │ ├── higherrank2.kk.out │ ├── higherrank3.kk │ ├── higherrank3.kk.out │ ├── higherrank3a.kk │ ├── higherrank3a.kk.out │ ├── higherrank3v.kk │ ├── higherrank3v.kk.out │ ├── hm1.kk │ ├── hm1.kk.out │ ├── hm2.kk │ ├── hm2.kk.out │ ├── hm3.kk │ ├── hm3.kk.out │ ├── hm4.kk │ ├── hm4.kk.out │ ├── hm4a.kk │ ├── hm4a.kk.out │ ├── hr1.kk │ ├── hr1.kk.out │ ├── hr2.kk │ ├── hr2.kk.out │ ├── hr3.kk │ ├── hr3.kk.out │ ├── hr4.kk │ ├── hr4.kk.out │ ├── hr5.kk │ ├── hr5.kk.out │ ├── hr6.kk │ ├── hr6.kk.out │ ├── hr7.kk │ ├── hr7.kk.out │ ├── hr7a.kk │ ├── hr7a.kk.out │ ├── local-shadow.kk │ ├── local-shadow.kk.out │ ├── open1.kk │ ├── open1.kk.out │ ├── open2.kk │ ├── open2.kk.out │ ├── open3.kk │ ├── open3.kk.out │ ├── overlap1.kk │ ├── overlap1.kk.out │ ├── overlap2.kk │ ├── overlap2.kk.out │ ├── overlap3.kk │ ├── overlap3.kk.out │ ├── pat1.kk │ ├── scheduler1.kk │ ├── scheduler1.kk.out │ ├── scheduler2.kk │ ├── scheduler2.kk.out │ ├── scheduler3.kk │ ├── scheduler3.kk.out │ ├── scheduler4.kk │ ├── scheduler4.kk.out │ ├── scheduler5.kk │ ├── scheduler5.kk.out │ ├── st1.kk │ ├── st1.kk.out │ ├── val1.kk │ ├── val1.kk.out │ ├── val1a.kk │ ├── val1a.kk.out │ └── var1.kk ├── util ├── Dockerfile ├── Dockerfile-minimal ├── README.md ├── bundle.kk ├── docs.kk ├── grammar.kk ├── install.bat ├── install.sh ├── link-min.kk ├── link-std.kk ├── link-test.kk ├── minbuild.sh ├── packaging │ ├── build.sh │ ├── distros │ │ ├── alpine.Dockerfile │ │ ├── alpine │ │ │ └── install-ghc.sh │ │ ├── arch.Dockerfile │ │ ├── arch │ │ │ └── install-ghc.sh │ │ ├── builder.sh │ │ ├── opensuse.Dockerfile │ │ ├── rhel.Dockerfile │ │ ├── rhel │ │ │ └── install-ghc.sh │ │ └── ubuntu.Dockerfile │ ├── fpm.Dockerfile │ ├── package.sh │ ├── readme.md │ ├── scripts │ │ ├── post-install.sh │ │ ├── pre-remove.sh │ │ └── script-behavious.md │ └── util.sh ├── release.md ├── reversion.kk └── windows-install.sed └── whatsnew.md /.gitattributes: -------------------------------------------------------------------------------- 1 | *.bat eol=crlf -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "kklib/mimalloc"] 2 | path = kklib/mimalloc 3 | url = https://github.com/microsoft/mimalloc 4 | -------------------------------------------------------------------------------- /.valgrindrc: -------------------------------------------------------------------------------- 1 | --leak-check=full 2 | --show-leak-kinds=all 3 | --show-reachable=yes 4 | -------------------------------------------------------------------------------- /doc/bench-amd3600-nov-2020.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/bench-amd3600-nov-2020.png -------------------------------------------------------------------------------- /doc/logo/koka-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-banner.png -------------------------------------------------------------------------------- /doc/logo/koka-logo-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-logo-100.png -------------------------------------------------------------------------------- /doc/logo/koka-logo-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-logo-200.png -------------------------------------------------------------------------------- /doc/logo/koka-logo-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-logo-400.png -------------------------------------------------------------------------------- /doc/logo/koka-logo-filled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-logo-filled.png -------------------------------------------------------------------------------- /doc/logo/koka-logo-url.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-logo-url.png -------------------------------------------------------------------------------- /doc/logo/koka-logo-v2-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-logo-v2-100.png -------------------------------------------------------------------------------- /doc/logo/koka-logo-v2-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-logo-v2-200.png -------------------------------------------------------------------------------- /doc/logo/koka-logo-v2-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-logo-v2-400.png -------------------------------------------------------------------------------- /doc/logo/koka-logo-v2-800.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-logo-v2-800.png -------------------------------------------------------------------------------- /doc/logo/koka-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/koka-logo.png -------------------------------------------------------------------------------- /doc/logo/logo.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/logo/logo.docx -------------------------------------------------------------------------------- /doc/snippet-rbtree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/snippet-rbtree.png -------------------------------------------------------------------------------- /doc/snippet-yield.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/snippet-yield.png -------------------------------------------------------------------------------- /doc/spec/images/penrose-tiling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/penrose-tiling.png -------------------------------------------------------------------------------- /doc/spec/images/perceus-perf-bw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/perceus-perf-bw.png -------------------------------------------------------------------------------- /doc/spec/images/perceus-perf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/perceus-perf.png -------------------------------------------------------------------------------- /doc/spec/images/perceus3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/perceus3.jpg -------------------------------------------------------------------------------- /doc/spec/images/vscode-caesar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/vscode-caesar.png -------------------------------------------------------------------------------- /doc/spec/images/vscode-codelens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/vscode-codelens.png -------------------------------------------------------------------------------- /doc/spec/images/vscode-commands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/vscode-commands.png -------------------------------------------------------------------------------- /doc/spec/images/vscode-inlay-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/vscode-inlay-off.png -------------------------------------------------------------------------------- /doc/spec/images/vscode-inlay-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/vscode-inlay-on.png -------------------------------------------------------------------------------- /doc/spec/images/vscode-install-compiler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/vscode-install-compiler.png -------------------------------------------------------------------------------- /doc/spec/images/vscode-install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/vscode-install.png -------------------------------------------------------------------------------- /doc/spec/images/vscode-rbtree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/images/vscode-rbtree.png -------------------------------------------------------------------------------- /doc/spec/styles/koka-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/spec/styles/koka-logo.png -------------------------------------------------------------------------------- /doc/spec/unchecked.json: -------------------------------------------------------------------------------- 1 | { "name": "unchecked", 2 | "extend": "koka", 3 | "extraKeywords": [] 4 | } -------------------------------------------------------------------------------- /doc/system-logos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/doc/system-logos.png -------------------------------------------------------------------------------- /kklib/ide/vs2019/kklib-test.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /kklib/ide/vs2019/kklib.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ..\..\..\out\lib\interactive-dbg.exe 5 | WindowsLocalDebugger 6 | 7 | 8 | -------------------------------------------------------------------------------- /kklib/test/time.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef int64_t msecs_t; 6 | 7 | msecs_t _clock_start(void); 8 | msecs_t _clock_end(msecs_t start); 9 | -------------------------------------------------------------------------------- /lib/std/time/timescales.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/lib/std/time/timescales.png -------------------------------------------------------------------------------- /lib/v1/demo/fib.kk: -------------------------------------------------------------------------------- 1 | // Example of an imperative version of the fibonacci function; 2 | function main() 3 | { 4 | val n = 10 5 | println("fibonacci(" + n.show + ") is " + fib(n).show ); 6 | } 7 | 8 | // Calculate the n'th fibonacci number 9 | function fib(n) 10 | { 11 | var x := 0 12 | var y := 1 13 | repeat(n) { 14 | val y0 = y 15 | y := x+y 16 | x := y0 17 | } 18 | return x 19 | } -------------------------------------------------------------------------------- /lib/v1/std/sys/dom/domException.kk: -------------------------------------------------------------------------------- 1 | public module dom.domException 2 | 3 | // Exception type generated by esidl 0.2.0. 4 | 5 | -------------------------------------------------------------------------------- /lib/v1/std/sys/dom/events/eventException.kk: -------------------------------------------------------------------------------- 1 | public module dom.events.eventException 2 | 3 | // Exception type generated by esidl 0.2.0. 4 | 5 | -------------------------------------------------------------------------------- /lib/v1/std/sys/dom/file/fileException.kk: -------------------------------------------------------------------------------- 1 | public module dom.file.fileException 2 | 3 | // Exception type generated by esidl 0.2.0. 4 | 5 | -------------------------------------------------------------------------------- /lib/v1/std/sys/dom/ranges/rangeException.kk: -------------------------------------------------------------------------------- 1 | public module dom.ranges.rangeException 2 | 3 | // Exception type generated by esidl 0.2.0. 4 | 5 | -------------------------------------------------------------------------------- /src/Main/README.md: -------------------------------------------------------------------------------- 1 | There are the main front-ends for the Koka compiler: 2 | 3 | - `langserver`: the regular Koka compiler with VS code language server support. 4 | See also `support/vscode` for the VS code extension. 5 | 6 | - `plain`: Koka compiler + interpreter without language server support; this is mainly 7 | to support platforms where the Haskell language server library does not build. 8 | 9 | 10 | -------------------------------------------------------------------------------- /support/atom/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "https://github.com/koka-lang/koka", 3 | "name": "language-koka", 4 | "description": "Koka language highlighting", 5 | "version": "2.0.0" 6 | } 7 | -------------------------------------------------------------------------------- /support/atom/settings/language-koka.cson: -------------------------------------------------------------------------------- 1 | '.source.koka': 2 | 'editor': 3 | 'autoIndentOnPaste': false 4 | 'softTabs': true 5 | 'tabLength': 2 6 | 'commentStart': '// ' 7 | -------------------------------------------------------------------------------- /support/sublime-text/Jake-Haskell.sublime-build: -------------------------------------------------------------------------------- 1 | { 2 | "cmd": ["jake","compiler"], 3 | "file_regex": "^([\\w\\-\\.\\\\/]+):([0-9]+):([0-9]+):\\s*[\\r\\n]*\\s*(.*)$", 4 | "working_dir": "${project_path:${folder:${file_path}}}", 5 | "selector": "source.makefile", 6 | 7 | "windows": { 8 | "cmd": ["jake.cmd","compiler"] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /support/sublime-text/Koka/koka.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | // "color_scheme": "Packages/Color Scheme - Default/Snow.tmTheme", 3 | "tab_size": 2, 4 | "translate_tabs_to_spaces": true, 5 | "use_tab_stops": true, 6 | "detect_indentation": false, 7 | "auto_indent": true, 8 | "smart_indent": true, 9 | "indent_to_bracket": true, 10 | "tab_completion": true 11 | } -------------------------------------------------------------------------------- /support/sublime-text/Koka/kokadoc.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | // "color_scheme": "Packages/Color Scheme - Default/Snow.tmTheme", 3 | "tab_size": 2, 4 | "translate_tabs_to_spaces": true, 5 | "use_tab_stops": true, 6 | "detect_indentation": false, 7 | "auto_indent": true, 8 | "smart_indent": true, 9 | "indent_to_bracket": true, 10 | "tab_completion": true 11 | } -------------------------------------------------------------------------------- /support/vim/ftdetect/koka.vim: -------------------------------------------------------------------------------- 1 | au BufNewfile,BufEnter *.kk setf koka 2 | -------------------------------------------------------------------------------- /support/vscode/koka.language-koka/images/codelens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/support/vscode/koka.language-koka/images/codelens.png -------------------------------------------------------------------------------- /support/vscode/koka.language-koka/images/impliciteq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/support/vscode/koka.language-koka/images/impliciteq.png -------------------------------------------------------------------------------- /support/vscode/koka.language-koka/images/inlayhints-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/support/vscode/koka.language-koka/images/inlayhints-off.png -------------------------------------------------------------------------------- /support/vscode/koka.language-koka/images/inlayhints.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/support/vscode/koka.language-koka/images/inlayhints.png -------------------------------------------------------------------------------- /support/vscode/koka.language-koka/images/koka-logo-filled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/support/vscode/koka.language-koka/images/koka-logo-filled.png -------------------------------------------------------------------------------- /support/vscode/koka.language-koka/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2020", 5 | "lib": [ 6 | "es2020" 7 | ], 8 | "outDir": "out", 9 | "sourceMap": true, 10 | "strict": false, 11 | "rootDir": "src" 12 | }, 13 | "exclude": [ 14 | "node_modules", 15 | ".vscode-test" 16 | ] 17 | } -------------------------------------------------------------------------------- /test/algeff/config.json: -------------------------------------------------------------------------------- 1 | "--showtypesigs -e" 2 | -------------------------------------------------------------------------------- /test/algeff/cps-cgen1.kk: -------------------------------------------------------------------------------- 1 | 2 | fun map-acc( xs : list, f : a -> e b, acc : list = [] ) : e list { 3 | match(xs) { 4 | Nil -> acc.reverse 5 | Cons(x,xx) -> xx.map-acc(f, Cons(f(x),acc)) 6 | } 7 | } 8 | 9 | fun main() { 10 | [1,2].map-acc(show).join(",").println 11 | } -------------------------------------------------------------------------------- /test/algeff/cps-cgen1a.kk: -------------------------------------------------------------------------------- 1 | 2 | fun map-acc( xs : list, f : a -> e b, acc : list ) : e list { 3 | match(xs) { 4 | Nil -> acc.reverse 5 | Cons(x,xx) -> xx.map-acc(f, Cons(f(x),acc)) 6 | } 7 | } 8 | 9 | fun main() { 10 | [1,2].map-acc(show,[]).join(",").println 11 | } -------------------------------------------------------------------------------- /test/algeff/cps1.kk.out: -------------------------------------------------------------------------------- 1 | [1,3] 2 | 3 | algeff/cps1/main: () -> console () 4 | algeff/cps1/mapIndexedPeekX: forall (xs : list, f : (idx : int, value : a, rest : list) -> e b) -> e list -------------------------------------------------------------------------------- /test/algeff/cps2.kk: -------------------------------------------------------------------------------- 1 | // triggers strange lifting during cps of letrec 2 | // because the else branch needs cps translation (but not the rest) 3 | 4 | val test = if (True || True) then (fn(x){x}) else (fn(x) { !(ref(x)) }) 5 | 6 | fun main() { 7 | test(42).show.println 8 | } -------------------------------------------------------------------------------- /test/algeff/cps2.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | algeff/cps2/main: () -> console () 4 | algeff/cps2/test: forall (x : a) -> a -------------------------------------------------------------------------------- /test/algeff/cps3.kk: -------------------------------------------------------------------------------- 1 | // test duplicate cps translation of polymorphic results 2 | 3 | fun compose1(f,g) { 4 | fun comp(x) { 5 | f(g(x)) 6 | } 7 | comp 8 | } 9 | 10 | 11 | fun compose2(f,g) { 12 | return fn(x) { 13 | f(g(x)) 14 | } 15 | } 16 | 17 | fun main() { 18 | println(compose1(inc,inc)(42)) 19 | println(compose2(inc,inc)(42)) 20 | } 21 | -------------------------------------------------------------------------------- /test/algeff/cps3.kk.out: -------------------------------------------------------------------------------- 1 | 44 2 | 44 3 | 4 | algeff/cps3/compose1: forall (f : (a) -> e b, g : (c) -> e a) -> ((x : c) -> e b) 5 | algeff/cps3/compose2: forall (f : (a) -> e b, g : (c) -> e a) -> ((x : c) -> e b) 6 | algeff/cps3/main: () -> console () -------------------------------------------------------------------------------- /test/algeff/cps5.kk: -------------------------------------------------------------------------------- 1 | 2 | fun foo( x : int, y : int ) { 3 | val x1 = if (x >= 0) then apply(id,1) else 2 4 | val y1 = if (y >= 0) then 1 else 2 5 | x1+y1 6 | } 7 | 8 | fun main() { 9 | foo(1,2).println 10 | } -------------------------------------------------------------------------------- /test/algeff/cps5.kk.out: -------------------------------------------------------------------------------- 1 | 2 2 | 3 | algeff/cps5/foo: (x : int, y : int) -> int 4 | algeff/cps5/main: () -> console () -------------------------------------------------------------------------------- /test/algeff/eff-constant.kk: -------------------------------------------------------------------------------- 1 | // issue: https://github.com/koka-lang/koka/issues/353 2 | fun x() : () 3 | () -------------------------------------------------------------------------------- /test/algeff/eff-constant.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/eff-constant@kk(2,12): parse error: invalid syntax 2 | encountered effect variable e when an effect label was expected 3 | hint: effect variables must be after `|` (e@g ``), or by themselves (e@g@ `e`) -------------------------------------------------------------------------------- /test/algeff/eff-constant2.kk: -------------------------------------------------------------------------------- 1 | // issue: https://github.com/koka-lang/koka/issues/60 2 | effect gen { 3 | ctl yield(item: a): () 4 | } 5 | 6 | fun list(program : () -> , e> ()): e list { 7 | handle(program) { 8 | yield(x) -> Cons(x, resume(())) 9 | return _ -> Nil 10 | } 11 | } -------------------------------------------------------------------------------- /test/algeff/eff-constant2.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/eff-constant2@kk(6,40): parse error: invalid syntax 2 | encountered effect variable e when an effect label was expected 3 | hint: effect variables must be after `|` (e@g ``), or by themselves (e@g@ `e`) -------------------------------------------------------------------------------- /test/algeff/eff-poly1.kk: -------------------------------------------------------------------------------- 1 | 2 | effect cheating { 3 | fun cheat(player:int) : a 4 | } 5 | -------------------------------------------------------------------------------- /test/algeff/eff-poly2.kk: -------------------------------------------------------------------------------- 1 | 2 | effect amb { 3 | fun flip() : bool 4 | fun fail() : a 5 | } 6 | -------------------------------------------------------------------------------- /test/algeff/eff-rec2.kk: -------------------------------------------------------------------------------- 1 | // https://github.com/koka-lang/koka/issues/385 2 | pub div effect parse 3 | fun current-input() : sslice 4 | 5 | pub fun parse-safe( input0 : sslice, p) 6 | var input := input0 7 | with handler 8 | fun current-input() 9 | input 10 | p() 11 | 12 | pub fun main() 13 | with parse-safe("hello".slice) 14 | val x = current-input() 15 | x.show.println -------------------------------------------------------------------------------- /test/algeff/eff-rec2.kk.out: -------------------------------------------------------------------------------- 1 | "hello" 2 | 3 | algeff/eff-rec2/current-input: () -> sslice 4 | algeff/eff-rec2/main: () -> () 5 | algeff/eff-rec2/parse-safe: forall (input0 : sslice, p : () -> a) -> e a -------------------------------------------------------------------------------- /test/algeff/effs-exists1.kk: -------------------------------------------------------------------------------- 1 | // test operators with existential bindings 2 | 3 | effect many { 4 | fun flip() : bool 5 | fun fail() : a 6 | } 7 | 8 | val many = handler { 9 | return x -> [x] 10 | flip() -> resume(True) + resume(False) 11 | fail() -> [] 12 | } 13 | 14 | fun test() { 15 | if (flip()) then 1 else fail() 16 | } 17 | 18 | fun main() { 19 | many(test).map(show).join(",").println 20 | } -------------------------------------------------------------------------------- /test/algeff/effs-exists2.kk: -------------------------------------------------------------------------------- 1 | // test operators with existential bindings 2 | 3 | effect ex { 4 | fun identity(x : a) : a 5 | } 6 | 7 | val ex = handler { 8 | identity( x ) -> resume(x) 9 | } 10 | 11 | fun test() { 12 | identity(42) 13 | } 14 | 15 | fun main() { 16 | ex(test).println 17 | } -------------------------------------------------------------------------------- /test/algeff/effs-exists3.kk: -------------------------------------------------------------------------------- 1 | // test operators with existential bindings 2 | 3 | effect ex { 4 | fun identity(x : a, i : s) : a 5 | } 6 | 7 | val ex = handler(s) { 8 | identity( x ) -> resume(x,s) 9 | } 10 | 11 | fun test() { 12 | identity(42,'a') 13 | } 14 | 15 | fun main() { 16 | ex(test).println 17 | } -------------------------------------------------------------------------------- /test/algeff/effs1.kk: -------------------------------------------------------------------------------- 1 | module effs1 2 | 3 | effect amb { 4 | ctl flip() : bool 5 | } 6 | 7 | fun xor() : amb bool { 8 | val p = flip() 9 | val q = flip() 10 | (p||q) && not(p&&q) 11 | } 12 | 13 | val amb = handler { 14 | return(x){ [x] } 15 | ctl flip(){ resume(False) ++ resume(True) } 16 | } 17 | 18 | fun main() { 19 | amb(xor).show.println 20 | } 21 | -------------------------------------------------------------------------------- /test/algeff/effs1.kk.out: -------------------------------------------------------------------------------- 1 | [False,True,True,False] 2 | 3 | algeff/effs1/amb: forall (() -> a) -> e list 4 | algeff/effs1/flip: () -> amb bool 5 | algeff/effs1/main: () -> console () 6 | algeff/effs1/xor: () -> amb bool -------------------------------------------------------------------------------- /test/algeff/effs1b.kk.out: -------------------------------------------------------------------------------- 1 | [False,True,True,False] 2 | 3 | algeff/effs1b/amb: forall (action : () -> a) -> e list 4 | algeff/effs1b/flip: () -> amb bool 5 | algeff/effs1b/main: () -> console () 6 | algeff/effs1b/xor: () -> amb bool -------------------------------------------------------------------------------- /test/algeff/effs3.kk.out: -------------------------------------------------------------------------------- 1 | negative or zero 2 | 3 | algeff/effs3/get: forall () -> (state) a 4 | algeff/effs3/main: () -> console () 5 | algeff/effs3/set: forall (x : a) -> (state) () 6 | algeff/effs3/state: forall (init : int, action : () -> |e> a) -> e a 7 | algeff/effs3/test: () -> (state) string -------------------------------------------------------------------------------- /test/algeff/effs4.kk.out: -------------------------------------------------------------------------------- 1 | positive 2 | 3 | algeff/effs4/get: forall () -> (state) a 4 | algeff/effs4/main: () -> console () 5 | algeff/effs4/set: forall (x : a) -> (state) () 6 | algeff/effs4/state: forall (() -> (state) b) -> ((s : a) -> b) 7 | algeff/effs4/test: () -> (state) string -------------------------------------------------------------------------------- /test/algeff/effs5.kk.out: -------------------------------------------------------------------------------- 1 | 0, 2, x, 2, x, 1, x 2 | 3 | algeff/effs5/amb: forall (() -> a) -> e list 4 | algeff/effs5/append: (x : string) -> state string 5 | algeff/effs5/flip: () -> amb bool 6 | algeff/effs5/get: () -> state string 7 | algeff/effs5/main: () -> console () 8 | algeff/effs5/state: forall (init : string, action : () -> a) -> e (a, string) 9 | algeff/effs5/test: () -> string -------------------------------------------------------------------------------- /test/algeff/effs5a.kk: -------------------------------------------------------------------------------- 1 | type mybool { 2 | MyFalse 3 | } 4 | effect ctl foo() : mybool 5 | effect val outer : string 6 | 7 | fun main() { 8 | with val outer = "outer" 9 | with rcontrol foo(){ rcontext.resume(MyFalse) } 10 | match(foo()) { 11 | MyFalse -> println("false") 12 | } 13 | } -------------------------------------------------------------------------------- /test/algeff/exn3.kk: -------------------------------------------------------------------------------- 1 | effect abort 2 | ctl abort() : a 3 | 4 | fun main() : total int 5 | with ctl abort() 42 6 | abort() 7 | 0 -------------------------------------------------------------------------------- /test/algeff/exn3.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | algeff/exn3/abort: forall () -> abort a 4 | algeff/exn3/main: () -> int -------------------------------------------------------------------------------- /test/algeff/issue305.kk: -------------------------------------------------------------------------------- 1 | import std/text/parse 2 | import std/core/undiv 3 | 4 | fun test(): parse char 5 | fun test2(): parse char 6 | char('r') 7 | pretend-no-div(test2) 8 | 9 | pub fun main() 10 | val code = "hi" 11 | val mb = parse(code.slice, test) 12 | println("success") 13 | -------------------------------------------------------------------------------- /test/algeff/issue305.kk.out: -------------------------------------------------------------------------------- 1 | success 2 | 3 | algeff/issuexxx/main: () -> console () 4 | algeff/issuexxx/test: () -> std/text/parse/parse char -------------------------------------------------------------------------------- /test/algeff/linear1.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | algeff/linear1/foo: () -> (state) int 4 | algeff/linear1/get: forall () -> (state) a 5 | algeff/linear1/main: () -> () 6 | algeff/linear1/put: forall (x : a) -> (state) () 7 | algeff/linear1/state: forall (init : a, action : () -> |e> int) -> int -------------------------------------------------------------------------------- /test/algeff/linear2.kk.out: -------------------------------------------------------------------------------- 1 | 68 2 | 3 | algeff/linear2/foo: () -> (state) int 4 | algeff/linear2/get: forall () -> (state) a 5 | algeff/linear2/main: () -> () 6 | algeff/linear2/put: forall (x : a) -> (state) () 7 | algeff/linear2/state: forall (init : a, action : () -> |e> int) -> int -------------------------------------------------------------------------------- /test/algeff/linear3.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | algeff/linear3/foo: () -> (state) int 4 | algeff/linear3/get: forall () -> (state) a 5 | algeff/linear3/main: () -> () 6 | algeff/linear3/put: forall (x : a) -> (state) () 7 | algeff/linear3/state: forall (init : a, action : () -> |e> int) -> int -------------------------------------------------------------------------------- /test/algeff/mask1.kk: -------------------------------------------------------------------------------- 1 | // issue #509 2 | 3 | effect reader 4 | fun ask() : s 5 | 6 | fun test( p : () -> , reader|e> a ) : e a 7 | with fun ask() 100 8 | with fun ask() 42 9 | p() 10 | 11 | pub fun main(): console () 12 | with test 13 | println(mask>(ask) : int) -------------------------------------------------------------------------------- /test/algeff/mask1.kk.out: -------------------------------------------------------------------------------- 1 | 100 2 | 3 | algeff/mask1/ask: forall () -> (reader) a 4 | algeff/mask1/main: () -> console () 5 | algeff/mask1/test: forall (p : () -> ,reader|e> a) -> e a -------------------------------------------------------------------------------- /test/algeff/noyield1.kk: -------------------------------------------------------------------------------- 1 | effect fun foo() : int 2 | effect fun bar() : int 3 | 4 | pub fun main() 5 | test().println 6 | 7 | pub fun test() : int 8 | with fun foo() 42 9 | with fun bar() foo() + 1 10 | foobar() 11 | 12 | fun foobar() : int 13 | with fun foo() 1 14 | bar() + foo() -------------------------------------------------------------------------------- /test/algeff/noyield1.kk.out: -------------------------------------------------------------------------------- 1 | 44 2 | 3 | algeff/noyield1/bar: () -> bar int 4 | algeff/noyield1/foo: () -> foo int 5 | algeff/noyield1/foobar: () -> bar int 6 | algeff/noyield1/main: () -> console () 7 | algeff/noyield1/test: () -> int -------------------------------------------------------------------------------- /test/algeff/noyield2.kk: -------------------------------------------------------------------------------- 1 | effect fun bar() : int 2 | effect fun foo(x:(),y:(),z:()) : int 3 | 4 | fun main() 5 | with fun bar() 1 6 | with fun foo(x,y,_z) 7 | //trace("hi") 8 | bar() 9 | val x = foo((),(),()) 10 | x.println 11 | -------------------------------------------------------------------------------- /test/algeff/noyield2.kk.out: -------------------------------------------------------------------------------- 1 | 1 2 | 3 | algeff/noyield2/bar: () -> bar int 4 | algeff/noyield2/foo: (x : (), y : (), z : ()) -> foo int 5 | algeff/noyield2/main: () -> console () -------------------------------------------------------------------------------- /test/algeff/open1.kk: -------------------------------------------------------------------------------- 1 | // test lifting of cps functions 2 | fun myid() : ((x:a) -> e a) { 3 | return fn(x){ x } 4 | } 5 | 6 | val hs : forall list e int> = [myid()] 7 | 8 | fun bar() { 9 | head(hs).default(id)(10) 10 | } 11 | 12 | fun main() { 13 | bar().show.println 14 | } -------------------------------------------------------------------------------- /test/algeff/open1.kk.out: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | algeff/open1/bar: () -> int 4 | algeff/open1/hs: forall list<(int) -> e int> 5 | algeff/open1/main: () -> console () 6 | algeff/open1/myid: forall () -> ((x : a) -> e a) -------------------------------------------------------------------------------- /test/algeff/open1a.kk: -------------------------------------------------------------------------------- 1 | // test lifting of cps functions 2 | // here the 'id' must first be lifted, but then is used 3 | // as non-cps 4 | 5 | val hs : forall list e int> = [id] 6 | 7 | fun bar(x:int) : int { 8 | head(hs).default(id)(x) 9 | } 10 | 11 | 12 | fun main() { 13 | bar(42).show.println 14 | } -------------------------------------------------------------------------------- /test/algeff/open1a.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | algeff/open1a/bar: (x : int) -> int 4 | algeff/open1a/hs: forall list<(int) -> e int> 5 | algeff/open1a/main: () -> console () -------------------------------------------------------------------------------- /test/algeff/open2.kk: -------------------------------------------------------------------------------- 1 | // test lifting of cps functions 2 | fun myid() : ((x:a) -> e a) { 3 | return fn(x){ x } 4 | } 5 | 6 | type func { 7 | Func (f : int -> e int) 8 | } 9 | 10 | val myfunc = Func(myid()) 11 | 12 | fun bar() { 13 | match(myfunc) { 14 | Func(f) -> f(42) 15 | } 16 | } 17 | 18 | fun main() { 19 | bar().show.println 20 | } -------------------------------------------------------------------------------- /test/algeff/open2.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | algeff/open2/func/f: forall (func : func) -> ((int) -> e int) 4 | algeff/open2/Func: forall (f : (int) -> e int) -> func 5 | algeff/open2/bar: () -> int 6 | algeff/open2/main: () -> console () 7 | algeff/open2/myfunc: forall func 8 | algeff/open2/myid: forall () -> ((x : a) -> e a) -------------------------------------------------------------------------------- /test/algeff/open3.kk: -------------------------------------------------------------------------------- 1 | // test lifting of cps functions 2 | 3 | fun mymap( f, xs ) { 4 | match(xs) { 5 | Nil -> Nil 6 | Cons(x,xx) -> Cons(f(x),mymap(f,xx)) 7 | } 8 | } 9 | 10 | fun myid(x) { 11 | x 12 | } 13 | 14 | fun test() { 15 | mymap(id,[42]) 16 | } 17 | 18 | fun main() { 19 | test().head.default(0).show.println 20 | } -------------------------------------------------------------------------------- /test/algeff/open3.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | algeff/open3/main: () -> console () 4 | algeff/open3/myid: forall (x : a) -> a 5 | algeff/open3/mymap: forall (f : (a) -> e b, xs : list) -> e list 6 | algeff/open3/test: () -> list -------------------------------------------------------------------------------- /test/algeff/open3a.kk: -------------------------------------------------------------------------------- 1 | // test lifting of cps functions 2 | 3 | fun mymap( f, xs ) { 4 | match(xs) { 5 | Nil -> Nil 6 | Cons(x,xx) -> Cons(f(x),mymap(f,xx)) 7 | } 8 | } 9 | 10 | fun myid(x) { 11 | x 12 | } 13 | 14 | fun test() { 15 | mymap(id,[42]) 16 | } 17 | 18 | fun main() { 19 | test().head.maybe(0).show.println 20 | } -------------------------------------------------------------------------------- /test/algeff/perf1.kk.flags: -------------------------------------------------------------------------------- 1 | --no-execute -------------------------------------------------------------------------------- /test/algeff/perf1a.kk.flags: -------------------------------------------------------------------------------- 1 | --no-execute -------------------------------------------------------------------------------- /test/algeff/perf2.kk.flags: -------------------------------------------------------------------------------- 1 | --no-execute -------------------------------------------------------------------------------- /test/algeff/rcontrol1.kk: -------------------------------------------------------------------------------- 1 | module rcontrol1 2 | 3 | effect amb { 4 | ctl flip() : bool 5 | } 6 | 7 | fun xor() : amb bool { 8 | val p = flip() 9 | val q = flip() 10 | (p||q) && not(p&&q) 11 | } 12 | 13 | val amb = handler { 14 | return(x){ [x] } 15 | rcontrol flip(){ rcontext.resume(False) ++ rcontext.resume(True) } 16 | } 17 | 18 | fun main() { 19 | amb(xor).show.println 20 | } 21 | -------------------------------------------------------------------------------- /test/algeff/rcontrol1.kk.out: -------------------------------------------------------------------------------- 1 | [False,True,True,False] 2 | 3 | algeff/rcontrol1/amb: forall (() -> a) -> e list 4 | algeff/rcontrol1/flip: () -> amb bool 5 | algeff/rcontrol1/main: () -> console () 6 | algeff/rcontrol1/xor: () -> amb bool -------------------------------------------------------------------------------- /test/algeff/scoped.flags: -------------------------------------------------------------------------------- 1 | --showtypesigs -e --no-checkcore 2 | -------------------------------------------------------------------------------- /test/algeff/scoped.kk.flags: -------------------------------------------------------------------------------- 1 | --no-checkcore 2 | -------------------------------------------------------------------------------- /test/algeff/wrong/eff-rec1.kk: -------------------------------------------------------------------------------- 1 | effect cow { 2 | ctl moo() : (() -> cow ()) 3 | } 4 | 5 | val cow = handler { 6 | ctl moo() { 7 | println("moo") 8 | resume( {moo()() } ) 9 | } 10 | } 11 | 12 | fun main() { 13 | cow { 14 | moo()() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/algeff/wrong/eff-rec1.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/eff-rec1@kk(1, 1): kind error: Type cow is declared as being 2 | (co)inductive but it occurs recursively in a negative position@ 3 | hint: declare it as a divergent (or retractive) type using 'div type' (or 'div effect') to allow negative occurrences -------------------------------------------------------------------------------- /test/algeff/wrong/eff-rec1.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/eff-rec1.kk(1, 1): error: Type .ops-cow is declared as being (co)inductive but it occurs 2 | recursively in a negative position. 3 | hint: declare it as a 'type rec' (or 'effect rec)' to allow negative occurrences -------------------------------------------------------------------------------- /test/algeff/wrong/eff-rec2.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/eff-rec2@kk(39,32): type error: effects do not match 2 | context : fun main() : int { 3 | @@@ 4 | } 5 | term : { 6 | @@@ 7 | } 8 | inferred effect: 9 | expected effect: -------------------------------------------------------------------------------- /test/algeff/wrong/eff-rec3.kk: -------------------------------------------------------------------------------- 1 | 2 | effect state { 3 | fun get() : a 4 | fun set(x : a) : () 5 | } 6 | 7 | fun new-ref(init,action) { 8 | var s := init 9 | handle(action) 10 | fun get() { s } 11 | fun set(x) { s := x } 12 | } 13 | 14 | fun recurse() { 15 | with new-ref(id) 16 | fun foo(i : int) { 17 | get()(i) 18 | } 19 | set(foo) 20 | foo(42) 21 | } 22 | -------------------------------------------------------------------------------- /test/algeff/wrong/eff-rec3.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/eff-rec3@kk(17, 5): type error: types do not match (due to an infinite type) 2 | context : get()(i) 3 | term : get() 4 | inferred effect: _e1 _a>|_e> 5 | expected effect: _e1 6 | because : effect cannot be subsumed 7 | hint : give a type to the function definition? -------------------------------------------------------------------------------- /test/algeff/wrong/eff-rec4.kk: -------------------------------------------------------------------------------- 1 | 2 | effect state { 3 | fun get() : (int -> state int) 4 | fun set(x : int -> state int) : () 5 | } 6 | 7 | fun new-ref(init,action) { 8 | var s := init 9 | handle(action) 10 | fun get() { s } 11 | fun set(x) { s := x } 12 | } 13 | 14 | fun recurse() { 15 | with new-ref(id) 16 | fun foo(i : int) { 17 | get()(i) 18 | } 19 | set(foo) 20 | foo(42) 21 | } 22 | -------------------------------------------------------------------------------- /test/algeff/wrong/eff-rec4.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/eff-rec4@kk(2, 1): kind error: Type state is declared as being 2 | (co)inductive but it occurs recursively in a negative position@ 3 | hint: declare it as a divergent (or retractive) type using 'div type' (or 'div effect') to allow negative occurrences -------------------------------------------------------------------------------- /test/algeff/wrong/linear2.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/linear2@kk(19, 3): type error: handler for state needs to be linear but uses a non-linear effect: amb 2 | context: handle(action) 3 | fun get() { s } 4 | fun put(t) { if flip() then s := t; () } 5 | term : handle 6 | hint : ensure only linear effects are used in a handler -------------------------------------------------------------------------------- /test/algeff/wrong/mask1.kk: -------------------------------------------------------------------------------- 1 | // issue #509 2 | 3 | effect reader 4 | fun ask() : s 5 | 6 | fun test( p : () -> , reader|e> a ) : e a 7 | with fun ask() 100 8 | with fun ask() 42 9 | p() 10 | 11 | pub fun main(): console () 12 | with test 13 | println(mask>(ask()) : int) -------------------------------------------------------------------------------- /test/algeff/wrong/mask1.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/mask1@kk(13,29): type error: types do not match (due to an infinite type) 2 | context : mask>(ask() 3 | term : ask() 4 | inferred effect: _e int>|_e1> 5 | expected effect: _e 6 | because : inject expects a parameter-less function argument 7 | hint : give a type to the function definition? -------------------------------------------------------------------------------- /test/algeff/wrong/ops1.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/ops1@kk(45, 3): type error: operator flip is not part of the handled effect 2 | term : handle(action) { 3 | @@@ 4 | } 5 | inferred type: state -------------------------------------------------------------------------------- /test/algeff/wrong/ops4.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/ops4@kk(12, 3): type error: operator set is not handled -------------------------------------------------------------------------------- /test/algeff/wrong/ops5.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/ops5@kk(12, 3): type error: operator get is handled multiple times -------------------------------------------------------------------------------- /test/algeff/wrong/reject-mono.kk: -------------------------------------------------------------------------------- 1 | effect get-id { 2 | control get-id-op() : (a -> a) 3 | } 4 | 5 | fun test() { 6 | val f = get-id-op() 7 | if (f(1)==1) then (f(0) + 1) else 2 8 | } 9 | 10 | val h = handler { 11 | control get-id-op() { 12 | resume( fn(z){ resume( fn(w){ z }); z } ) 13 | } 14 | } 15 | 16 | fun main() { 17 | h(test) // 1 18 | } -------------------------------------------------------------------------------- /test/algeff/wrong/reject-poly.kk: -------------------------------------------------------------------------------- 1 | effect get-id { 2 | control get-id-op(): (a -> a) 3 | } 4 | 5 | fun test() { 6 | val f : forall a -> a = get-id-op() // can we generalize the get-id-op result $a -> $a ? 7 | if (f(True)) then (f(0) + 1) else 2 8 | } 9 | 10 | val h = handler { 11 | control get-id-op() { 12 | resume( fn(z){ resume( fn(w){ z }); z } ) 13 | } 14 | } 15 | 16 | fun main() { 17 | h(test) // 1 18 | } -------------------------------------------------------------------------------- /test/algeff/wrong/reject-poly2.kk: -------------------------------------------------------------------------------- 1 | effect get-id { 2 | control get-id-op() : (a -> a) 3 | } 4 | 5 | fun test() { 6 | val f : forall a -> a = get-id-op() 7 | if (f(True)) then (f(0) + 1) else 2 8 | } 9 | 10 | val h = handler { 11 | control get-id-op() { 12 | resume( fn(z){ resume( fn(w){ z }); z } ) 13 | } 14 | } 15 | 16 | fun main() { 17 | h(test) 18 | } -------------------------------------------------------------------------------- /test/algeff/wrong/scoped1.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/scoped1@kk(62, 7): type error: type is not polymorphic enough 2 | context : handler { 3 | @@@ 4 | } 5 | term : choice(xs) { 6 | @@@ 7 | } 8 | inferred type : forall clause1,b,nondet,|e1>,b> 9 | is less general than: forall clause1,b,nondet,|_e>,$a> 10 | hint : give a higher-rank type annotation to a function parameter? -------------------------------------------------------------------------------- /test/algeff/wrong/type1.kk: -------------------------------------------------------------------------------- 1 | 2 | effect amb { 3 | ctl flip() : bool 4 | } 5 | 6 | 7 | fun amb_handle() { 8 | handler { 9 | return(x) -> [x] 10 | ctl flip() -> [resume(False)] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/algeff/wrong/type1.kk.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/type1@kk(10, 9): type error: types do not match (due to an infinite type) 2 | context : flip() -> [resume(False)] 3 | term : flip 4 | inferred type: (resume : (bool) -> _e list<_a>) -> _e list> 5 | expected type: ((bool) -> _e list>) -> _e list> 6 | hint : give a type to the function definition? -------------------------------------------------------------------------------- /test/async/async1.kk: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------- 2 | // Async demo 3 | // -------------------------------------------------------- 4 | import std/async 5 | import std/async/readline 6 | 7 | fun main() { 8 | println("what is your name?") 9 | val name = readline() 10 | println("and your age?") 11 | val age = readline() 12 | println("hi " ++ name ++ ", you are " ++ age) 13 | } -------------------------------------------------------------------------------- /test/async/async1.kk.out: -------------------------------------------------------------------------------- 1 | main : () -> () -------------------------------------------------------------------------------- /test/async/async1a.kk: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------- 2 | // Async demo 3 | // -------------------------------------------------------- 4 | import std/async 5 | import std/time/duration 6 | 7 | fun main() { 8 | println("wait 1") 9 | wait(1.seconds) 10 | println("wait 2") 11 | wait(1.seconds) 12 | println("wait 3") 13 | wait(1.seconds) 14 | println("done") 15 | } -------------------------------------------------------------------------------- /test/async/async2.kk.out: -------------------------------------------------------------------------------- 1 | operator branch (amb) flip: resume scoped 2 | .Op-flip : .op-flip 3 | .Ops-flip : forall (flip : .op-flip) -> .ops-amb 4 | .tag-amb : string 5 | amb : forall (action : () -> a) -> e list 6 | flip : () -> amb bool 7 | main : () -> () 8 | test : () -> () -------------------------------------------------------------------------------- /test/async/async3.kk.out: -------------------------------------------------------------------------------- 1 | main : () -> () 2 | test : () -> () -------------------------------------------------------------------------------- /test/async/async4.kk.out: -------------------------------------------------------------------------------- 1 | main : () -> () 2 | test : () -> () -------------------------------------------------------------------------------- /test/async/async4a.kk.out: -------------------------------------------------------------------------------- 1 | main : () -> () -------------------------------------------------------------------------------- /test/async/async4b.kk.out: -------------------------------------------------------------------------------- 1 | main : () -> () 2 | test : () -> () -------------------------------------------------------------------------------- /test/async/async7.kk.out: -------------------------------------------------------------------------------- 1 | dowait : (s : std/time/duration/duration) -> string 2 | main : () -> () 3 | test : () -> () -------------------------------------------------------------------------------- /test/async/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "flags": "--showtypesigs", 3 | "exclude": ["async.*.kk"] 4 | } -------------------------------------------------------------------------------- /test/bench/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *.hi 3 | *.o 4 | *.cmi 5 | *.cmx 6 | -------------------------------------------------------------------------------- /test/bench/koka/lookup-borrow.kk: -------------------------------------------------------------------------------- 1 | val n = 1000000 2 | val xs = list(1,n) 3 | 4 | fun lookup( ^xs : list, pred : a -> bool) : maybe 5 | match xs 6 | Cons(x,xx) -> if pred(x) then Just(x) else lookup(xx,pred) 7 | Nil -> Nothing 8 | 9 | pub fun main() 10 | repeat(1000) 11 | xs.lookup( fn(x) x == 0 ) 12 | () 13 | 14 | -------------------------------------------------------------------------------- /test/bench/koka/lookup-owned.kk: -------------------------------------------------------------------------------- 1 | val n = 1000000 2 | val xs = list(1,n) 3 | 4 | fun lookup( xs : list, pred : a -> bool) : maybe 5 | match xs 6 | Cons(x,xx) -> if pred(x) then Just(x) else lookup(xx,pred) 7 | Nil -> Nothing 8 | 9 | pub fun main() 10 | repeat(1000) 11 | xs.lookup( fn(x) x == 0 ) 12 | () 13 | 14 | -------------------------------------------------------------------------------- /test/bench/koka/tak-int.kk: -------------------------------------------------------------------------------- 1 | module tak-int 2 | 3 | pub fun tak(x : int, y : int, z : int ) : div int 4 | if y < x 5 | then tak( tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y) ) 6 | else z 7 | 8 | pub fun main() 9 | // tak(18,12,6).println 10 | tak(36,24,14).println -------------------------------------------------------------------------------- /test/bench/koka/tak.kk: -------------------------------------------------------------------------------- 1 | module tak 2 | 3 | import std/num/int32 4 | 5 | pub fun tak(x : int32, y : int32, z : int32 ) : div int32 6 | if y < x 7 | then tak( tak(x - 1.int32, y, z), tak(y - 1.int32, z, x), tak(z - 1.int32, x, y) ) 8 | else z 9 | 10 | pub fun main() 11 | // tak(18,12,6).println 12 | tak(36.int32,24.int32,14.int32).show.println -------------------------------------------------------------------------------- /test/bench/lean/leancompile.sh: -------------------------------------------------------------------------------- 1 | function run { 2 | echo $1 3 | $1 4 | } 5 | 6 | run "lean --c=$1.c $1" 7 | run "leanc -O3 -DNDEBUG -o lean-${1%.lean} $1.c" 8 | -------------------------------------------------------------------------------- /test/cgen/apply1.kk: -------------------------------------------------------------------------------- 1 | // tests codegeneration for parametersless fun (needs eta expansion in c# backend) 2 | fun foo() { 3 | 42 4 | } 5 | 6 | fun bar( action : () -> e int ) : e int { 7 | action() 8 | } 9 | 10 | fun main() { 11 | bar(foo) 12 | } -------------------------------------------------------------------------------- /test/cgen/assign1.kk: -------------------------------------------------------------------------------- 1 | struct counter( count : ref ) 2 | 3 | fun count( c : counter, assigned : int) : write () { 4 | c.counter/count.set(assigned) 5 | } 6 | 7 | fun main() { 8 | val c = Counter( count = ref(0) ) 9 | c.count := 1 10 | c.count.set := 2 11 | print(!(c.count)) 12 | } 13 | -------------------------------------------------------------------------------- /test/cgen/assign1.kk.out: -------------------------------------------------------------------------------- 1 | 2 -------------------------------------------------------------------------------- /test/cgen/box-int8.kk: -------------------------------------------------------------------------------- 1 | fun main() 2 | val v = vector-init(10) fn(i) i.int8 3 | v[0].int.println -------------------------------------------------------------------------------- /test/cgen/box-int8.kk.out: -------------------------------------------------------------------------------- 1 | 0 -------------------------------------------------------------------------------- /test/cgen/box1.kk: -------------------------------------------------------------------------------- 1 | type foo { 2 | Fun( f:a -> a) 3 | } 4 | 5 | fun foo() : foo { 6 | Fun(inc) 7 | } 8 | 9 | fun test() { 10 | match(foo()) { 11 | Fun(f) -> f(1) 12 | } 13 | } 14 | 15 | fun test2() { 16 | match([1]) { 17 | Cons(x) -> inc(x) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/cgen/box2.kk: -------------------------------------------------------------------------------- 1 | type foo { 2 | Fun( f:a -> a) 3 | } 4 | 5 | fun foo() : foo { 6 | Fun(inc) 7 | } 8 | 9 | fun test() { 10 | match(foo()) { 11 | Fun(f) -> f(1) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/cgen/box4.kk.out: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/cgen/comments1.kk: -------------------------------------------------------------------------------- 1 | // issue #594 2 | /* a /* b */ fun main () 1 */ 3 | fun main() 42 -------------------------------------------------------------------------------- /test/cgen/comments1.kk.out: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /test/cgen/config.json: -------------------------------------------------------------------------------- 1 | "-e" 2 | -------------------------------------------------------------------------------- /test/cgen/ctail11.kk.out: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | [1,3,5,7,9] 12 | [2,4,6,8,10] -------------------------------------------------------------------------------- /test/cgen/ctail11a.kk.out: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | [1,3,5,7,9] 12 | [2,4,6,8,10] -------------------------------------------------------------------------------- /test/cgen/ctail2.kk: -------------------------------------------------------------------------------- 1 | 2 | fun mapx( xs : list, f : a -> e b ) : e list { 3 | match(xs) { 4 | Cons(x,xx) -> Cons(f(x),xx.mapx(f)) 5 | Nil -> Nil 6 | } 7 | } 8 | 9 | fun main() { 10 | list(1,10).mapx(fn(i){ i.println; i+1 }).sum.println 11 | } 12 | -------------------------------------------------------------------------------- /test/cgen/ctail2a.kk: -------------------------------------------------------------------------------- 1 | 2 | fun mapx( xs : list, f : a -> total b ) : total list { 3 | match(xs) { 4 | Cons(x,xx) -> Cons(f(x),xx.mapx(f)) 5 | Nil -> Nil 6 | } 7 | } 8 | 9 | fun main() { 10 | list(1,10).mapx(fn(i){ i+1 }).sum.println 11 | } 12 | -------------------------------------------------------------------------------- /test/cgen/ctail3.kk: -------------------------------------------------------------------------------- 1 | effect out { 2 | ctl out(s : string) : () 3 | } 4 | 5 | 6 | fun mapx( xs : list, f : a -> e b ) : e list { 7 | match(xs) { 8 | Cons(x,xx) -> Cons(f(x),xx.mapx(f)) 9 | Nil -> Nil 10 | } 11 | } 12 | 13 | fun main() { 14 | with ctl out(s:string) { 15 | println(s); resume(()) 16 | } 17 | list(1,10).mapx(fn(i:int){ if (i.is-odd) i.show.out; i+1 }).sum.println 18 | } 19 | -------------------------------------------------------------------------------- /test/cgen/ctail3a.kk: -------------------------------------------------------------------------------- 1 | effect out { 2 | fun out(s : string) : () 3 | } 4 | 5 | 6 | fun mapx( xs : list, f : a -> e b ) : e list { 7 | match(xs) { 8 | Cons(x,xx) -> Cons(f(x),xx.mapx(f)) 9 | Nil -> Nil 10 | } 11 | } 12 | 13 | fun main() { 14 | with fun out(s:string) { println(s) } 15 | list(1,10).mapx(fn(i:int){ if (i.is-odd) i.show.out; i+1 }).sum.println 16 | } 17 | -------------------------------------------------------------------------------- /test/cgen/ctail3b.kk: -------------------------------------------------------------------------------- 1 | effect out { 2 | fun out(s : string) : () 3 | } 4 | 5 | 6 | fun mapx( xs : list, f : a -> e b ) : e list { 7 | match(xs) { 8 | Cons(x,xx) -> Cons(f(x),xx.mapx(f)) 9 | Nil -> Nil 10 | } 11 | } 12 | 13 | fun main() { 14 | with fun out(s:string) { if s=="9" then throw(s); println(s) } 15 | list(1,10).mapx(fn(i:int){ if i.is-odd then i.show.out; i+1 }).sum.println 16 | } 17 | -------------------------------------------------------------------------------- /test/cgen/ctail7a.kk.out: -------------------------------------------------------------------------------- 1 | 2047 -------------------------------------------------------------------------------- /test/cgen/ctail7b.kk.out: -------------------------------------------------------------------------------- 1 | 2047 -------------------------------------------------------------------------------- /test/cgen/ctail7c.kk.out: -------------------------------------------------------------------------------- 1 | 11 -------------------------------------------------------------------------------- /test/cgen/ctail8.kk.out: -------------------------------------------------------------------------------- 1 | [1,3,5,7,9,11,13,15,17,19] -------------------------------------------------------------------------------- /test/cgen/dep1.kk.out: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /test/cgen/dep2.kk.out: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /test/cgen/eff-name.kk.out: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | Test name: Assertion -------------------------------------------------------------------------------- /test/cgen/external1.kk: -------------------------------------------------------------------------------- 1 | 2 | external inline foo( x : int ) : int { 3 | inline "#1" 4 | } 5 | 6 | fun main() { 7 | apply(foo,42) 8 | } 9 | -------------------------------------------------------------------------------- /test/cgen/external2.kk: -------------------------------------------------------------------------------- 1 | 2 | external inline foo( x : int ) : exn int { 3 | inline "#1" 4 | } 5 | 6 | fun main() { 7 | foo(42) 8 | print("done") 9 | } 10 | -------------------------------------------------------------------------------- /test/cgen/external3.kk: -------------------------------------------------------------------------------- 1 | 2 | external inline foo( x : int ) : exn int { 3 | inline "#1" 4 | } 5 | 6 | fun main() { 7 | [42].map(foo).head 8 | } 9 | -------------------------------------------------------------------------------- /test/cgen/external4.kk: -------------------------------------------------------------------------------- 1 | 2 | external inline foo( x : int ) : exn int { 3 | inline "#1" 4 | } 5 | 6 | fun main() { 7 | zipWith([12],[30],(+)).head 8 | } 9 | -------------------------------------------------------------------------------- /test/cgen/field1.kk: -------------------------------------------------------------------------------- 1 | struct num 2 | (+) : ( x : a, y : a ) -> a 3 | (*) : (a,a) -> a 4 | 5 | val int/num : num 6 | = Num( (+), (*) ) 7 | 8 | pub fun main() 9 | (num.(+))(1,2).println -------------------------------------------------------------------------------- /test/cgen/field1.kk.out: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /test/cgen/hidden1.kk: -------------------------------------------------------------------------------- 1 | module hidden1 2 | 3 | // Had an issue where hidden names of operators were creating invalid identifiers for parsing the kki files. 4 | pub fun (+++)(l: list, x: int): list 5 | match l 6 | Cons(n, rs) -> Cons(n + x, rs +++ x) 7 | Nil -> Nil -------------------------------------------------------------------------------- /test/cgen/hidden2.kk: -------------------------------------------------------------------------------- 1 | module hidden2 2 | 3 | import hidden1 4 | 5 | pub fun main() 6 | ([0, 1, 2, 3] +++ 1).show.println -------------------------------------------------------------------------------- /test/cgen/higherkind0.kk: -------------------------------------------------------------------------------- 1 | fun idp( x : c ) : c { x } 2 | 3 | fun main() { Cons(1,idp([1])) } 4 | -------------------------------------------------------------------------------- /test/cgen/higherkind0.kk.out: -------------------------------------------------------------------------------- 1 | [1,1] -------------------------------------------------------------------------------- /test/cgen/higherkind1.kk: -------------------------------------------------------------------------------- 1 | fun bar( f : forall ( x:c,y:a) -> list ) { 2 | f([2],1) 3 | } 4 | 5 | fun foo( x:a,y:b ) : list { 6 | [y] 7 | } 8 | 9 | fun main() { bar(foo) } 10 | -------------------------------------------------------------------------------- /test/cgen/higherkind1.kk.out: -------------------------------------------------------------------------------- 1 | [1] -------------------------------------------------------------------------------- /test/cgen/higherkind2.kk: -------------------------------------------------------------------------------- 1 | type eq { 2 | con Eq( witness : forall f -> f ) 3 | } 4 | 5 | fun idp( x : c ) : c { x } 6 | fun foo( x : eq ) { 42 } 7 | 8 | fun main() { foo(Eq(id)) } 9 | -------------------------------------------------------------------------------- /test/cgen/higherkind2.kk.out: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /test/cgen/higherkind3.kk: -------------------------------------------------------------------------------- 1 | // The current C-sharp translation does not support 'nested' polymorphic higher kinds 2 | fun foo( xs : list> ) { 1 } 3 | 4 | fun main() { 5 | foo(single(single(1))) 6 | } -------------------------------------------------------------------------------- /test/cgen/host.kk: -------------------------------------------------------------------------------- 1 | fun main() 2 | host() == "libc" -------------------------------------------------------------------------------- /test/cgen/host.kk.out: -------------------------------------------------------------------------------- 1 | True -------------------------------------------------------------------------------- /test/cgen/javascript.kk.out: -------------------------------------------------------------------------------- 1 | 3test/cgen/javascript@kk(84, 3): type warning: Some branches in the match will never be reached: _ -------------------------------------------------------------------------------- /test/cgen/localrec1.kk: -------------------------------------------------------------------------------- 1 | /* 2 | fun my-show-list( xs : list, show-elem : (a) -> e string ) : e string 3 | { 4 | "[" ++ xs.map(show-elem).join(",") ++ "]" 5 | } 6 | */ 7 | 8 | fun main(x : int) 9 | fun f(i:int) 10 | fun g(j:int) 11 | fun h(k:int) 12 | if k==0 then x+k else h(k - 1) 13 | if j==0 then h(i+x) else g(j - 1) 14 | if i==x then g(i) else f(i - 1) 15 | f(x+1) 16 | -------------------------------------------------------------------------------- /test/cgen/monad1.kk: -------------------------------------------------------------------------------- 1 | struct monad 2 | pure : forall a -> m 3 | bind : forall (m, a -> m) -> m 4 | 5 | 6 | //fun sequence( ms : list>, ?monad : monad ) : m> 7 | fun sequence( xs, ?m:monad<_> ) 8 | match xs 9 | Nil -> m.pure.([]) 10 | Cons(mx,mxx) -> 11 | with x <- m.bind.(mx) 12 | with xx <- m.bind.(sequence(mxx)) 13 | m.pure.(Cons(x,xx)) 14 | -------------------------------------------------------------------------------- /test/cgen/monadic2.kk: -------------------------------------------------------------------------------- 1 | effect reader { 2 | fun read() : int 3 | } 4 | 5 | fun foo() : reader int { 6 | fun bar( y : int ) : reader int { 7 | return y 8 | } 9 | val x = bar(19) 10 | x + 1 11 | } 12 | -------------------------------------------------------------------------------- /test/cgen/mutual1.kk: -------------------------------------------------------------------------------- 1 | // mutual recursive functions (issue #596) 2 | 3 | fun foo() 4 | bar() 5 | 6 | fun bar() 7 | foo() 8 | 9 | fun main() 10 | () -------------------------------------------------------------------------------- /test/cgen/mutual1.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/cgen/mutual1.kk.out -------------------------------------------------------------------------------- /test/cgen/open0.kk: -------------------------------------------------------------------------------- 1 | type open test { 2 | X 3 | } 4 | 5 | type extend test { 6 | Y 7 | } 8 | 9 | fun test(x) { 10 | match(x) { 11 | Y -> println("its a Y") 12 | } 13 | } 14 | 15 | fun main() { 16 | test(Y) 17 | } -------------------------------------------------------------------------------- /test/cgen/open1.kk: -------------------------------------------------------------------------------- 1 | open type test { 2 | A 3 | } 4 | 5 | extend type test { 6 | B(i : int) 7 | } 8 | 9 | extend type test { 10 | C(j : int) 11 | } 12 | 13 | fun foo(t) { 14 | match(t) { 15 | B(i) -> i 16 | _ -> 42 17 | } 18 | } 19 | 20 | fun main() { 21 | foo(C(2)).print 22 | } -------------------------------------------------------------------------------- /test/cgen/open1.kk.out: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /test/cgen/open1a.kk: -------------------------------------------------------------------------------- 1 | module open1a 2 | 3 | import open0 4 | 5 | val theY = open0/Y 6 | val theX = open0/X 7 | 8 | extend type test { 9 | X 10 | } 11 | 12 | fun test( x : test ) { 13 | match(x) { 14 | open0/X -> "original X" 15 | open1a/X -> "the new X" 16 | } 17 | } 18 | 19 | fun main() { 20 | open1a/test(theX).print 21 | open1a/test(open1a/X).print 22 | } -------------------------------------------------------------------------------- /test/cgen/open3.kk: -------------------------------------------------------------------------------- 1 | open type test { 2 | X 3 | } 4 | 5 | extend type test { 6 | Y 7 | } 8 | 9 | fun test(x) { 10 | match(x) { 11 | Y -> println("its a Y") 12 | } 13 | } 14 | 15 | fun main() { 16 | test(Y).print 17 | } -------------------------------------------------------------------------------- /test/cgen/open4.kk.out: -------------------------------------------------------------------------------- 1 | Nothing 2 | Just(C) 3 | Just(C) -------------------------------------------------------------------------------- /test/cgen/pat1.kk: -------------------------------------------------------------------------------- 1 | import std/num/int64 2 | 3 | fun test( x : int = 42, y : int64 = 0.int64) 4 | 2*x+y.int -------------------------------------------------------------------------------- /test/cgen/rec1.kk: -------------------------------------------------------------------------------- 1 | fun foo() { 2 | 42 3 | } 4 | 5 | fun bar( action : () -> e int ) : e int { 6 | action() 7 | } 8 | 9 | fun main() { 10 | bar(foo) 11 | } -------------------------------------------------------------------------------- /test/cgen/rec1.kk.out: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /test/cgen/rec2.kk: -------------------------------------------------------------------------------- 1 | // polymorphic recursion 2 | fun foo(xs:list, n:int) : _ int 3 | { 4 | if (n==0) then 1 else foo(single(xs),n - 1) 5 | } 6 | 7 | fun main() { foo(single(1),2) } -------------------------------------------------------------------------------- /test/cgen/rec2.kk.out: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/cgen/rec3.kk: -------------------------------------------------------------------------------- 1 | // polymorphic recursion on a dynamic closure 2 | fun bar(ys,m) { 3 | fun foo(xs:list, n:int) : _ int 4 | { 5 | if (n==0) then m else foo(single(xs),n - 1) 6 | } 7 | 8 | return foo(ys,m) 9 | } 10 | 11 | fun main() { print(bar([],1)) } -------------------------------------------------------------------------------- /test/cgen/rec3.kk.out: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/cgen/rec4.kk: -------------------------------------------------------------------------------- 1 | fun foo(xs,n) { 2 | fun bar(xs : list) { 3 | match(xs) { 4 | Cons(_x,xx) -> bar(xx); 5 | Nil -> n 6 | } 7 | }; 8 | bar(xs) 9 | } 10 | 11 | 12 | fun main() { print(foo([],1)) } 13 | -------------------------------------------------------------------------------- /test/cgen/rec4.kk.out: -------------------------------------------------------------------------------- 1 | 1test/cgen/rec4@kk(2,13): type warning: xs shadows an earlier local definition or parameter -------------------------------------------------------------------------------- /test/cgen/rec4a.kk: -------------------------------------------------------------------------------- 1 | fun foo(xs,n) { 2 | fun bar(xs) { 3 | match(xs) { 4 | Cons(_x,xx) -> bar(xx); 5 | Nil -> n 6 | } 7 | }; 8 | bar(xs) 9 | } 10 | 11 | 12 | fun main() { print(foo([],1)) } 13 | -------------------------------------------------------------------------------- /test/cgen/rec4a.kk.out: -------------------------------------------------------------------------------- 1 | 1test/cgen/rec4a@kk(2,13): type warning: xs shadows an earlier local definition or parameter -------------------------------------------------------------------------------- /test/cgen/rec5.kk: -------------------------------------------------------------------------------- 1 | fun foo(xs,n) { 2 | fun bar(xs) { 3 | match(xs) { 4 | // cons(x,xx) -> bar(xx); 5 | Nil -> n 6 | } 7 | }; 8 | bar(xs) 9 | } 10 | 11 | 12 | fun main() { print(foo([],1)) } -------------------------------------------------------------------------------- /test/cgen/rec5.kk.out: -------------------------------------------------------------------------------- 1 | 1test/cgen/rec5@kk(2,13): type warning: xs shadows an earlier local definition or parameter -------------------------------------------------------------------------------- /test/cgen/return1.kk: -------------------------------------------------------------------------------- 1 | 2 | fun foo() { 3 | if (True && False) return 1 4 | 42 5 | } 6 | 7 | fun main() { 8 | foo().print 9 | } 10 | -------------------------------------------------------------------------------- /test/cgen/return1.kk.out: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /test/cgen/return2.kk: -------------------------------------------------------------------------------- 1 | 2 | fun foo() { 3 | val x = if (True && False) return () 4 | x 5 | } 6 | 7 | fun main() { 8 | foo().show.print 9 | } 10 | -------------------------------------------------------------------------------- /test/cgen/return2.kk.out: -------------------------------------------------------------------------------- 1 | () -------------------------------------------------------------------------------- /test/cgen/return3.kk: -------------------------------------------------------------------------------- 1 | 2 | fun foo() { 3 | val x = if (True || False) then 42 else return 32 4 | x 5 | } 6 | 7 | fun main() { 8 | foo().print 9 | } 10 | -------------------------------------------------------------------------------- /test/cgen/return3.kk.out: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /test/cgen/return4.kk: -------------------------------------------------------------------------------- 1 | 2 | fun foo() { 3 | if (True || False) then return 42 4 | 0 5 | } 6 | 7 | fun main() { 8 | foo().print 9 | } 10 | -------------------------------------------------------------------------------- /test/cgen/return4.kk.out: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /test/cgen/return5.kk.out: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /test/cgen/return6.kk: -------------------------------------------------------------------------------- 1 | // issue #643 2 | fun test(c: char): maybe 3 | val c1 = 4 | match f(c) 5 | Just(c1) -> 6 | c1 7 | Nothing -> 8 | return Nothing // or `return test(c)` 9 | 10 | Just(c1) 11 | 12 | fun f(c: char): maybe 13 | val x = match Just(c) 14 | Just(_cx) -> return Nothing 15 | Nothing -> Just(c) 16 | x 17 | 18 | fun main() 19 | () -------------------------------------------------------------------------------- /test/cgen/return6.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/cgen/return6.kk.out -------------------------------------------------------------------------------- /test/cgen/returnscrut.kk.out: -------------------------------------------------------------------------------- 1 | Compiled -------------------------------------------------------------------------------- /test/cgen/reused-names.kk.out: -------------------------------------------------------------------------------- 1 | [[0,1,2,3],[]] -------------------------------------------------------------------------------- /test/cgen/shortcircuit1.kk.out: -------------------------------------------------------------------------------- 1 | b = True 2 | True 3 | b = True 4 | True -------------------------------------------------------------------------------- /test/cgen/spec1.kk: -------------------------------------------------------------------------------- 1 | fun test-many() 2 | var i := 0 3 | for(1,10000000) fn(j) 4 | i := i + 1 5 | println(i) 6 | 7 | 8 | fun main() 9 | test-many() 10 | -------------------------------------------------------------------------------- /test/cgen/specialize-map6.kk: -------------------------------------------------------------------------------- 1 | 2 | fun test(xs : list<_>, f, g) : total list<_> { 3 | xs.map( fn(x){ f(g(x))} ) // free variable 4 | } 5 | 6 | pub fun main() { 7 | list(1,10).test(fn(x){x*2},inc).sum.println 8 | } 9 | -------------------------------------------------------------------------------- /test/cgen/specialize-showlist.kk: -------------------------------------------------------------------------------- 1 | fun show(xs : list<(int,list)>) : string 2 | xs.show-list fn(x) 3 | "(state=" ++ x.fst.show ++ ", " ++ x.snd.show ++ ")" 4 | 5 | fun main() 6 | val xss = [(1,[1,2]),(2,[3,4,5]),(3,[])] 7 | xss.show.println 8 | -------------------------------------------------------------------------------- /test/cgen/specialize/branch.kk.out: -------------------------------------------------------------------------------- 1 | 2 2 | 1 3 | 2 4 | 5 5 | 6 | cgen/specialize/branch/@lift-xxx: (list) -> console () 7 | cgen/specialize/branch/@lift-xxx: (list) -> console () 8 | cgen/specialize/branch/@lift-xxx: forall<_e> (list) -> list 9 | cgen/specialize/branch/main: () -> console () 10 | cgen/specialize/branch/map_other: forall (xs : list, f : (a) -> b, g : (a) -> b) -> list -------------------------------------------------------------------------------- /test/cgen/specialize/config.json: -------------------------------------------------------------------------------- 1 | "-e --showhiddentypesigs --fno-trmc -O1 --core" 2 | -------------------------------------------------------------------------------- /test/cgen/specialize/fold1.kk: -------------------------------------------------------------------------------- 1 | fun foo(f) { 2 | list(1,10).foldl( 0, f ) 3 | } 4 | 5 | fun bar(f) { 6 | list(1,10).foldl1(f) 7 | } 8 | 9 | fun main() { 10 | // specializes 11 | list(1,10).foldl(0, (+)).show.println 12 | // this seems to specialize if the next call to bar is commented 13 | foo((+)).show.println 14 | // does not specialize; check if fold1 is specializable 15 | bar((+)).show.println 16 | } -------------------------------------------------------------------------------- /test/cgen/specialize/fold2.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | list(1,10).foldr( 0, (+) ).println 3 | } -------------------------------------------------------------------------------- /test/cgen/specialize/fold2.kk.out: -------------------------------------------------------------------------------- 1 | 55 2 | 3 | cgen/specialize/fold2/@lift-xxx: (list, int) -> console int 4 | cgen/specialize/fold2/@lift-xxx: (list, int) -> console int 5 | cgen/specialize/fold2/main: () -> console () -------------------------------------------------------------------------------- /test/cgen/specialize/map-alias.kk: -------------------------------------------------------------------------------- 1 | fun map2(xs : list<_>, f) { 2 | map(xs, f) 3 | } 4 | 5 | fun map3(xs : list<_>, f) { 6 | map2(xs, f) 7 | } 8 | 9 | fun main() { 10 | [1,2,3].map3(fn(x) { x + 1 }).show.println 11 | } -------------------------------------------------------------------------------- /test/cgen/specialize/map.kk: -------------------------------------------------------------------------------- 1 | fun map-int(xs : list, f : int -> int) : list { 2 | match (xs) { 3 | Nil -> Nil 4 | Cons(x, xx) -> Cons(x.f, xx.map-int(f)) 5 | } 6 | } 7 | 8 | pub fun test() { 9 | [1,2,3].map-int(fn(x){ x + 1 }) 10 | } 11 | 12 | pub fun main() { 13 | test().show.println 14 | } 15 | -------------------------------------------------------------------------------- /test/cgen/specialize/map2.kk: -------------------------------------------------------------------------------- 1 | fun map-int(xs : list, f : int -> int) : list { 2 | match (xs) { 3 | Nil -> Nil 4 | Cons(x, xx) -> Cons(x.f, xx.map-int(f)) 5 | } 6 | } 7 | 8 | pub fun test(y : int) { 9 | [1,2,3].map-int(fn(x){ x + y }) // free variable 10 | } 11 | 12 | pub fun main() { 13 | test(2).show.println 14 | } 15 | -------------------------------------------------------------------------------- /test/cgen/specialize/map3.kk: -------------------------------------------------------------------------------- 1 | fun map-poly(xs : list, f : a -> e b) : e list { 2 | match (xs) { 3 | Nil -> Nil 4 | Cons(x, xx) -> Cons(x.f, xx.map-poly(f)) 5 | } 6 | } 7 | 8 | pub fun test(xs : list, y : int) { 9 | xs.map-poly(fn(x){ x + y }) // free variable 10 | } 11 | 12 | pub fun main() { 13 | list(1,10).test(5).show.println 14 | } 15 | -------------------------------------------------------------------------------- /test/cgen/specialize/map4.kk: -------------------------------------------------------------------------------- 1 | 2 | fun map-poly(xs : list, f : a -> e b) : e list { 3 | match (xs) { 4 | Nil -> Nil 5 | Cons(x, xx) -> Cons(x.f, xx.map-poly(f)) 6 | } 7 | } 8 | 9 | pub fun test(xs : list, y : int, g : a -> int) { 10 | xs.map-poly(fn(x){ g(x) + y }) // free variable 11 | } 12 | 13 | pub fun main() { 14 | list(1,10).test(5, fn(x){ x*2 }).sum.println 15 | } 16 | -------------------------------------------------------------------------------- /test/cgen/specialize/map5.kk: -------------------------------------------------------------------------------- 1 | 2 | pub fun test(xs : list, y : int, f : a -> int) { 3 | xs.map(fn(x){ f(x) + y }) // free variable 4 | } 5 | 6 | pub fun main() { 7 | list(1,10).test(5, inc).sum.println 8 | } 9 | -------------------------------------------------------------------------------- /test/cgen/specialize/maptwice.kk: -------------------------------------------------------------------------------- 1 | inline fun maptwice(f : int -> _) : total list> { 2 | [[1,2,3]].map(fn(xs) xs.map(f)) 3 | } 4 | 5 | fun main() { 6 | maptwice(inc)[0].unjust[0].unjust.println 7 | } -------------------------------------------------------------------------------- /test/cgen/specialize/sieve.kk: -------------------------------------------------------------------------------- 1 | fun sieve(xs : list, max : int ) : div list 2 | match xs 3 | Nil -> Nil 4 | Cons(x,xx) -> if x*x > max then xx 5 | else Cons(x, xx.filter(fn(y) y%x != 0).sieve(max)) 6 | 7 | fun gen-primes(n : int) : div list 8 | list(2,n).sieve(n) 9 | 10 | fun test(n) 11 | gen-primes(n).foreach(fn(x) println(x)) 12 | 13 | fun main() 14 | test(100) -------------------------------------------------------------------------------- /test/cgen/specialize/twostep-large.kk: -------------------------------------------------------------------------------- 1 | fun large(f : int -> _ _) : total _ { 2 | list(1, 10, f).sum 3 | } 4 | 5 | fun calls-large(f) { 6 | large(f).println 7 | large(f).println 8 | } 9 | 10 | fun main() { 11 | calls-large() fn(x) { 12 | x + 2 13 | } 14 | } -------------------------------------------------------------------------------- /test/cgen/specialize/while.kk: -------------------------------------------------------------------------------- 1 | fun countdown(n_ : int) : _ () 2 | var n := n_ 3 | while { n > 0 } 4 | n.println 5 | n := n - 1 6 | 7 | 8 | fun main() { 9 | countdown(10) 10 | } -------------------------------------------------------------------------------- /test/cgen/specialize/while.kk.out: -------------------------------------------------------------------------------- 1 | 10 2 | 9 3 | 8 4 | 7 5 | 6 6 | 5 7 | 4 8 | 3 9 | 2 10 | 1 11 | 12 | cgen/specialize/while/@lift-xxx: forall (n : local-var) -> ,console> () 13 | cgen/specialize/while/countdown: (n_ : int) -> () 14 | cgen/specialize/while/main: () -> () -------------------------------------------------------------------------------- /test/cgen/tail.kk.out: -------------------------------------------------------------------------------- 1 | 0@25 -------------------------------------------------------------------------------- /test/cgen/tail2.kk: -------------------------------------------------------------------------------- 1 | import tail 2 | 3 | pub fun main() 4 | tail/main() -------------------------------------------------------------------------------- /test/cgen/tail2.kk.out: -------------------------------------------------------------------------------- 1 | 0@25 -------------------------------------------------------------------------------- /test/cgen/trace1.kk: -------------------------------------------------------------------------------- 1 | 2 | fun main() { 3 | trace("hi") 4 | println("done") 5 | } 6 | -------------------------------------------------------------------------------- /test/cgen/unicode1.kk.out: -------------------------------------------------------------------------------- 1 | count: 13, sub3: x☃x, rev3: x☃x, 2 | s: x☃x (snowman), [0x78,0x2603,0x78,0x20,0x28,0x73,0x6E,0x6F,0x77,0x6D,0x61,0x6E,0x29] 3 | count: 13, sub3: x💪x, rev3: x💪x, 4 | s: x💪x (astral ), [0x78,0x1F4AA,0x78,0x20,0x28,0x61,0x73,0x74,0x72,0x61,0x6C,0x20,0x29] 5 | count: 13, sub3: x𝐀x, rev3: x𝐀x, 6 | s: x𝐀x (math A ), [0x78,0x1D400,0x78,0x20,0x28,0x6D,0x61,0x74,0x68,0x20,0x41,0x20,0x29] -------------------------------------------------------------------------------- /test/cgen/unicode2.kk.out: -------------------------------------------------------------------------------- 1 | count: 6, sub3: aña, rev3: aña, 2 | s: mañana, [0x6D,0x61,0xF1,0x61,0x6E,0x61] 3 | count: 7, sub3: añ, rev3: ña, 4 | s: mañana, [0x6D,0x61,0x6E,0x303,0x61,0x6E,0x61] 5 | count: 6, sub3: ̣̇x, rev3: ̣̇x, 6 | s: ẋ̣xyz, [0x78,0x307,0x323,0x78,0x79,0x7A] -------------------------------------------------------------------------------- /test/cgen/vector1.kk: -------------------------------------------------------------------------------- 1 | pub fun vector/append(first : vector, second : vector) : _ vector 2 | vector-init(first.length + second.length, fn(i) index-two(first, second, i)) 3 | 4 | fun vector/index-two(first : vector, second : vector, i: int) : _ a 5 | if i < first.length then first[i] else second[i] 6 | 7 | pub fun main() 8 | val x = [1,2,3].vector 9 | val y = x.append(x) 10 | () -------------------------------------------------------------------------------- /test/cgen/vector1.kk.out: -------------------------------------------------------------------------------- 1 | uncaught exception: index out of bounds -------------------------------------------------------------------------------- /test/cgen/wrong/assign1.kk: -------------------------------------------------------------------------------- 1 | struct counter( count : ref ) 2 | 3 | 4 | fun test() { 5 | val c = Counter( count = ref(0) ) 6 | c.count := 1 7 | print(!c.count) 8 | } 9 | -------------------------------------------------------------------------------- /test/cgen/wrong/ctail7.kk: -------------------------------------------------------------------------------- 1 | // Tail recursion on a field in a value type. 2 | type tree 3 | Tip 4 | Node( lr : maybe<(tree,tree)> ) 5 | 6 | 7 | fun make( depth : int ) : div tree 8 | if depth > 0 9 | then Node( Just((make(depth.dec), make(depth.dec))) ) 10 | else Node( Just((Tip, Tip)) ) 11 | -------------------------------------------------------------------------------- /test/cgen/wrong/exists1.kk.out: -------------------------------------------------------------------------------- 1 | test/cgen/wrong/exists1@kk(18,27): type error: True does not match the argument types 2 | context : True 3 | term : True 4 | inferred type: bool 5 | expected type: $a -------------------------------------------------------------------------------- /test/cgen/wrong/exists1a.kk.out: -------------------------------------------------------------------------------- 1 | test/cgen/wrong/exists1a@kk(18,19): type error: abstract types do not match 2 | context : x@eval 3 | term : x 4 | inferred type: expr<$b> 5 | expected type: expr<$a> 6 | hint : an higher-rank type escapes its scope? -------------------------------------------------------------------------------- /test/cgen/wrong/rec2.kk: -------------------------------------------------------------------------------- 1 | // polymorphic recursion but without a type signature: should be rejected??? 2 | fun foo(xs,n) 3 | { 4 | if (n==0) then 1 else foo(single(xs),n - 1) 5 | } 6 | 7 | fun main() { foo(single(1),2) } -------------------------------------------------------------------------------- /test/cgen/wrong/recval.kk: -------------------------------------------------------------------------------- 1 | val x = x 2 | 3 | fun main() { } -------------------------------------------------------------------------------- /test/cgen/wrong/recval.kk.out: -------------------------------------------------------------------------------- 1 | test/cgen/wrong/recval@kk(1, 5): type error: value definition is recursive@ 2 | recursive group: [cgen/wrong/recval/x] -------------------------------------------------------------------------------- /test/finally/config.json: -------------------------------------------------------------------------------- 1 | "--showtypesigs -e" 2 | -------------------------------------------------------------------------------- /test/finally/finally1.kk.out: -------------------------------------------------------------------------------- 1 | action 2 | finally 3 | return 4 | 42 5 | 6 | finally/finally1/bar: () -> console int 7 | finally/finally1/foo: () -> console int 8 | finally/finally1/main: () -> console () -------------------------------------------------------------------------------- /test/finally/finally1a.kk: -------------------------------------------------------------------------------- 1 | // Test finally 2 | 3 | fun bar() { 4 | println("action") 5 | throw("ouch") 6 | 42 7 | } 8 | 9 | fun foo() 10 | { 11 | with return(x) { println("return"); x } 12 | with finally { println("finally") } 13 | bar() 14 | } 15 | 16 | fun main() { 17 | foo().println 18 | } 19 | -------------------------------------------------------------------------------- /test/finally/finally1a.kk.out: -------------------------------------------------------------------------------- 1 | action 2 | finally 3 | uncaught exception: ouch 4 | 5 | finally/finally1a/bar: () -> int 6 | finally/finally1a/foo: () -> int 7 | finally/finally1a/main: () -> () -------------------------------------------------------------------------------- /test/finally/finally2.kk.out: -------------------------------------------------------------------------------- 1 | action: 42 2 | return, local: 42 3 | finally, local: 42 4 | 42 5 | 6 | finally/finally2/bar: () -> int 7 | finally/finally2/foo: () -> console int 8 | finally/finally2/inc: () -> state int 9 | finally/finally2/main: () -> console () -------------------------------------------------------------------------------- /test/finally/finally2a.kk.out: -------------------------------------------------------------------------------- 1 | action: 42 2 | finally, local: 42 3 | raised: ouch 4 | exc finalize 5 | 6 | finally/finally2a/bar: () -> int 7 | finally/finally2a/foo: () -> int 8 | finally/finally2a/inc: () -> state int 9 | finally/finally2a/main: () -> console () 10 | finally/finally2a/raise: forall (s : string) -> exc a -------------------------------------------------------------------------------- /test/finally/finally2b.kk.out: -------------------------------------------------------------------------------- 1 | finally, local: 41 2 | result: 43 3 | exc finalize 4 | 5 | finally/finally2b/bar: () -> int 6 | finally/finally2b/foo: () -> int 7 | finally/finally2b/inc: () -> state int 8 | finally/finally2b/main: () -> console () 9 | finally/finally2b/raise: forall (s : string) -> exc a -------------------------------------------------------------------------------- /test/finally/finally3.kk.out: -------------------------------------------------------------------------------- 1 | action: 43 2 | finally, local: 43 3 | return, local: 43 4 | 42 5 | 6 | finally/finally3/bar: () -> int 7 | finally/finally3/foo: () -> console int 8 | finally/finally3/inc: () -> inc int 9 | finally/finally3/main: () -> console () -------------------------------------------------------------------------------- /test/finally/finally3a.kk.out: -------------------------------------------------------------------------------- 1 | action: 42 2 | finally, local: 43 3 | exc finalize 4 | raised: ouch 5 | 6 | finally/finally3a/bar: () -> int 7 | finally/finally3a/foo: () -> int 8 | finally/finally3a/inc: () -> inc int 9 | finally/finally3a/main: () -> console () 10 | finally/finally3a/raise: forall (msg : string) -> raise a -------------------------------------------------------------------------------- /test/finally/finally3b.kk.out: -------------------------------------------------------------------------------- 1 | action: 42 2 | raised: ouch 3 | finally, local: 43 4 | exc finalize 5 | 6 | finally/finally3b/bar: () -> int 7 | finally/finally3b/foo: () -> int 8 | finally/finally3b/inc: () -> inc int 9 | finally/finally3b/main: () -> console () 10 | finally/finally3b/raise: forall (msg : string) -> raise a -------------------------------------------------------------------------------- /test/finally/finally4.kk: -------------------------------------------------------------------------------- 1 | // see issue #360 2 | effect ctl myeffect() : () 3 | 4 | fun main() : () 5 | with finally 6 | println("top") 7 | with ctl myeffect() () 8 | with finally 9 | println("mid") 10 | with ctl myeffect() myeffect() 11 | with finally 12 | println("cleanup") 13 | myeffect() -------------------------------------------------------------------------------- /test/finally/finally4.kk.out: -------------------------------------------------------------------------------- 1 | cleanup 2 | mid 3 | top 4 | 5 | finally/finally4/main: () -> console () 6 | finally/finally4/myeffect: () -> myeffect () -------------------------------------------------------------------------------- /test/finally/initially1.kk.out: -------------------------------------------------------------------------------- 1 | initially: 0 2 | action 3 | return, local=42 4 | finally, local=42 5 | 42 6 | 7 | finally/initially1/bar: () -> console int 8 | finally/initially1/foo: () -> console int 9 | finally/initially1/main: () -> console () -------------------------------------------------------------------------------- /test/jsgen/config.json: -------------------------------------------------------------------------------- 1 | "--target=js -e" 2 | -------------------------------------------------------------------------------- /test/jsgen/err.kk: -------------------------------------------------------------------------------- 1 | import std/os/env 2 | import std/os/file 3 | import std/os/path 4 | 5 | fun main() 6 | val args = get-args() 7 | val file-path = match args 8 | Cons(file-path, Nil) -> file-path 9 | _ -> throw("Usage: program ", ExnError) 10 | val file-contents = read-text-file(file-path.path) 11 | () -------------------------------------------------------------------------------- /test/jsgen/err.kk.out: -------------------------------------------------------------------------------- 1 | uncaught exception: Usage: program -------------------------------------------------------------------------------- /test/jsgen/exn.kk: -------------------------------------------------------------------------------- 1 | // Issue: https://github.com/koka-lang/koka/issues/625 (make sure default exception handler is inserted) 2 | fun main() 3 | throw("Error") -------------------------------------------------------------------------------- /test/jsgen/exn.kk.out: -------------------------------------------------------------------------------- 1 | uncaught exception: Error -------------------------------------------------------------------------------- /test/jsgen/parse-int.kk: -------------------------------------------------------------------------------- 1 | // Issue: https://github.com/koka-lang/koka/issues/640 2 | 3 | fun main() 4 | val i = parse-int("123\n") 5 | println(i) 6 | () -------------------------------------------------------------------------------- /test/jsgen/parse-int.kk.out: -------------------------------------------------------------------------------- 1 | Nothing -------------------------------------------------------------------------------- /test/jsgen/vector-assign.kk: -------------------------------------------------------------------------------- 1 | fun main() 2 | var a := [0].vector 3 | a[0] := 1 4 | println(a[0]) -------------------------------------------------------------------------------- /test/jsgen/vector-assign.kk.out: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/kind/alias1.kk: -------------------------------------------------------------------------------- 1 | type total :: X 2 | alias id = forall a -> a 3 | alias choose = (id,id) -> id 4 | -------------------------------------------------------------------------------- /test/kind/alias1.kk.out: -------------------------------------------------------------------------------- 1 | choose : V 2 | id : V 3 | total : X 4 | 5 | pub alias choose = (id, id) -> id = 2 6 | pub alias id = forall (a) -> a = 1 -------------------------------------------------------------------------------- /test/kind/alias2.kk: -------------------------------------------------------------------------------- 1 | type int 2 | type list { con Single( field1 : a) } 3 | alias tt = list 4 | alias uu = list>> 5 | -------------------------------------------------------------------------------- /test/kind/alias2.kk.out: -------------------------------------------------------------------------------- 1 | int : V 2 | list : V -> V 3 | tt : V -> V 4 | uu : V 5 | 6 | pub alias tt :: V -> V = list = 1 7 | pub alias uu = list>> = 2 -------------------------------------------------------------------------------- /test/kind/alias3.kk: -------------------------------------------------------------------------------- 1 | // partially applied type synonym 2 | type foo 3 | 4 | alias id = a 5 | alias ap = f 6 | 7 | alias ok = ap -------------------------------------------------------------------------------- /test/kind/alias3.kk.out: -------------------------------------------------------------------------------- 1 | ap : (V -> V, V) -> V 2 | foo : V 3 | id : V -> V 4 | ok : V 5 | 6 | pub alias ap :: (V -> V, V) -> V = a = 1 7 | pub alias id :: V -> V = a = 1 8 | pub alias ok = ap = 2 -------------------------------------------------------------------------------- /test/kind/alias4.kk: -------------------------------------------------------------------------------- 1 | // test name hiding 2 | import static/modA 3 | 4 | alias aint = modA/aint 5 | alias ok1 = aint 6 | alias ok2 = modA/aint 7 | -------------------------------------------------------------------------------- /test/kind/alias4.kk.out: -------------------------------------------------------------------------------- 1 | aint : V 2 | ok1 : V 3 | ok2 : V 4 | 5 | pub alias aint = static/modA/aint = 2 6 | pub alias ok1 = aint = 3 7 | pub alias ok2 = static/modA/aint = 2 -------------------------------------------------------------------------------- /test/kind/bgroup1.kk: -------------------------------------------------------------------------------- 1 | type int 2 | type tt1 { con TT1(x: tt2) } 3 | type tt2 { con TT2(y: tt1) } 4 | -------------------------------------------------------------------------------- /test/kind/bgroup1.kk.out: -------------------------------------------------------------------------------- 1 | int : V 2 | tt1 : (V, V) -> V 3 | tt2 : (V, V) -> V -------------------------------------------------------------------------------- /test/kind/bgroup2.kk: -------------------------------------------------------------------------------- 1 | type int 2 | alias age = int 3 | type tt { con T(age : age) } 4 | alias uu1 = tt 5 | alias uu2 = tt 6 | -------------------------------------------------------------------------------- /test/kind/bgroup2.kk.out: -------------------------------------------------------------------------------- 1 | age : V 2 | int : V 3 | tt : V -> V 4 | uu1 : V -> V 5 | uu2 : (V, V) -> V 6 | 7 | pub alias age = int = 1 8 | pub alias uu1 :: V -> V = tt = 2 9 | pub alias uu2 :: (V, V) -> V = tt = 1 -------------------------------------------------------------------------------- /test/kind/bgroup3.kk: -------------------------------------------------------------------------------- 1 | type int 2 | alias aa = int 3 | alias bb = cc 4 | alias cc = aa 5 | type xx { con X( cc : cc ) } 6 | -------------------------------------------------------------------------------- /test/kind/bgroup3.kk.out: -------------------------------------------------------------------------------- 1 | aa : V 2 | bb : V 3 | cc : V 4 | int : V 5 | xx : V 6 | 7 | pub alias aa = int = 1 8 | pub alias bb = cc = 3 9 | pub alias cc = aa = 2 -------------------------------------------------------------------------------- /test/kind/config.json: -------------------------------------------------------------------------------- 1 | "-c -l --showkindsigs" -------------------------------------------------------------------------------- /test/kind/fix1.kk: -------------------------------------------------------------------------------- 1 | type fix { 2 | con Inn( fix: f> ) 3 | } 4 | -------------------------------------------------------------------------------- /test/kind/fix1.kk.out: -------------------------------------------------------------------------------- 1 | fix : (V -> V) -> V -------------------------------------------------------------------------------- /test/kind/fix1a.kk: -------------------------------------------------------------------------------- 1 | type fix V > { 2 | con Inn( out : f> ) 3 | } 4 | -------------------------------------------------------------------------------- /test/kind/fix1a.kk.out: -------------------------------------------------------------------------------- 1 | fix : (V -> V) -> V -------------------------------------------------------------------------------- /test/kind/fix2.kk: -------------------------------------------------------------------------------- 1 | div type recurse { 2 | con In( out : recurse -> a ) 3 | } 4 | -------------------------------------------------------------------------------- /test/kind/fix2.kk.out: -------------------------------------------------------------------------------- 1 | recurse : V -> V -------------------------------------------------------------------------------- /test/kind/type1.kk: -------------------------------------------------------------------------------- 1 | type void { } 2 | type unit { 3 | con Unit 4 | } -------------------------------------------------------------------------------- /test/kind/type1.kk.out: -------------------------------------------------------------------------------- 1 | unit : V 2 | void : V -------------------------------------------------------------------------------- /test/kind/type10.kk: -------------------------------------------------------------------------------- 1 | // Test if type synonym variables are correctly generalized in constructors. 2 | alias id = a 3 | alias ap = f 4 | type list { con Single(:a) } 5 | type yy { con Yy( :ap ) } 6 | type zz { con Zz( :ap> ) } 7 | -------------------------------------------------------------------------------- /test/kind/type10.kk.out: -------------------------------------------------------------------------------- 1 | ap : (V -> V, V) -> V 2 | id : V -> V 3 | list : V -> V 4 | yy : V -> V 5 | zz : V -> V 6 | 7 | pub alias ap :: (V -> V, V) -> V = a = 1 8 | // Test if type synonym variables are correctly generalized in constructors@ 9 | pub alias id :: V -> V = a = 1 -------------------------------------------------------------------------------- /test/kind/type2.kk: -------------------------------------------------------------------------------- 1 | type bool { 2 | False 3 | True 4 | } 5 | -------------------------------------------------------------------------------- /test/kind/type2.kk.out: -------------------------------------------------------------------------------- 1 | bool : V -------------------------------------------------------------------------------- /test/kind/type3.kk: -------------------------------------------------------------------------------- 1 | type maybe { 2 | con Nothing 3 | con Just( :a ) 4 | } 5 | -------------------------------------------------------------------------------- /test/kind/type3.kk.out: -------------------------------------------------------------------------------- 1 | maybe : V -> V -------------------------------------------------------------------------------- /test/kind/type4.kk: -------------------------------------------------------------------------------- 1 | type list { 2 | con Nil 3 | con Cons( head : a, tail : list ) 4 | } 5 | -------------------------------------------------------------------------------- /test/kind/type4.kk.out: -------------------------------------------------------------------------------- 1 | list : V -> V -------------------------------------------------------------------------------- /test/kind/type5.kk: -------------------------------------------------------------------------------- 1 | type int 2 | type app { con App( app: f) } 3 | type id { con Id(x:a) } 4 | alias ok = app 5 | -------------------------------------------------------------------------------- /test/kind/type5.kk.out: -------------------------------------------------------------------------------- 1 | app : (V -> V, V) -> V 2 | id : V -> V 3 | int : V 4 | ok : V 5 | 6 | pub alias ok = app = 1 -------------------------------------------------------------------------------- /test/kind/type6.kk: -------------------------------------------------------------------------------- 1 | type int 2 | alias id V > = a 3 | type list { con Single(x:a) } 4 | alias ok = id 5 | -------------------------------------------------------------------------------- /test/kind/type6.kk.out: -------------------------------------------------------------------------------- 1 | id : (V -> V) -> V 2 | int : V 3 | list : V -> V 4 | ok : V 5 | 6 | pub alias id :: (V -> V) -> V = a = 1 7 | pub alias ok = id = 2 -------------------------------------------------------------------------------- /test/kind/type7.kk: -------------------------------------------------------------------------------- 1 | type int 2 | alias equal = forall f -> f 3 | alias tt = equal 4 | alias uu = equal 5 | alias vv = equal 6 | -------------------------------------------------------------------------------- /test/kind/type7.kk.out: -------------------------------------------------------------------------------- 1 | equal : (V, V) -> V 2 | int : V 3 | tt : V 4 | uu : V -> V 5 | vv : V -> V 6 | 7 | pub alias equal :: (V, V) -> V = forall (c) -> c = 1 8 | pub alias tt = equal = 2 9 | pub alias uu :: V -> V = equal = 2 10 | pub alias vv :: V -> V = equal = 2 -------------------------------------------------------------------------------- /test/kind/type8.kk: -------------------------------------------------------------------------------- 1 | // over application 2 | type int 3 | type tuple { con Tup( fld: int) } 4 | alias tt = tuple 5 | alias uu = tuple 6 | -------------------------------------------------------------------------------- /test/kind/type8.kk.out: -------------------------------------------------------------------------------- 1 | int : V 2 | tt : (V, V) -> V 3 | tuple : (V, V) -> V 4 | uu : V 5 | 6 | pub alias tt :: (V, V) -> V = tuple = 1 7 | pub alias uu = tuple = 1 -------------------------------------------------------------------------------- /test/kind/type9.kk: -------------------------------------------------------------------------------- 1 | // test name clash on type synonyms 2 | alias id = forall a -> a 3 | alias tt = forall a -> id 4 | alias choose = id -> id 5 | -------------------------------------------------------------------------------- /test/kind/type9.kk.out: -------------------------------------------------------------------------------- 1 | choose : V 2 | id : V 3 | tt : V 4 | 5 | pub alias choose = (id) -> id = 2 6 | // test name clash on type synonyms 7 | pub alias id = forall (a) -> a = 1 8 | pub alias tt = forall (a) -> id = 2 -------------------------------------------------------------------------------- /test/kind/wrong/alias1.kk: -------------------------------------------------------------------------------- 1 | // partially applied type synonym 2 | type foo 3 | type ap { Ap( :f) } 4 | alias id = a 5 | 6 | alias wrong = ap 7 | -------------------------------------------------------------------------------- /test/kind/wrong/alias1.kk.out: -------------------------------------------------------------------------------- 1 | test/kind/wrong/alias1@kk(6,18): kind error: Type alias kind/wrong/alias1/id has too few arguments -------------------------------------------------------------------------------- /test/kind/wrong/negative2.kk: -------------------------------------------------------------------------------- 1 | // inductive types cannot have a negative recursive occurrence 2 | type foo { 3 | con In( out : bar -> a ) 4 | } 5 | 6 | type bar { 7 | con Mkfoo( :foo ) 8 | con Mknil 9 | } 10 | -------------------------------------------------------------------------------- /test/kind/wrong/negative2.kk.out: -------------------------------------------------------------------------------- 1 | test/kind/wrong/negative2@kk(2, 1): kind error: Type foo is declared as being 2 | (co)inductive but it occurs recursively in a negative position@ 3 | hint: declare it as a divergent (or retractive) type using 'div type' (or 'div effect') to allow negative occurrences -------------------------------------------------------------------------------- /test/kind/wrong/rec1.kk: -------------------------------------------------------------------------------- 1 | alias aa = bb 2 | alias bb = aa -------------------------------------------------------------------------------- /test/kind/wrong/rec1.kk.out: -------------------------------------------------------------------------------- 1 | test/kind/wrong/rec1@kk(1, 1): kind error: Type synonyms cannot be recursive -------------------------------------------------------------------------------- /test/kind/wrong/rec2.kk: -------------------------------------------------------------------------------- 1 | // inductive types cannot have a negative recursive occurrence 2 | type recurse { 3 | con In( out : recurse -> a ) 4 | } 5 | -------------------------------------------------------------------------------- /test/kind/wrong/rec2.kk.out: -------------------------------------------------------------------------------- 1 | test/kind/wrong/rec2@kk(2, 1): kind error: Type recurse is declared as being 2 | (co)inductive but it occurs recursively in a negative position@ 3 | hint: declare it as a divergent (or retractive) type using 'div type' (or 'div effect') to allow negative occurrences -------------------------------------------------------------------------------- /test/kind/wrong/type1.kk: -------------------------------------------------------------------------------- 1 | type list { 2 | con Single( head: a) 3 | } 4 | 5 | alias id = a 6 | alias wrong = list 7 | -------------------------------------------------------------------------------- /test/kind/wrong/type1.kk.out: -------------------------------------------------------------------------------- 1 | test/kind/wrong/type1@kk(6,20): kind error: Invalid type 2 | type context : list 3 | type : id 4 | inferred kind: V -> V 5 | expected kind: V 6 | test/kind/wrong/type1@kk(6,20): kind error: Type alias kind/wrong/type1/id has too few arguments -------------------------------------------------------------------------------- /test/kind/wrong/type2.kk: -------------------------------------------------------------------------------- 1 | type int 2 | alias wrong = int -------------------------------------------------------------------------------- /test/kind/wrong/type2.kk.out: -------------------------------------------------------------------------------- 1 | test/kind/wrong/type2@kk(2,15): kind error: Invalid type 2 | type context : int 3 | type : int 4 | inferred kind: V 5 | expected kind: k1 -> k 6 | because : The type cannot be applied to those arguments -------------------------------------------------------------------------------- /test/kind/wrong/type3.kk: -------------------------------------------------------------------------------- 1 | type int 2 | alias id = a 3 | alias wrong = id -------------------------------------------------------------------------------- /test/kind/wrong/type3.kk.out: -------------------------------------------------------------------------------- 1 | test/kind/wrong/type3@kk(3,15): kind error: Invalid type 2 | type context : id 3 | type : id 4 | inferred kind: V -> V 5 | expected kind: (k1, k) -> k2 6 | because : The type cannot be applied to those arguments 7 | test/kind/wrong/type3@kk(3,15): kind error: Type alias kind/wrong/type3/id has too many arguments -------------------------------------------------------------------------------- /test/kind/wrong/type4.kk: -------------------------------------------------------------------------------- 1 | type int 2 | alias wrong = int -> int int -------------------------------------------------------------------------------- /test/kind/wrong/type4.kk.out: -------------------------------------------------------------------------------- 1 | test/kind/wrong/type4@kk(2,15): kind error: Invalid type 2 | type context : int -> int int 3 | type : int -> int int 4 | inferred kind: V 5 | expected kind: E 6 | because : The effect of a function type must be an effect type -------------------------------------------------------------------------------- /test/kind/wrong/type7.kk: -------------------------------------------------------------------------------- 1 | // test type variable/constructor 2 | type a { 3 | con Test( x : a ) 4 | } 5 | -------------------------------------------------------------------------------- /test/kind/wrong/type7.kk.out: -------------------------------------------------------------------------------- 1 | test/kind/wrong/type7@kk(2, 6): parse error: invalid syntax 2 | expecting type name (and not type variable) -------------------------------------------------------------------------------- /test/lazy/wrong/lazy1.kk: -------------------------------------------------------------------------------- 1 | type stream 2 | SNil 3 | SCons( head : a, tail : stream ) 4 | lazy SApp( pre : stream, post : stream ) -> 5 | match pre 6 | SCons(x,xx) -> SCons(x,SApp(xx,post)) 7 | SNil -> post 8 | 9 | fun foo( m : maybe> ) : int 10 | match m 11 | Just(SCons(x,_xx)) -> x 12 | Just(SNil) -> 0 13 | Nothing -> 0 14 | -------------------------------------------------------------------------------- /test/lazy/wrong/lazy2.kk: -------------------------------------------------------------------------------- 1 | type stream 2 | SNil 3 | SCons( head : a, tail : stream ) 4 | lazy SApp( pre : stream, post : stream ) -> 5 | match pre 6 | SCons(x,xx) -> SCons(x,SApp(xx,post)) 7 | SNil -> post 8 | SApp(p,q) -> SNil 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/lib/bigint1.kk.out: -------------------------------------------------------------------------------- 1 | 1000000000000000000 2 | 999999999999999999 3 | 1000000000000000000 4 | done -------------------------------------------------------------------------------- /test/lib/bigint2.kk: -------------------------------------------------------------------------------- 1 | fun sieve(xs : list, max : int ) : div list 2 | match xs 3 | Nil -> Nil 4 | Cons(x,xx) -> if x*x > max then xx 5 | else Cons(x, xx.filter(fn(y) y%x != 0).sieve(max)) 6 | 7 | fun gen-primes(n : int) : div list 8 | list(2,n).sieve(n) 9 | 10 | fun test(n) 11 | gen-primes(n).length.println 12 | 13 | pub fun main() 14 | test(1000) 15 | -------------------------------------------------------------------------------- /test/lib/bigint2.kk.out: -------------------------------------------------------------------------------- 1 | 167 -------------------------------------------------------------------------------- /test/lib/bigint3.kk: -------------------------------------------------------------------------------- 1 | // test for TAOCP Vol 2 bigint division bug (1st & 2nd edition), 2 | // see: 3 | 4 | noinline fun muldiv( x : int, y : int, z : int ) : int 5 | (x*y)/z 6 | 7 | pub fun main() 8 | muldiv(18446744069414584318, 4294967296, 18446744069414584319).println // 4294967295 9 | -------------------------------------------------------------------------------- /test/lib/bigint3.kk.out: -------------------------------------------------------------------------------- 1 | 4294967295 -------------------------------------------------------------------------------- /test/lib/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "flags": "-e", 3 | "exclude": [ 4 | "file1.kk", 5 | "jaro.kk", 6 | "jaro2.kk", 7 | "time1.kk", 8 | "time3.kk", 9 | "time8.kk" 10 | ] 11 | } -------------------------------------------------------------------------------- /test/lib/decimal1.kk.out: -------------------------------------------------------------------------------- 1 | trunc1 : ok: 0 2 | round1 : ok: 1 -------------------------------------------------------------------------------- /test/lib/dir.kk: -------------------------------------------------------------------------------- 1 | import std/os/path 2 | import std/os/dir 3 | 4 | fun main() 5 | val files = path("test/lib/dir").list-directory 6 | println("found " ++ files.length.show ++ " files") 7 | -------------------------------------------------------------------------------- /test/lib/dir.kk.out: -------------------------------------------------------------------------------- 1 | found 2 files 2 | -------------------------------------------------------------------------------- /test/lib/dir/file-a.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/lib/dir/file-a.txt -------------------------------------------------------------------------------- /test/lib/dir/file-b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/lib/dir/file-b -------------------------------------------------------------------------------- /test/lib/range1.kk: -------------------------------------------------------------------------------- 1 | // This test was made by Tim Whiting, issue #410 2 | fun main() 3 | val a = [1, 2, 3].vector 4 | val x = a[3] 5 | x.show.println 6 | -------------------------------------------------------------------------------- /test/lib/range1.kk.out: -------------------------------------------------------------------------------- 1 | uncaught exception: index out of bounds -------------------------------------------------------------------------------- /test/lib/ref-modify.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | val r = ref(0) 3 | r.modify fn(l) { 4 | l := 1 5 | } 6 | (!r).println 7 | } -------------------------------------------------------------------------------- /test/lib/ref-modify.kk.out: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test/lib/ref-vector-set.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | val v = vector(3, 'a') 3 | var w := v 4 | v[1].println 5 | w[1] := 'b' 6 | v[1].println 7 | w[1].println 8 | } 9 | -------------------------------------------------------------------------------- /test/lib/ref-vector-set.kk.out: -------------------------------------------------------------------------------- 1 | 'a' 2 | 'a' 3 | 'b' -------------------------------------------------------------------------------- /test/lib/slice.kk.out: -------------------------------------------------------------------------------- 1 | True 2 | True 3 | True 4 | True 5 | True 6 | True 7 | True 8 | True 9 | True 10 | True 11 | True 12 | True 13 | True 14 | True 15 | True 16 | True 17 | True 18 | True 19 | True 20 | True 21 | True 22 | True 23 | True 24 | True 25 | True 26 | True 27 | True 28 | True 29 | True 30 | True 31 | True 32 | True 33 | True 34 | True 35 | True 36 | True 37 | True 38 | True 39 | False 40 | False 41 | False 42 | False -------------------------------------------------------------------------------- /test/lib/string.kk: -------------------------------------------------------------------------------- 1 | // See https://github.com/koka-lang/koka/issues/486 2 | fun main() 3 | val some-string = "hello" 4 | println("some-string = [" ++ some-string ++ "]") 5 | println("some-string.vector.string = [" ++ some-string.vector.string ++ "]") 6 | -------------------------------------------------------------------------------- /test/lib/string.kk.out: -------------------------------------------------------------------------------- 1 | some-string = [hello] 2 | some-string@vector@string = [hello] -------------------------------------------------------------------------------- /test/lib/time-parse.kk: -------------------------------------------------------------------------------- 1 | import std/time 2 | 3 | fun main() 4 | parse-iso("2008-12-31").println -------------------------------------------------------------------------------- /test/lib/time-parse.kk.out: -------------------------------------------------------------------------------- 1 | Just(2008-12-31T00:00:00Z) -------------------------------------------------------------------------------- /test/lib/time11.kk.out: -------------------------------------------------------------------------------- 1 | ok -------------------------------------------------------------------------------- /test/lib/time2main.kk: -------------------------------------------------------------------------------- 1 | module time2main 2 | 3 | @open import time2 4 | import std/core 5 | import std/time/utc 6 | 7 | pub fun @expr() : _ () 8 | time2/main() 9 | 10 | pub fun main() : io-noexn () 11 | std/time/utc/@default-utc(fn() std/core/@default-exn(fn() @expr())) -------------------------------------------------------------------------------- /test/lib/vector1.kk.out: -------------------------------------------------------------------------------- 1 | 32 2 | 55555555555555555555555555555555 -------------------------------------------------------------------------------- /test/mask/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "flags" : "--showtypesigs -e", 3 | "exclude": ["inject2"] 4 | } -------------------------------------------------------------------------------- /test/mask/inject1.kk: -------------------------------------------------------------------------------- 1 | // Test mask 2 | 3 | fun foo(action : () -> a ) : a 4 | { 5 | val x = mask(action) 6 | if (False) then foo(action) else x 7 | } 8 | 9 | fun main() { 10 | foo{42}.println 11 | } -------------------------------------------------------------------------------- /test/mask/inject1.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | mask/inject1/foo: forall (action : () -> a) -> a 4 | mask/inject1/main: () -> () -------------------------------------------------------------------------------- /test/mask/inject2.kk: -------------------------------------------------------------------------------- 1 | 2 | fun xforeach-indexed( xs : list, action : (int,a) -> e () ) : e () 3 | { 4 | val i = ref(0) 5 | xs.foreach fn(x) { 6 | val j = !i; 7 | mask{ mask{ action(j,x) } } 8 | i := !i+1 9 | } 10 | } 11 | 12 | fun main() { 13 | var acc := 0 14 | [0,41].xforeach-indexed fn(idx,x) { 15 | acc := acc + idx + x 16 | } 17 | println(acc) 18 | } 19 | -------------------------------------------------------------------------------- /test/mask/inject2.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | main : () -> console () 3 | xforeach-indexed: forall (xs : list, action : (int, a) -> e ()) -> e () -------------------------------------------------------------------------------- /test/mask/inject3.kk: -------------------------------------------------------------------------------- 1 | // Test inject over exceptions (should insert "inject-exn") 2 | fun foo( action : () -> e int ) : e int { 3 | try { 4 | mask(action) 5 | throw("test") 6 | 60 7 | } fn(exn) { 8 | 52 9 | } 10 | } 11 | 12 | fun main() { 13 | try{ foo{ throw("should throw") }}.default(42).println 14 | } -------------------------------------------------------------------------------- /test/mask/inject3.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | mask/inject3/foo: forall (action : () -> e int) -> e int 4 | mask/inject3/main: () -> console () -------------------------------------------------------------------------------- /test/mask/inject4.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | mask/inject4/get: forall () -> (heap) a 4 | mask/inject4/main: () -> () 5 | mask/inject4/new-ref: forall (init : a, action : () -> |e> b) -> b 6 | mask/inject4/set: forall (value : a) -> (heap) () 7 | mask/inject4/test: () -> div int -------------------------------------------------------------------------------- /test/mask/inject4a.kk.out: -------------------------------------------------------------------------------- 1 | 42 2 | 3 | mask/inject4a/get: forall () -> (heap) a 4 | mask/inject4a/main: () -> () 5 | mask/inject4a/new-ref: forall (init : a, action : () -> |e> b) -> b 6 | mask/inject4a/set: forall (value : a) -> (heap) () 7 | mask/inject4a/test: () -> div int -------------------------------------------------------------------------------- /test/medium/allsamples.kk: -------------------------------------------------------------------------------- 1 | // call the `all/main` in the samples directory 2 | module allsamples 3 | 4 | import samples/all 5 | 6 | pub fun main() 7 | all/main() -------------------------------------------------------------------------------- /test/medium/collatz.kk.out: -------------------------------------------------------------------------------- 1 | Took 111 steps@ 2 | 3 | medium/collatz/collatz: (n : int, steps : ? int) -> div maybe 4 | medium/collatz/main: () -> io () -------------------------------------------------------------------------------- /test/medium/config.json: -------------------------------------------------------------------------------- 1 | "--showtypesigs -e" 2 | -------------------------------------------------------------------------------- /test/medium/fibonacci.kk: -------------------------------------------------------------------------------- 1 | module fibonacci 2 | 3 | pub fun main() { 4 | println("The 10000th fibonacci number is " ++ fibonacci(10000).show) 5 | } 6 | 7 | pub fun fibonacci(n : int) : div int { 8 | fib(n, 0, 1) 9 | } 10 | 11 | fun fib(n : int, x1 : int, x2 : int) : div int 12 | { 13 | if (n<=0) return x1 14 | fib(n - 1, x2, x1+x2) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/medium/gcd.kk: -------------------------------------------------------------------------------- 1 | fun gcd( x : int, y : int ) { 2 | if (x>y) then gcd(x - y, y) 3 | elif (x < y) then gcd(x,y - x) 4 | else x 5 | } 6 | 7 | fun main() { 8 | println(gcd(119,7)) 9 | } -------------------------------------------------------------------------------- /test/medium/gcd.kk.out: -------------------------------------------------------------------------------- 1 | 7 2 | 3 | medium/gcd/gcd: (x : int, y : int) -> div int 4 | medium/gcd/main: () -> () -------------------------------------------------------------------------------- /test/medium/nqueens.kk.out: -------------------------------------------------------------------------------- 1 | 92 2 | appendSafe : (queen : int, xs : solution, xss : solutions) -> div solutions 3 | extend : (queen : int, acc : solutions, xss : solutions) -> div solutions 4 | findSolutions: (n : int, queen : int) -> div solutions 5 | main : () -> () 6 | queens : (n : int) -> div int 7 | safe : (queen : int, diag : int, xs : solution) -> bool -------------------------------------------------------------------------------- /test/misc/evidence/evscoped3.kk: -------------------------------------------------------------------------------- 1 | pub module resolve-problem 2 | 3 | import model-using-effect 4 | 5 | // import std/num/ddouble // Commenting this line out hides 6 | // (<) : ddouble -> ddouble -> bool and produces an error 7 | 8 | fun not-handling(a: number, b: number){ 9 | a < b 10 | } 11 | -------------------------------------------------------------------------------- /test/misc/instance/effdup1.kk: -------------------------------------------------------------------------------- 1 | fun exndup() : int { 2 | "hi".println 3 | 42 4 | } 5 | -------------------------------------------------------------------------------- /test/misc/instance/instance4.kk: -------------------------------------------------------------------------------- 1 | ambient heap { } 2 | 3 | val heap = with> { } 4 | 5 | fun foo() { 6 | with heap 7 | 42 8 | } 9 | 10 | fun main() { 11 | println(foo()) 12 | } 13 | -------------------------------------------------------------------------------- /test/misc/instance/instance4a.kk: -------------------------------------------------------------------------------- 1 | // Test empty effect with rank-2 wrapper 2 | 3 | ambient heap { 4 | } 5 | 6 | val heap = fn(action:forall () -> |_e> _a) { 7 | with> { } 8 | action() 9 | } 10 | 11 | 12 | fun foo() { 13 | with heap 14 | 42 15 | } 16 | 17 | fun main() { 18 | println(foo()) 19 | } 20 | -------------------------------------------------------------------------------- /test/misc/instance/rec-type1.kk: -------------------------------------------------------------------------------- 1 | effect state { 2 | fun get() : int 3 | } 4 | 5 | fun foo() { 6 | handle({ 7 | foo() 8 | }) { 9 | get() -> resume(42) 10 | } 11 | } -------------------------------------------------------------------------------- /test/misc/instance/rec-type2.kk: -------------------------------------------------------------------------------- 1 | effect state { 2 | fun get() : int 3 | } 4 | 5 | fun foo(f) { 6 | handle({ 7 | foo(f) 8 | f() 9 | }) { 10 | get() -> resume(42) 11 | } 12 | } -------------------------------------------------------------------------------- /test/misc/instance/state3.kk: -------------------------------------------------------------------------------- 1 | fun xforeach-indexed( xs : list, action : (int,a) -> e () ) : e () 2 | { 3 | var i := 0 4 | xs.foreach fn(x) { 5 | val j = i // don't dereference `i` inside the closure 6 | mask{ action(j,x) } 7 | i := i+1 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/misc/instance/state4.kk: -------------------------------------------------------------------------------- 1 | fun test(xs) 2 | { 3 | match(xs) { 4 | Nil -> 0 5 | Cons -> { 6 | var i := 0 7 | xs.foreach fn(x) { i := i + 1 } 8 | i 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/misc/instance/wrong/inject1.kk: -------------------------------------------------------------------------------- 1 | // Test inject over handled effects 2 | 3 | effect heap { 4 | fun get() : a 5 | fun set(value : a) : () 6 | } 7 | 8 | val new-ref = handler(s) { 9 | get() -> resume(s,s) 10 | set(x) -> resume((),x) 11 | } 12 | 13 | fun main() { 14 | new-ref("hi") { 15 | new-ref(44) { 16 | get() - inject{(get():string).count} // 44 - "hi".count 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /test/misc/instance/wrong/inject1.out: -------------------------------------------------------------------------------- 1 | test/algeff/wrong/inject1.kk(16,15): error: Invalid type 2 | type context : inject{(get():string).count} 3 | type : inject{(get():string).count} 4 | inferred kind: V 5 | expected kind: X 6 | because : Can only inject effect constants (of kind X) -------------------------------------------------------------------------------- /test/misc/instance/wrong/resource1a.flags: -------------------------------------------------------------------------------- 1 | -e -------------------------------------------------------------------------------- /test/misc/instance/wrong/resource1a.out: -------------------------------------------------------------------------------- 1 | operator branch (new-ref) get: resume tail 2 | operator branch (new-ref) set: resume tail 3 | failure while running program: 4 | node out/test/algeff_wrong_resource1a.js 5 | .../out/test/std_core.js: 6 | throw result.exn; // rethrow 7 | ^ 8 | Error: there is no handler found for operation ref-resource1a3/get -------------------------------------------------------------------------------- /test/overload/config.json: -------------------------------------------------------------------------------- 1 | "-e --showtypesigs" 2 | -------------------------------------------------------------------------------- /test/overload/eta1.kk: -------------------------------------------------------------------------------- 1 | import std/num/float64 2 | 3 | pub fun main() 4 | // with `float64/show(f : float64, precision : ?int) : string` 5 | // the implicit parameter needs to be eta-expanded 6 | println(1.0) -------------------------------------------------------------------------------- /test/overload/eta1.kk.out: -------------------------------------------------------------------------------- 1 | 1 2 | 3 | overload/eta1/main: () -> console () -------------------------------------------------------------------------------- /test/overload/eta2.kk: -------------------------------------------------------------------------------- 1 | noinline fun plus(x:int,y:int,z:int=1) 2 | x+y+z 3 | 4 | noinline fun foo( xs : list, zero : a, ?plus : (a,a) -> a) : a 5 | xs.foldl(zero,?plus) 6 | 7 | pub fun main() 8 | [1,2,3].foo(0) -------------------------------------------------------------------------------- /test/overload/eta2.kk.out: -------------------------------------------------------------------------------- 1 | 9 2 | 3 | overload/eta2/foo: forall (xs : list, zero : a, ?plus : (a, a) -> a) -> a 4 | overload/eta2/main: () -> int 5 | overload/eta2/plus: (x : int, y : int, z : ? int) -> int -------------------------------------------------------------------------------- /test/overload/testA.kk: -------------------------------------------------------------------------------- 1 | import std/num/float64 2 | 3 | fun int/plus( x : int, y : int ) : int 4 | x + y 5 | 6 | fun float64/plus( x : float64, y : float64 ) : float64 7 | testA/float64/pi() + x + y 8 | 9 | fun float64/pi() 10 | 3.14 11 | 12 | fun plus( x : char, y : char ) : char 13 | x 14 | 15 | fun test1() 16 | plus(1,2) 17 | -------------------------------------------------------------------------------- /test/parc/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "flags": "-l --target=c --showfcore", 3 | "exclude": [ "parc19.kk" ] 4 | } 5 | -------------------------------------------------------------------------------- /test/parc/inline1.kk: -------------------------------------------------------------------------------- 1 | fun test( xs : list ) : int { 2 | match(xs) { 3 | Cons(x,Cons(y,_)) -> x + y 4 | _ -> 42 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/parc/inline2.kk: -------------------------------------------------------------------------------- 1 | type alpha { A(x: a, y: beta) } 2 | type beta { con B(x: a) B2 } 3 | 4 | fun test(x) { 5 | match(x) { 6 | A(y, B(z)) 7 | -> B(y) // reuse inner B 8 | _ -> B2 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/parc/inline3.kk: -------------------------------------------------------------------------------- 1 | type alpha { con A(x: a, y: beta) A2 } 2 | type beta { B(x: a) } 3 | 4 | fun test(x) { 5 | match(x) { 6 | A(y, B(z)) 7 | -> A(z, B(y)) // reuse both x and inner B 8 | _ -> A2 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/parc/inline4.kk: -------------------------------------------------------------------------------- 1 | fun joinsepx( xs : list, sep : string ) : string 2 | { 3 | fun join-acc( ys : list, acc : string ) { 4 | match(ys) { 5 | Cons(y,yy) -> join-acc(yy, acc + sep + y) // todo: use string builder 6 | Nil -> acc 7 | } 8 | } 9 | match(xs) { 10 | Nil -> "" 11 | Cons(x,xx) -> join-acc(xx,x) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/parc/inline5.kk: -------------------------------------------------------------------------------- 1 | // check copy constructors 2 | struct tup2( x : a, y : b ) // value type 3 | struct tup4( x : a, y : b, z : c, zz : d) // non-value type 4 | 5 | fun copyx( t : tup4, x : a = t.x, zz : d = t.zz ) : tup4 { 6 | Tup4(x,t.y,t.z,zz) 7 | } 8 | -------------------------------------------------------------------------------- /test/parc/parc-leak1.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | (match(Just((1,2))) { 3 | Just(xy) -> xy 4 | }).fst.println 5 | } 6 | -------------------------------------------------------------------------------- /test/parc/parc-leak1b.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | (match(Just([1,2])) { 3 | Just(xy) -> xy 4 | }).head.default(42).println 5 | } 6 | -------------------------------------------------------------------------------- /test/parc/parc1.kk: -------------------------------------------------------------------------------- 1 | fun test(x) { x } 2 | -------------------------------------------------------------------------------- /test/parc/parc10.kk: -------------------------------------------------------------------------------- 1 | fun test(x:list): list { 2 | // drop x 3 | return [] 4 | } 5 | -------------------------------------------------------------------------------- /test/parc/parc11.kk: -------------------------------------------------------------------------------- 1 | fun test(x:list): list { 2 | val y = match(x) { 3 | Cons -> x 4 | Nil -> /* drop x */ [] 5 | } 6 | return y 7 | } 8 | -------------------------------------------------------------------------------- /test/parc/parc12.kk: -------------------------------------------------------------------------------- 1 | fun test(x:int):int { 2 | // dup x 3 | val y = match(x + 1 /* x' */) { 4 | 2 -> /* drop x, x' */ 3 5 | _ -> /* drop x' */ x 6 | } 7 | return y 8 | } 9 | -------------------------------------------------------------------------------- /test/parc/parc13.kk: -------------------------------------------------------------------------------- 1 | fun test(x:int): (() -> int) { 2 | return fn() { x } 3 | } 4 | -------------------------------------------------------------------------------- /test/parc/parc14.kk: -------------------------------------------------------------------------------- 1 | fun test(x:int, y:a, z:a): a { 2 | match(x) { 3 | 0 -> /* drop x, z */ y 4 | _ -> /* drop x, y */ z 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/parc/parc15.kk: -------------------------------------------------------------------------------- 1 | fun test(xs:list, y:int) { 2 | match(xs) { 3 | Cons(x,_) -> 4 | /* dup x; drop y */ 5 | match(xs) { 6 | Cons -> /* drop xs */ x 7 | Nil -> /* drop x, xs */ 2 8 | } 9 | Cons -> /* drop y, xs */ 2 10 | _ -> /* drop xs */ y 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/parc/parc16.kk: -------------------------------------------------------------------------------- 1 | fun test(xs:list, y:int, z:int) { 2 | // drop z 3 | match(xs) { 4 | Cons(x,_) -> 5 | // dup x; drop y 6 | match(xs) { 7 | Cons -> /* drop xs */ x 8 | Nil -> /* drop x, xs */ 2 9 | } 10 | Cons -> /* drop y, xs */ 2 11 | _ -> /* drop xs */ y 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/parc/parc17.kk: -------------------------------------------------------------------------------- 1 | fun test(xs:list) { 2 | match(xs) { 3 | ys as Cons -> ys 4 | Nil -> /* drop xs */ [] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/parc/parc18.kk: -------------------------------------------------------------------------------- 1 | fun test(xs:list, ys:list): list { 2 | match(xs) { 3 | Cons(z) -> match(ys) { 4 | Cons(z /* z0 */) -> /* dup z0; drop xs; drop ys */ [z /* z0 */] 5 | Nil -> /* drop ys */ xs 6 | } 7 | Nil -> /* drop xs */ ys 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/parc/parc19.kk: -------------------------------------------------------------------------------- 1 | fun test(xs:list) { 2 | match(xs) { 3 | Cons(ys as xs /* xs0 */) -> /* dup xs0; drop xs */ xs /* xs0 */ 4 | Nil -> /* drop xs */ 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/parc/parc2.kk: -------------------------------------------------------------------------------- 1 | fun test(x:list): list { 2 | return /* dup x */ x ++ x 3 | } 4 | -------------------------------------------------------------------------------- /test/parc/parc20.kk: -------------------------------------------------------------------------------- 1 | // TRICKY: need to dup x because xs is consumed by Cons-ctor 2 | fun test(xs:list) { 3 | match(xs) { 4 | Cons(x) -> /* dup(x) */ Cons(x /* box(x) */, xs) 5 | Nil -> /* drop xs */ Nil 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/parc/parc21.kk: -------------------------------------------------------------------------------- 1 | // Check that borrowing keeps evaluation order 2 | 3 | noinline fun bo(a : int, ^b : int) { 4 | a 5 | } 6 | 7 | fun print-ret(x : int) { 8 | print(x) 9 | x 10 | } 11 | 12 | fun test() { 13 | bo(3, 4).print 14 | bo(print-ret(3), print-ret(4)) 15 | } -------------------------------------------------------------------------------- /test/parc/parc22.kk: -------------------------------------------------------------------------------- 1 | div type hello 2 | World(i : int) 3 | 4 | fun f(h : hello) 5 | World(2) -------------------------------------------------------------------------------- /test/parc/parc23.kk: -------------------------------------------------------------------------------- 1 | // ensure reuse works through a box 2 | 3 | // struct pair2(a : list, b : b) // this reuses 4 | struct pair2(a : a, b : b) 5 | 6 | fun rotate( ysacc ) 7 | match ysacc 8 | Pair2(Cons(y,ys),acc) -> Pair2(Cons(y,acc),ys) // should reuse the Cons 9 | _ -> Pair2(Nil,Nil) 10 | 11 | fun main() 12 | () 13 | -------------------------------------------------------------------------------- /test/parc/parc3.kk: -------------------------------------------------------------------------------- 1 | fun test(xs:list, y:int, z :int) { 2 | match(xs) { 3 | Cons(x) | x == z -> /* dup x; drop xs; drop y; drop z */ x 4 | Cons(x) | x == y -> /* drop xs; drop z */ y 5 | Cons | y == z -> /* drop xs; drop y; drop z */ 2 6 | _ -> /* drop xs; drop z */ y 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/parc/parc4.kk: -------------------------------------------------------------------------------- 1 | fun test(xs:list>, y:int) { 2 | match(xs) { 3 | Cons(Just(x)) | x == y -> /* dup x; drop xs; drop y */ x 4 | Cons(Nothing) -> /* drop xs; drop y */ 2 5 | _ -> /* drop xs */ y 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/parc/parc5.kk: -------------------------------------------------------------------------------- 1 | fun test() { 2 | head([1],1) 3 | /* 4 | val xs = [1] 5 | match(xs) { 6 | Cons(x) -> /* dup x; drop xs */ x 7 | _ -> /* drop xs */ 1 8 | } 9 | */ 10 | } 11 | -------------------------------------------------------------------------------- /test/parc/parc6.kk: -------------------------------------------------------------------------------- 1 | fun test(y) { 2 | val xs = [1] 3 | match(xs) { 4 | Cons(x) -> /* dup x; drop xs; drop y */ x 5 | _ -> /* drop xs */ y 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/parc/parc7.kk: -------------------------------------------------------------------------------- 1 | fun test(x, y) { 2 | // drop y 3 | return x 4 | } 5 | -------------------------------------------------------------------------------- /test/parc/parc8.kk: -------------------------------------------------------------------------------- 1 | fun test(x:int, y:int) { 2 | // drop y 3 | return /* dup x */ x + x 4 | } 5 | -------------------------------------------------------------------------------- /test/parc/parc9.kk: -------------------------------------------------------------------------------- 1 | fun test(x:list): list { 2 | // drop x 3 | return [] 4 | } 5 | -------------------------------------------------------------------------------- /test/parc/reuse1.kk: -------------------------------------------------------------------------------- 1 | // Unzip a list of pairs into two lists 2 | fun unzipx( xs : list<(a,b)> ) : (list,list) 3 | { 4 | fun iter( ys, acc1, acc2 ) 5 | { 6 | match(ys) { 7 | Cons((x,y),xx) -> iter(xx,Cons(x,acc1),Cons(y,acc2)) 8 | Nil -> (reverse(acc1),reverse(acc2)) 9 | } 10 | } 11 | 12 | iter(xs,[],[]) 13 | } 14 | -------------------------------------------------------------------------------- /test/parc/reuse2.kk: -------------------------------------------------------------------------------- 1 | // Unzip a list of pairs into two lists 2 | fun test( xs : list ) : exn int32 3 | { 4 | match(xs) { 5 | Cons(_,Cons(x)) -> x 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/parc/reuse3.kk: -------------------------------------------------------------------------------- 1 | // Unzip a list of pairs into two lists 2 | fun test( xs : list<(int32,b)> ) : exn int32 3 | { 4 | match(xs) { 5 | Cons(_,Cons((x,_))) -> x 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/parc/reuse4.kk: -------------------------------------------------------------------------------- 1 | // map 2 | fun mapx( xs : list, f : a -> b ) : list 3 | { 4 | match(xs) { 5 | Cons(x,xx) -> Cons(f(x),xx.mapx(f)) 6 | Nil -> Nil 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/perf/heaps/base.kk: -------------------------------------------------------------------------------- 1 | module base 2 | 3 | pub fun raise(s) { throw-exn(Exception(s, ExnError)) } 4 | 5 | // Don't use the exn effect for better performance 6 | pub fun wont-happen() { 7 | unsafe-noexn(fn() { raise("Won't happen") }) 8 | } -------------------------------------------------------------------------------- /test/perf/sets/base.kk: -------------------------------------------------------------------------------- 1 | module base 2 | 3 | pub fun raise(s) { throw-exn(Exception(s, ExnError)) } 4 | 5 | // Don't use the exn effect for better performance 6 | pub fun wont-happen() { 7 | unsafe-noexn(fn() { raise("Won't happen") }) 8 | } -------------------------------------------------------------------------------- /test/static/config.json: -------------------------------------------------------------------------------- 1 | "--showtypesigs --showkindsigs -l" -------------------------------------------------------------------------------- /test/static/div1.kk: -------------------------------------------------------------------------------- 1 | type nat { 2 | Zero 3 | Succ( :nat) 4 | } 5 | 6 | 7 | fun h(x,y) { 8 | match(x) { 9 | Zero -> match(y) { 10 | Zero -> Zero 11 | Succ(s) -> h(x,s) 12 | } 13 | Succ(s) -> h(s,y) 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test/static/div1.kk.out: -------------------------------------------------------------------------------- 1 | nat : V 2 | 3 | static/div1/Succ: (nat) -> nat 4 | static/div1/Zero: nat 5 | static/div1/h: (x : nat, y : nat) -> nat 6 | static/div1/is-succ: (nat : nat) -> bool 7 | static/div1/is-zero: (nat : nat) -> bool -------------------------------------------------------------------------------- /test/static/div2-ack.kk: -------------------------------------------------------------------------------- 1 | type nat { 2 | Zero 3 | Succ(succ:nat) 4 | } 5 | 6 | 7 | fun ack(x,y) { 8 | match(x) { 9 | Zero -> Succ(y) 10 | Succ(s) -> ack(s,match(y) { 11 | Zero -> Succ(Zero) 12 | Succ(t) -> ack(x,t) }) 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test/static/div2-ack.kk.out: -------------------------------------------------------------------------------- 1 | nat : V 2 | 3 | static/div2-ack/Succ: (succ : nat) -> nat 4 | static/div2-ack/Zero: nat 5 | static/div2-ack/ack: (x : nat, y : nat) -> nat 6 | static/div2-ack/is-succ: (nat : nat) -> bool 7 | static/div2-ack/is-zero: (nat : nat) -> bool -------------------------------------------------------------------------------- /test/static/div3.kk: -------------------------------------------------------------------------------- 1 | type ord { 2 | Zero 3 | Succ(pred:ord) 4 | Lim(lim:int -> ord) 5 | } 6 | 7 | 8 | fun addord(x,y) { 9 | match(x) { 10 | Zero -> y 11 | Succ(s) -> Succ(addord(s,y)) 12 | Lim(f) -> Lim( fn(i:int) { addord( f(i), y ) } ) 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test/static/div3.kk.out: -------------------------------------------------------------------------------- 1 | ord : V 2 | 3 | static/div3/Lim: (lim : (int) -> ord) -> ord 4 | static/div3/Succ: (pred : ord) -> ord 5 | static/div3/Zero: ord 6 | static/div3/addord: (x : ord, y : ord) -> ord 7 | static/div3/is-lim: (ord : ord) -> bool 8 | static/div3/is-succ: (ord : ord) -> bool 9 | static/div3/is-zero: (ord : ord) -> bool -------------------------------------------------------------------------------- /test/static/modA.kk: -------------------------------------------------------------------------------- 1 | module modA { 2 | pub type int 3 | pub alias aint = int 4 | } 5 | -------------------------------------------------------------------------------- /test/static/modA.kk.out: -------------------------------------------------------------------------------- 1 | aint : V 2 | int : V 3 | 4 | pub alias aint = int = 1 -------------------------------------------------------------------------------- /test/static/modAWrong.kk: -------------------------------------------------------------------------------- 1 | module static/modAWrong { 2 | pub type int 3 | pub alias aint = int 4 | } 5 | -------------------------------------------------------------------------------- /test/static/modAWrong.kk.out: -------------------------------------------------------------------------------- 1 | aint : V 2 | int : V 3 | 4 | pub alias aint = int = 1 -------------------------------------------------------------------------------- /test/static/modB.kk: -------------------------------------------------------------------------------- 1 | module modB { 2 | pub type int 3 | pub alias bint = int 4 | } 5 | -------------------------------------------------------------------------------- /test/static/modB.kk.out: -------------------------------------------------------------------------------- 1 | bint : V 2 | int : V 3 | 4 | pub alias bint = int = 1 -------------------------------------------------------------------------------- /test/static/module1.kk: -------------------------------------------------------------------------------- 1 | module module1 { 2 | import static/modA 3 | import static/modB 4 | 5 | pub alias ok = aint 6 | } 7 | -------------------------------------------------------------------------------- /test/static/module1.kk.out: -------------------------------------------------------------------------------- 1 | ok : V 2 | 3 | pub alias ok = static/modA/aint = 2 -------------------------------------------------------------------------------- /test/static/module1a.kk: -------------------------------------------------------------------------------- 1 | module module1a { 2 | import static/modA 3 | import static/modB 4 | 5 | alias ok = modA/aint 6 | } 7 | -------------------------------------------------------------------------------- /test/static/module1a.kk.out: -------------------------------------------------------------------------------- 1 | alias ok = static/modA/aint = 2 -------------------------------------------------------------------------------- /test/static/recursive1.kk: -------------------------------------------------------------------------------- 1 | // recursive type 2 | type list { 3 | Nil 4 | Cons(head: a, tail: list) 5 | } 6 | -------------------------------------------------------------------------------- /test/static/recursive1.kk.out: -------------------------------------------------------------------------------- 1 | list : V -> V 2 | 3 | static/recursive1/Cons: forall (head : a, tail : list) -> list 4 | static/recursive1/Nil: forall list 5 | static/recursive1/is-cons: forall (list : list) -> bool 6 | static/recursive1/is-nil: forall (list : list) -> bool -------------------------------------------------------------------------------- /test/static/shadow3a.kk: -------------------------------------------------------------------------------- 1 | // shadow definition 2 | fun id(x) { 3 | fun id(y) { y }; 4 | id(x) 5 | } 6 | -------------------------------------------------------------------------------- /test/static/shadow3a.kk.out: -------------------------------------------------------------------------------- 1 | static/shadow3a/id: forall (x : a) -> a -------------------------------------------------------------------------------- /test/static/shadow3b.kk: -------------------------------------------------------------------------------- 1 | // shadow definition 2 | fun id(x) { 3 | fun id2(x) { x } 4 | fun id(y) { id2(y) } 5 | id(x) 6 | } 7 | -------------------------------------------------------------------------------- /test/static/shadow3b.kk.out: -------------------------------------------------------------------------------- 1 | static/shadow3b/id: forall (x : a) -> a 2 | test/static/shadow3b@kk(3,11): type warning: x shadows an earlier local definition or parameter -------------------------------------------------------------------------------- /test/static/wrong/alias1.kk: -------------------------------------------------------------------------------- 1 | import static/modA 2 | import static/modAWrong 3 | 4 | alias myint = aint 5 | -------------------------------------------------------------------------------- /test/static/wrong/alias1.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/alias1@kk(4,15): kind error: Type aint is ambiguous@ 2 | hint: It can refer to either static/modAWrong/aint, or static/modA/aint 3 | test/static/wrong/alias1@kk(4,15): kind error: Type aint is ambiguous@ 4 | hint: It can refer to either static/modAWrong/aint, or static/modA/aint -------------------------------------------------------------------------------- /test/static/wrong/case1.kk: -------------------------------------------------------------------------------- 1 | type foo 2 | alias bar = fOO 3 | -------------------------------------------------------------------------------- /test/static/wrong/case1.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/case1@kk(2,13): kind error: type fOO should be cased as foo -------------------------------------------------------------------------------- /test/static/wrong/case2.kk: -------------------------------------------------------------------------------- 1 | alias bar = inT 2 | -------------------------------------------------------------------------------- /test/static/wrong/case2.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/case2@kk(1,13): kind error: type inT should be cased as int -------------------------------------------------------------------------------- /test/static/wrong/case4.kk: -------------------------------------------------------------------------------- 1 | // case sensitivity 2 | import static/modA 3 | import static/modB 4 | 5 | alias wrong = aInt 6 | -------------------------------------------------------------------------------- /test/static/wrong/case4.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/case4@kk(5,15): kind error: type aInt should be cased as aint -------------------------------------------------------------------------------- /test/static/wrong/case5.kk: -------------------------------------------------------------------------------- 1 | // case sensitivity 2 | import modA = static/modA 3 | import static/modB 4 | 5 | alias wrong = modA/aInt 6 | -------------------------------------------------------------------------------- /test/static/wrong/case5.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/case5@kk(5,15): kind error: type aInt should be cased as aint 2 | test/static/wrong/case5@kk(5,15): kind error: Type modA/static/aint is not defined 3 | hint: bind the variable using forall ? -------------------------------------------------------------------------------- /test/static/wrong/case5a.kk: -------------------------------------------------------------------------------- 1 | // case sensitivity 2 | import modD = static/modA 3 | import static/modB 4 | 5 | alias wrong = modD/aInt 6 | -------------------------------------------------------------------------------- /test/static/wrong/case5a.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/case5a@kk(5,15): kind error: type aInt should be cased as aint 2 | test/static/wrong/case5a@kk(5,15): kind error: Type modA/static/aint is not defined 3 | hint: bind the variable using forall ? -------------------------------------------------------------------------------- /test/static/wrong/case6.kk: -------------------------------------------------------------------------------- 1 | // case sensitivity 2 | import moda = static/modA 3 | import static/modB 4 | 5 | alias wrong = moda/ainT 6 | -------------------------------------------------------------------------------- /test/static/wrong/case6.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/case6@kk(5,15): kind error: type ainT should be cased as aint 2 | test/static/wrong/case6@kk(5,15): kind error: Type modA/static/aint is not defined 3 | hint: bind the variable using forall ? -------------------------------------------------------------------------------- /test/static/wrong/config.json: -------------------------------------------------------------------------------- 1 | "-l --showtypesigs --showkindsigs" -------------------------------------------------------------------------------- /test/static/wrong/duplicate1.kk: -------------------------------------------------------------------------------- 1 | alias dup = int 2 | alias foo = dup 3 | alias bar = foo 4 | alias dup = list 5 | -------------------------------------------------------------------------------- /test/static/wrong/duplicate1.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/duplicate1@kk(4, 1): kind error: Type static/wrong/duplicate1/dup is already defined -------------------------------------------------------------------------------- /test/static/wrong/duplicate2.kk: -------------------------------------------------------------------------------- 1 | // duplicate data type 2 | type dup { 3 | Dup(:int) 4 | } 5 | 6 | type dup { 7 | Dup2(:int) 8 | } 9 | -------------------------------------------------------------------------------- /test/static/wrong/duplicate2.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/duplicate2@kk(6, 1): kind error: Type static/wrong/duplicate2/dup is already defined -------------------------------------------------------------------------------- /test/static/wrong/duplicate3.kk: -------------------------------------------------------------------------------- 1 | // duplicate constructor 2 | type dup 3 | Dup1(:int) 4 | Dup1(:int) 5 | -------------------------------------------------------------------------------- /test/static/wrong/duplicate3.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/duplicate3@kk(4, 3): kind error: Constructor static/wrong/duplicate3/Dup1 is already defined at (3, 3) -------------------------------------------------------------------------------- /test/static/wrong/duplicate3a.kk: -------------------------------------------------------------------------------- 1 | // duplicate constructor 2 | type dup1 { Dup1(:int) } 3 | type dup2 { Dup1(:int) } 4 | -------------------------------------------------------------------------------- /test/static/wrong/duplicate3a.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/duplicate3a@kk(3,13): kind error: Constructor static/wrong/duplicate3a/Dup1 is already defined at (2,13) -------------------------------------------------------------------------------- /test/static/wrong/duplicate3b.kk: -------------------------------------------------------------------------------- 1 | // duplicate constructor 2 | type dup1 { DUP1(:int) } 3 | type dup2 { Dup1(:int) } 4 | -------------------------------------------------------------------------------- /test/static/wrong/duplicate3b.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/duplicate3b@kk(3,13): kind error: Constructor static/wrong/duplicate3b/Dup1 is already defined at (2,13) -------------------------------------------------------------------------------- /test/static/wrong/module1.kk: -------------------------------------------------------------------------------- 1 | module static/wrong/module1 { 2 | import static/modA 3 | import static/modB 4 | 5 | alias ok = int 6 | } 7 | -------------------------------------------------------------------------------- /test/static/wrong/module1.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/module1@kk(5,14): kind error: Type int is ambiguous@ 2 | hint: It can refer to either static/modB/int, static/modA/int, or std/core/types/int 3 | test/static/wrong/module1@kk(5,14): kind error: Type int is ambiguous@ 4 | hint: It can refer to either static/modB/int, static/modA/int, or std/core/types/int -------------------------------------------------------------------------------- /test/static/wrong/module2.kk: -------------------------------------------------------------------------------- 1 | module static/wrong/module2 { 2 | import static/doesNotExist 3 | import static/b 4 | 5 | alias ok = int 6 | } 7 | -------------------------------------------------------------------------------- /test/static/wrong/module2.kk.out: -------------------------------------------------------------------------------- 1 | (1, 0): build error: could not find module: static/doesNotExist 2 | search path: @@@,@@@/lib,@@@/test -------------------------------------------------------------------------------- /test/static/wrong/rec1.kk: -------------------------------------------------------------------------------- 1 | // illegal recursive call with more arguments 2 | // used to trigger bug in divergent analysis 3 | 4 | fun rfix(f) { f( fn(x){ rfix(f,x) }) } -------------------------------------------------------------------------------- /test/static/wrong/rec1.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/rec1@kk(4,25): type error: function is applied to too many arguments 2 | context : rfix(f,x) 3 | term : rfix 4 | inferred type: (f : _a) -> _e _b -------------------------------------------------------------------------------- /test/static/wrong/shadow1.kk: -------------------------------------------------------------------------------- 1 | alias shadow = a 2 | -------------------------------------------------------------------------------- /test/static/wrong/shadow1.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/shadow1@kk(1,16): kind error: Type a is already defined -------------------------------------------------------------------------------- /test/static/wrong/shadow2.kk: -------------------------------------------------------------------------------- 1 | // shadow parameter 2 | val id : forall (a) -> a = (fn(x) { 3 | return x 4 | }) 5 | -------------------------------------------------------------------------------- /test/static/wrong/shadow2.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/shadow2@kk(2,19): kind error: Type a is already defined -------------------------------------------------------------------------------- /test/static/wrong/shadow3.kk: -------------------------------------------------------------------------------- 1 | // shadow parameter 2 | fun id(x,x) { x } 3 | -------------------------------------------------------------------------------- /test/static/wrong/shadow3.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/shadow3@kk(2,10): type error: x is already defined at (2, 8) 2 | hint: if these are potentially recursive definitions, give a full type signature to disambiguate them@ -------------------------------------------------------------------------------- /test/static/wrong/shadow4.kk: -------------------------------------------------------------------------------- 1 | // combination of warning and error used to display incorrectly 2 | fun foo(x) { val x = 2; x + True } -------------------------------------------------------------------------------- /test/static/wrong/shadow4.kk.out: -------------------------------------------------------------------------------- 1 | test/static/wrong/shadow4@kk(2,29): type error: True does not match the argument types 2 | context : True 3 | term : True 4 | inferred type: bool 5 | expected type: int 6 | test/static/wrong/shadow4@kk(2,18): type warning: x shadows an earlier local definition or parameter -------------------------------------------------------------------------------- /test/static/xcase1.kk: -------------------------------------------------------------------------------- 1 | import static/modA 2 | alias bar = modA/aint 3 | -------------------------------------------------------------------------------- /test/static/xcase1.kk.out: -------------------------------------------------------------------------------- 1 | bar : V 2 | 3 | pub alias bar = static/modA/aint = 2 -------------------------------------------------------------------------------- /test/syntax/braces1.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | print("hi"); print("world") 3 | print("!") 4 | } 5 | 6 | 7 | fun map(f,xs) { 8 | match(xs) { 9 | Nil -> Nil 10 | Cons(x,xx) -> { val y = f(x); val yy = map(f,xx); Cons(y,yy) } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/syntax/comment1.kk: -------------------------------------------------------------------------------- 1 | // documentation 2 | fun foo() { 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /test/syntax/comment1.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/comment1.kk.out -------------------------------------------------------------------------------- /test/syntax/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "flags": "-l" 3 | } -------------------------------------------------------------------------------- /test/syntax/final-ctl.kk: -------------------------------------------------------------------------------- 1 | // https://github.com/koka-lang/koka/issues/456 2 | effect final ctl err-not-found(name: string): a 3 | 4 | fun error-handler(eval: () -> int): e string 5 | with final ctl err-not-found(name) "function not found: " ++ name 6 | eval().show 7 | 8 | fun test() 9 | with error-handler 10 | "foo".println 11 | err-not-found("foo") 12 | 0 13 | -------------------------------------------------------------------------------- /test/syntax/final-ctl.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/final-ctl.kk.out -------------------------------------------------------------------------------- /test/syntax/layout1.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | print("hi"); print("world") 3 | print("!") 4 | } 5 | 6 | 7 | fun map(f,xs) { 8 | match(xs) { 9 | Nil -> Nil 10 | Cons(x,xx) -> { val y = f(x); val yy = map(f,xx); Cons(y,yy) } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/syntax/layout1.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/layout1.kk.out -------------------------------------------------------------------------------- /test/syntax/layout2.kk: -------------------------------------------------------------------------------- 1 | 2 | fun main() { 3 | print("hi"); 4 | } 5 | -------------------------------------------------------------------------------- /test/syntax/layout2.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/layout2.kk.out -------------------------------------------------------------------------------- /test/syntax/syntax1.kk: -------------------------------------------------------------------------------- 1 | fun id2(x) { x } 2 | 3 | fun id3(x:a) : a { x } 4 | 5 | fun id4(x:a) : a 6 | { x } 7 | 8 | fun id5(x : a ) : a 9 | { 10 | x 11 | } 12 | 13 | val id6 : forall a -> a = fn(x) { x } 14 | -------------------------------------------------------------------------------- /test/syntax/syntax1.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/syntax1.kk.out -------------------------------------------------------------------------------- /test/syntax/trailing1.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | val xs = [1,2,3,] 3 | xs.length 4 | } -------------------------------------------------------------------------------- /test/syntax/trailing1.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/trailing1.kk.out -------------------------------------------------------------------------------- /test/syntax/trailing2.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | val x = (1,2,) 3 | x.fst 4 | } -------------------------------------------------------------------------------- /test/syntax/trailing2.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/trailing2.kk.out -------------------------------------------------------------------------------- /test/syntax/type1.kk: -------------------------------------------------------------------------------- 1 | alias id = a -------------------------------------------------------------------------------- /test/syntax/type1.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/type1.kk.out -------------------------------------------------------------------------------- /test/syntax/use1.kk: -------------------------------------------------------------------------------- 1 | // documentation 2 | fun main() { 3 | var i := 2 4 | with while{i >= 0} 5 | println(i) 6 | i := i - 1 7 | } 8 | -------------------------------------------------------------------------------- /test/syntax/use1.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/use1.kk.out -------------------------------------------------------------------------------- /test/syntax/use2.kk: -------------------------------------------------------------------------------- 1 | // documentation 2 | fun main() { 3 | with x = [1,2].foreach 4 | println(x) 5 | } 6 | -------------------------------------------------------------------------------- /test/syntax/use2.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/use2.kk.out -------------------------------------------------------------------------------- /test/syntax/utf1.kk: -------------------------------------------------------------------------------- 1 | fun main() 2 | { 3 | val s = "hello effectful world of 効果! "; 4 | println( s.list.show-list(fn(c) {show-hex(c.int)}) ); 5 | println(s) 6 | } 7 | -------------------------------------------------------------------------------- /test/syntax/utf1.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/utf1.kk.out -------------------------------------------------------------------------------- /test/syntax/utf2.kk: -------------------------------------------------------------------------------- 1 | // Jean-Christophe Filli�tre: 2 | fun foo() { 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /test/syntax/utf2.kk.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/koka-lang/koka/c9c313f09cc10c24386f97f3d80a22f3f132baed/test/syntax/utf2.kk.out -------------------------------------------------------------------------------- /test/syntax/wrong/braces1.kk: -------------------------------------------------------------------------------- 1 | fun map(f,xs) { 2 | match(xs) { 3 | Nil -> Nil 4 | Cons(x,xx)) -> { val y = f(x); val yy = map(f,xx); Cons(y,yy) } 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/syntax/wrong/braces1.kk.out: -------------------------------------------------------------------------------- 1 | test/syntax/wrong/braces1@kk(4,15): parse error: invalid syntax 2 | unexpected ")" 3 | expecting ":", guard condition "|", "->" or "{" -------------------------------------------------------------------------------- /test/syntax/wrong/braces2.kk: -------------------------------------------------------------------------------- 1 | fun map(f,xs) { 2 | match(xs) { 3 | Nil -> Nil 4 | Cons(x,xx -> { val y = f(x); val yy = map(f,xx); Cons(y,yy) } 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/syntax/wrong/braces2.kk.out: -------------------------------------------------------------------------------- 1 | test/syntax/wrong/braces2@kk(4,15): parse error: invalid syntax 2 | unexpected "->" 3 | expecting "," or ")" -------------------------------------------------------------------------------- /test/syntax/wrong/unused1.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | 1 2 + 3 3 | } -------------------------------------------------------------------------------- /test/syntax/wrong/unused1.kk.out: -------------------------------------------------------------------------------- 1 | test/syntax/wrong/unused1@kk(2, 5): parse error: invalid syntax 2 | unexpected 2 3 | expecting "@", "(", "[", "{", "fn", operator, ":=", ";", "return" or "}" -------------------------------------------------------------------------------- /test/syntax/wrong/unused2.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | 2 + 3 print("hi") 3 | } -------------------------------------------------------------------------------- /test/syntax/wrong/unused2.kk.out: -------------------------------------------------------------------------------- 1 | test/syntax/wrong/unused2@kk(2, 9): parse error: invalid syntax 2 | unexpected identifier "print" 3 | expecting "@", "(", "[", "{", "fn", operator, ":=", ";", "return" or "}" -------------------------------------------------------------------------------- /test/syntax/wrong/unused3.kk: -------------------------------------------------------------------------------- 1 | fun main() { 2 | val xs = [1,2,3] 3 | 1 xs.length 4 | } -------------------------------------------------------------------------------- /test/syntax/wrong/unused3.kk.out: -------------------------------------------------------------------------------- 1 | test/syntax/wrong/unused3@kk(3, 5): parse error: invalid syntax 2 | unexpected identifier "xs" 3 | expecting "@", "(", "[", "{", "fn", operator, ":=", ";", "return" or "}" -------------------------------------------------------------------------------- /test/syntax/wrong/utf1.kk: -------------------------------------------------------------------------------- 1 | fun main() 2 | { 3 | // print(2 + "hello effectful world of 効果! "); 4 | print(2 + "hello effectful world!"); 5 | } 6 | -------------------------------------------------------------------------------- /test/syntax/wrong/utf1.kk.out: -------------------------------------------------------------------------------- 1 | test/syntax/wrong/utf1@kk(4,13): type error: types do not match 2 | context : 2 + "hello effectful world!" 3 | term : "hello effectful world!" 4 | inferred type: string 5 | expected type: int -------------------------------------------------------------------------------- /test/type/alias.kk: -------------------------------------------------------------------------------- 1 | alias newtest = test; 2 | 3 | type test 4 | Test(nt: newtest) 5 | Empty 6 | 7 | fun test1(n: newtest) 8 | match n 9 | Test(nt) -> nt.test1 + 1 10 | Empty -> 0 11 | 12 | fun main() 13 | test1(Test(Test(Empty))).println 14 | -------------------------------------------------------------------------------- /test/type/alias.kk.out: -------------------------------------------------------------------------------- 1 | type/alias/Empty: test 2 | type/alias/Test: (nt : newtest) -> test 3 | type/alias/is-empty: (test : test) -> bool 4 | type/alias/is-test: (test : test) -> bool 5 | type/alias/main: () -> console () 6 | type/alias/test1: (n : newtest) -> int -------------------------------------------------------------------------------- /test/type/args1.kk: -------------------------------------------------------------------------------- 1 | value struct test( x : int, y : int = 0 ) 2 | 3 | fun foo() { 4 | Test(1) 5 | } -------------------------------------------------------------------------------- /test/type/args1.kk.out: -------------------------------------------------------------------------------- 1 | type/args1/test/x: (test : test) -> int 2 | type/args1/test/y: (test : test) -> int 3 | type/args1/Test: (x : int, y : int) -> test 4 | type/args1/foo: () -> test -------------------------------------------------------------------------------- /test/type/config.json: -------------------------------------------------------------------------------- 1 | "-l --showtypesigs" -------------------------------------------------------------------------------- /test/type/data1.kk: -------------------------------------------------------------------------------- 1 | struct foo( i : int, d : float64 ) 2 | 3 | fun foo( i : int, d : float64 = 0.0 ) : foo { 4 | Foo(i,d) 5 | } 6 | 7 | fun foo( d : float64 ) : foo { 8 | Foo(0,d) 9 | } 10 | 11 | fun main() { 12 | val f = foo(1) 13 | () 14 | } -------------------------------------------------------------------------------- /test/type/data2.kk: -------------------------------------------------------------------------------- 1 | struct foo( i : int, d : float64 = 0.0 ) 2 | 3 | // Dependency issue: if called 'foo' it is checked *before* .create-foo is defined 4 | fun foo( i : int ) : foo { 5 | Foo(i) 6 | } 7 | 8 | fun test(x) { 9 | val f = Foo(x) 10 | () 11 | } -------------------------------------------------------------------------------- /test/type/eff-rec1.kk: -------------------------------------------------------------------------------- 1 | div effect cow 2 | ctl moo() : (() -> ()) 3 | 4 | 5 | val cow = handler 6 | ctl moo() 7 | println("moo") 8 | resume( { moo()() } ) 9 | 10 | fun main() 11 | with cow 12 | moo()() 13 | -------------------------------------------------------------------------------- /test/type/eff-rec1.kk.out: -------------------------------------------------------------------------------- 1 | type/eff-rec1/cow: forall (() -> a) -> a 2 | type/eff-rec1/main: () -> () 3 | type/eff-rec1/moo: () -> (() -> ()) -------------------------------------------------------------------------------- /test/type/eff-rec1a.kk: -------------------------------------------------------------------------------- 1 | div effect fun moo() : (() -> ()) 2 | 3 | fun main() 4 | with fun moo() 5 | println("moo") 6 | ({ moo()() }) 7 | moo()() 8 | 9 | -------------------------------------------------------------------------------- /test/type/eff-rec1a.kk.out: -------------------------------------------------------------------------------- 1 | type/eff-rec1a/main: () -> () 2 | type/eff-rec1a/moo: () -> (() -> ()) -------------------------------------------------------------------------------- /test/type/eff1.kk: -------------------------------------------------------------------------------- 1 | fun omega(): div () { 2 | return () 3 | } 4 | 5 | fun main() { 6 | fun choose(x,y){ if (True) then x else y} 7 | choose(throw("hi"),omega()) 8 | } -------------------------------------------------------------------------------- /test/type/eff1.kk.out: -------------------------------------------------------------------------------- 1 | type/eff1/main: () -> pure () 2 | type/eff1/omega: () -> div () -------------------------------------------------------------------------------- /test/type/eff2.kk: -------------------------------------------------------------------------------- 1 | fun twice(f,x) { 2 | return f(f(x)) 3 | } 4 | 5 | fun twice2(f,x) { 6 | return id(f(id(f(x)))) 7 | } -------------------------------------------------------------------------------- /test/type/eff2.kk.out: -------------------------------------------------------------------------------- 1 | type/eff2/twice: forall (f : (a) -> e a, x : a) -> e a 2 | type/eff2/twice2: forall (f : (a) -> e a, x : a) -> e a -------------------------------------------------------------------------------- /test/type/eff3.kk: -------------------------------------------------------------------------------- 1 | fun choose(x,y){ if (True) then x else y} 2 | 3 | fun test() { 4 | choose( ref(1), throw("hi") ) 5 | } 6 | 7 | fun test2() { 8 | choose( const(())(ref(1)), ref(2).set(3)) 9 | } 10 | -------------------------------------------------------------------------------- /test/type/eff3.kk.out: -------------------------------------------------------------------------------- 1 | type/eff3/choose: forall (x : a, y : a) -> a 2 | type/eff3/test: forall () -> ,exn> ref 3 | type/eff3/test2: () -> () -------------------------------------------------------------------------------- /test/type/eff4.kk: -------------------------------------------------------------------------------- 1 | // test subtyping etc 2 | fun ioapp( f ) : io () { 3 | return f() 4 | } 5 | 6 | fun test() { 7 | ioapp(fn(){ () }) 8 | } 9 | -------------------------------------------------------------------------------- /test/type/eff4.kk.out: -------------------------------------------------------------------------------- 1 | type/eff4/ioapp: (f : () -> io ()) -> io () 2 | type/eff4/test: () -> io () -------------------------------------------------------------------------------- /test/type/eff4a.kk: -------------------------------------------------------------------------------- 1 | // test subtyping etc 2 | fun ioapp( f : () -> () ) : () { 3 | return f() 4 | } 5 | 6 | fun test() { 7 | ioapp(fn(){ () }) 8 | } 9 | -------------------------------------------------------------------------------- /test/type/eff4a.kk.out: -------------------------------------------------------------------------------- 1 | type/eff4a/ioapp: forall (f : () -> ()) -> () 2 | type/eff4a/test: () -> io () -------------------------------------------------------------------------------- /test/type/eff4b.kk: -------------------------------------------------------------------------------- 1 | // test subtyping etc 2 | fun ioapp( f ) : () { 3 | return f() 4 | } 5 | 6 | fun test() { 7 | ioapp(fn(){ () }) 8 | } 9 | -------------------------------------------------------------------------------- /test/type/eff4b.kk.out: -------------------------------------------------------------------------------- 1 | type/eff4b/ioapp: (f : () -> ()) -> () 2 | type/eff4b/test: () -> () -------------------------------------------------------------------------------- /test/type/eff4c.kk: -------------------------------------------------------------------------------- 1 | // test subtyping etc 2 | fun ioapp( f ) : _e () { 3 | print("hi") 4 | return f() 5 | } 6 | 7 | fun test() { 8 | ioapp(fn(){ () }) 9 | } 10 | -------------------------------------------------------------------------------- /test/type/eff4c.kk.out: -------------------------------------------------------------------------------- 1 | type/eff4c/ioapp: forall (f : () -> ()) -> () 2 | type/eff4c/test: () -> console () -------------------------------------------------------------------------------- /test/type/eff5.kk: -------------------------------------------------------------------------------- 1 | fun choose(x,y){ if (True) then x else y} 2 | 3 | // test if we keep effects polymorph 4 | // ok : forall (f: (x: a) -> e a) -> ((x: a) -> e a) 5 | fun ok(f) { choose(id,f) } 6 | -------------------------------------------------------------------------------- /test/type/eff5.kk.out: -------------------------------------------------------------------------------- 1 | type/eff5/choose: forall (x : a, y : a) -> a 2 | type/eff5/ok: forall (f : (x : a) -> e a) -> ((x : a) -> e a) -------------------------------------------------------------------------------- /test/type/eff5a.kk: -------------------------------------------------------------------------------- 1 | fun choose(x,y){ if (True) then x else y} 2 | fun error(msg:string){ throw(msg) } 3 | 4 | // test if we keep effects polymorph 5 | // ok : forall (f: (string) -> e a) -> ((string) -> e a) with (partial<=e) 6 | fun ok(f) { choose(error,f) } 7 | -------------------------------------------------------------------------------- /test/type/eff5a.kk.out: -------------------------------------------------------------------------------- 1 | type/eff5a/choose: forall (x : a, y : a) -> a 2 | type/eff5a/error: forall (msg : string) -> exn a 3 | type/eff5a/ok: forall (f : (msg : string) -> a) -> ((msg : string) -> a) -------------------------------------------------------------------------------- /test/type/eff6.kk: -------------------------------------------------------------------------------- 1 | fun remote( f : () -> exn () ) : exn () { () } 2 | 3 | fun test(f) { print("hi"); remote(f); f() } -------------------------------------------------------------------------------- /test/type/eff6.kk.out: -------------------------------------------------------------------------------- 1 | type/eff6/remote: (f : () -> exn ()) -> exn () 2 | type/eff6/test: (f : () -> exn ()) -> () -------------------------------------------------------------------------------- /test/type/eff6a.kk: -------------------------------------------------------------------------------- 1 | fun remote( f : () -> exn () ) : exn () { () } 2 | 3 | fun test(f) { remote(f); f(); print("hi"); } -------------------------------------------------------------------------------- /test/type/eff6a.kk.out: -------------------------------------------------------------------------------- 1 | type/eff6a/remote: (f : () -> exn ()) -> exn () 2 | type/eff6a/test: (f : () -> exn ()) -> () -------------------------------------------------------------------------------- /test/type/eff6b.kk: -------------------------------------------------------------------------------- 1 | fun remote( f : () -> exn () ) : exn () { () } 2 | 3 | fun test(f) { remote(f); f(); } -------------------------------------------------------------------------------- /test/type/eff6b.kk.out: -------------------------------------------------------------------------------- 1 | type/eff6b/remote: (f : () -> exn ()) -> exn () 2 | type/eff6b/test: (f : () -> exn ()) -> exn () -------------------------------------------------------------------------------- /test/type/eff7.kk: -------------------------------------------------------------------------------- 1 | fun whilex(p,f) { 2 | if (p()) then { 3 | f(); 4 | whilex(p,f); 5 | } 6 | else { 7 | print("done"); 8 | () 9 | } 10 | } -------------------------------------------------------------------------------- /test/type/eff7.kk.out: -------------------------------------------------------------------------------- 1 | type/eff7/whilex: forall (p : () -> bool, f : () -> a) -> () -------------------------------------------------------------------------------- /test/type/eff7a.kk: -------------------------------------------------------------------------------- 1 | fun whilex(p,f) { 2 | if (p()) then { 3 | f(); 4 | whilex(p,f); 5 | } 6 | else () 7 | } -------------------------------------------------------------------------------- /test/type/eff7a.kk.out: -------------------------------------------------------------------------------- 1 | type/eff7a/whilex: forall (p : () -> bool, f : () -> a) -> () -------------------------------------------------------------------------------- /test/type/eff8.kk: -------------------------------------------------------------------------------- 1 | fun forever(f) { 2 | f(); 3 | forever(f); 4 | } -------------------------------------------------------------------------------- /test/type/eff8.kk.out: -------------------------------------------------------------------------------- 1 | type/eff8/forever: forall (f : () -> a) -> b -------------------------------------------------------------------------------- /test/type/eff8a.kk: -------------------------------------------------------------------------------- 1 | fun forever(f) { 2 | f(); 3 | print("hi"); 4 | forever(f); 5 | } -------------------------------------------------------------------------------- /test/type/eff8a.kk.out: -------------------------------------------------------------------------------- 1 | type/eff8a/forever: forall (f : () -> a) -> b -------------------------------------------------------------------------------- /test/type/eff8b.kk: -------------------------------------------------------------------------------- 1 | fun forever(f) { 2 | f("hi"); 3 | throw("hi"); 4 | forever(f); 5 | } 6 | 7 | fun test() { 8 | forever( println ); 9 | } -------------------------------------------------------------------------------- /test/type/eff8b.kk.out: -------------------------------------------------------------------------------- 1 | type/eff8b/forever: forall (f : (string) -> a) -> b 2 | type/eff8b/test: forall () -> a -------------------------------------------------------------------------------- /test/type/eff9.kk: -------------------------------------------------------------------------------- 1 | type foo :: X 2 | 3 | fun onevent( _f : () -> e () ) : () { 4 | () 5 | } 6 | 7 | fun f() : () 8 | { fun g() : foo () 9 | { 10 | return () 11 | } 12 | onevent(g) 13 | } 14 | -------------------------------------------------------------------------------- /test/type/eff9.kk.out: -------------------------------------------------------------------------------- 1 | type/eff9/f : () -> () 2 | type/eff9/onevent: forall (() -> e ()) -> () -------------------------------------------------------------------------------- /test/type/exp1.kk: -------------------------------------------------------------------------------- 1 | pub type xlist 2 | Cons( head : a, tail : xlist ) 3 | XNil 4 | 5 | /* 6 | pub type ylist 7 | ZCons( hd : a, tl : ylist ) 8 | YNil 9 | */ 10 | 11 | // checks potential exponential type check time 12 | pub fun test1( x,y ) 13 | Cons(x,Cons(y,Cons(x, Cons(y,(Cons(x,Cons(y,Cons(x, Cons(y, XNil ))))))))) 14 | -------------------------------------------------------------------------------- /test/type/higherrank2.kk: -------------------------------------------------------------------------------- 1 | fun choose(x,y){ if (True) then x else y} 2 | 3 | val ids1 = [id] 4 | val ids2 = [id : forall a -> a] 5 | 6 | fun ok(f) { 7 | choose(id,f) 8 | } -------------------------------------------------------------------------------- /test/type/higherrank2.kk.out: -------------------------------------------------------------------------------- 1 | type/higherrank2/choose: forall (x : a, y : a) -> a 2 | type/higherrank2/ids1: forall list<(x : a) -> e a> 3 | type/higherrank2/ids2: list (a) -> a> 4 | type/higherrank2/ok: forall (f : (x : a) -> e a) -> ((x : a) -> e a) -------------------------------------------------------------------------------- /test/type/higherrank3.kk: -------------------------------------------------------------------------------- 1 | fun auto(f : forall a -> a) { f(f) } 2 | 3 | fun ok(f : forall a -> a ) { 4 | (auto(f)) 5 | } 6 | -------------------------------------------------------------------------------- /test/type/higherrank3.kk.out: -------------------------------------------------------------------------------- 1 | type/higherrank3/auto: forall (f : forall (b) -> b) -> ((a) -> e a) 2 | type/higherrank3/ok: forall (f : forall (b) -> b) -> ((a) -> e a) -------------------------------------------------------------------------------- /test/type/hm1.kk: -------------------------------------------------------------------------------- 1 | fun choose(x,y){ if (True) then x else y } 2 | 3 | fun apply(f,x) { 4 | f(x) 5 | } 6 | 7 | fun test() { 8 | fun i(x) { x } 9 | i(i) 10 | } 11 | 12 | fun test2() { 13 | single(id) 14 | } 15 | 16 | fun test3() { choose(fn(x,y){x},fn(x,y){y}) } 17 | fun test4(f) { choose(id,f) } 18 | -------------------------------------------------------------------------------- /test/type/hm1.kk.out: -------------------------------------------------------------------------------- 1 | type/hm1/apply: forall (f : (a) -> e b, x : a) -> e b 2 | type/hm1/choose: forall (x : a, y : a) -> a 3 | type/hm1/test: forall () -> ((x : a) -> a) 4 | type/hm1/test2: forall () -> list<(x : a) -> e a> 5 | type/hm1/test3: forall () -> ((x : a, y : a) -> a) 6 | type/hm1/test4: forall (f : (x : a) -> e a) -> ((x : a) -> e a) -------------------------------------------------------------------------------- /test/type/hm2.kk: -------------------------------------------------------------------------------- 1 | // fun choose1(x:a,y:a) { x } 2 | 3 | fun choose2(x:a,y:a) : a { x } 4 | 5 | fun choose3(x,y) { if (True) then x else y } 6 | -------------------------------------------------------------------------------- /test/type/hm2.kk.out: -------------------------------------------------------------------------------- 1 | type/hm2/choose2: forall (x : a, y : a) -> a 2 | type/hm2/choose3: forall (x : a, y : a) -> a -------------------------------------------------------------------------------- /test/type/hm3.kk: -------------------------------------------------------------------------------- 1 | fun f(y) 2 | val h = fn(x) f(x) 3 | h(y) 4 | 5 | fun g(x) 6 | g(x) -------------------------------------------------------------------------------- /test/type/hm3.kk.out: -------------------------------------------------------------------------------- 1 | type/hm3/f: forall (y : a) -> div b 2 | type/hm3/g: forall (x : a) -> div b -------------------------------------------------------------------------------- /test/type/hr1a.kk: -------------------------------------------------------------------------------- 1 | fun xauto(f:forall a -> a) { 2 | f(f) 3 | } 4 | 5 | fun auto(f:forall a -> e a) : e (forall a -> e a) 6 | { 7 | f(f) 8 | } 9 | 10 | val ids = single(id:forall a -> a) //rigid annotation 11 | val test3 = ids.map(auto) 12 | -------------------------------------------------------------------------------- /test/type/hr1a.kk.out: -------------------------------------------------------------------------------- 1 | type/hr1a/auto: forall (f : forall (a) -> e a) -> e (forall (a) -> e a) 2 | type/hr1a/ids: list (a) -> a> 3 | type/hr1a/test3: list (a) -> a> 4 | type/hr1a/xauto: forall (f : forall (b) -> b) -> ((a) -> e a) -------------------------------------------------------------------------------- /test/type/hr2.kk: -------------------------------------------------------------------------------- 1 | fun runST( action : forall () -> ,exn> a ) : exn a { throw("runST") } 2 | 3 | fun ok() { 4 | runST( fn() { 1 } ) 5 | } -------------------------------------------------------------------------------- /test/type/hr2.kk.out: -------------------------------------------------------------------------------- 1 | type/hr2/ok : () -> exn int 2 | type/hr2/runST: forall (action : forall () -> ,exn> a) -> exn a -------------------------------------------------------------------------------- /test/type/hr3.kk: -------------------------------------------------------------------------------- 1 | val ids = [id : forall a -> a] 2 | 3 | fun test1() { 4 | (head(ids).unjust)(1) 5 | } -------------------------------------------------------------------------------- /test/type/hr3.kk.out: -------------------------------------------------------------------------------- 1 | type/hr3/ids: list (a) -> a> 2 | type/hr3/test1: () -> exn int -------------------------------------------------------------------------------- /test/type/hr3a.kk: -------------------------------------------------------------------------------- 1 | val ids = [id : forall a -> a] 2 | 3 | fun test1() { 4 | (head(ids).unjust)(1) 5 | } -------------------------------------------------------------------------------- /test/type/hr3a.kk.out: -------------------------------------------------------------------------------- 1 | type/hr3a/ids: list (a) -> a> 2 | type/hr3a/test1: () -> exn int -------------------------------------------------------------------------------- /test/type/hr3b.kk: -------------------------------------------------------------------------------- 1 | val ids = [id : forall a -> a] 2 | 3 | fun test1() { (ids.head.unjust)(1) } 4 | -------------------------------------------------------------------------------- /test/type/hr3b.kk.out: -------------------------------------------------------------------------------- 1 | type/hr3b/ids: list (a) -> a> 2 | type/hr3b/test1: () -> exn int -------------------------------------------------------------------------------- /test/type/hr3c.kk: -------------------------------------------------------------------------------- 1 | val ids = [id : forall a -> a] 2 | 3 | fun test1() { 4 | (head(ids).unjust)(1) 5 | } -------------------------------------------------------------------------------- /test/type/hr3c.kk.out: -------------------------------------------------------------------------------- 1 | type/hr3c/ids: list (a) -> a> 2 | type/hr3c/test1: () -> exn int -------------------------------------------------------------------------------- /test/type/hr6.kk: -------------------------------------------------------------------------------- 1 | fun g (x : (forall a -> a) -> int) { 2 | x(id) 3 | } 4 | 5 | fun f(x : int -> int) { 6 | x(1) 7 | } 8 | 9 | // val wrong = g(f) // invariant 10 | val ok = g( fn(x : forall a -> a) { f(x) } ) 11 | -------------------------------------------------------------------------------- /test/type/hr6.kk.out: -------------------------------------------------------------------------------- 1 | type/hr6/f : (x : (int) -> int) -> int 2 | type/hr6/g : (x : (forall (a) -> a) -> int) -> int 3 | type/hr6/ok: int -------------------------------------------------------------------------------- /test/type/hr7.kk: -------------------------------------------------------------------------------- 1 | // ,("(undefined :: some a. [a -> a] -> Int) (undefined :: some c. [(forall d. d -> c) -> c])", Wrong) 2 | 3 | fun ok() { 4 | (throw("hi") : some list (forall b -> b)> -> exn int)(throw("there") : some list<(forall d -> d) -> c>) 5 | } -------------------------------------------------------------------------------- /test/type/hr7.kk.out: -------------------------------------------------------------------------------- 1 | type/hr7/ok : () -> exn int -------------------------------------------------------------------------------- /test/type/import-alias.kk: -------------------------------------------------------------------------------- 1 | // https://github.com/koka-lang/koka/issues/705 2 | import foo = std/os/path 3 | 4 | fun main() 5 | println(path/cwd()) 6 | println(foo/cwd()) -------------------------------------------------------------------------------- /test/type/import-alias.kk.out: -------------------------------------------------------------------------------- 1 | type/import-alias/main: () -> io () -------------------------------------------------------------------------------- /test/type/masklocal2.kk.out: -------------------------------------------------------------------------------- 1 | type/masklocal2/emit: (s : string) -> emit () 2 | type/masklocal2/pretty-emit1: forall (action : () -> a) -> error 3 | type/masklocal2/pretty-emit2: forall (action : () -> a) -> e (a, string) 4 | type/masklocal2/pretty-emit3: forall (action : () -> a) -> e string -------------------------------------------------------------------------------- /test/type/match1.kk: -------------------------------------------------------------------------------- 1 | type test { 2 | Test(arg : a) 3 | } 4 | 5 | fun xtest( x : test ) : _ a { 6 | val (test,_) = (x,"hi") 7 | match(test) { 8 | Test(argx) -> { println("test"); argx } 9 | } 10 | } -------------------------------------------------------------------------------- /test/type/match1.kk.out: -------------------------------------------------------------------------------- 1 | type/match1/test/arg: forall (test : test) -> a 2 | type/match1/Test: forall (arg : a) -> test 3 | type/match1/xtest: forall (x : test) -> console a -------------------------------------------------------------------------------- /test/type/opt1.kk: -------------------------------------------------------------------------------- 1 | noinline fun plus(x:int,y:int,z:int=1) 2 | x+y+z 3 | 4 | pub fun main() 5 | [1,2,3].foldl(0,plus) 6 | -------------------------------------------------------------------------------- /test/type/opt1.kk.out: -------------------------------------------------------------------------------- 1 | type/opt1/main: () -> int 2 | type/opt1/plus: (x : int, y : int, z : ? int) -> int -------------------------------------------------------------------------------- /test/type/opt2.kk: -------------------------------------------------------------------------------- 1 | noinline fun plus(x:int, y:int, z:int=1) 2 | x+y+z 3 | 4 | fun psum( xs:list, ?plus) : int 5 | xs.foldl(0,plus) 6 | 7 | pub fun main() 8 | [1,2,3].psum(?plus=plus) 9 | -------------------------------------------------------------------------------- /test/type/opt2.kk.out: -------------------------------------------------------------------------------- 1 | type/opt2/main: () -> int 2 | type/opt2/plus: (x : int, y : int, z : ? int) -> int 3 | type/opt2/psum: forall (xs : list, ?plus : a) -> int -------------------------------------------------------------------------------- /test/type/pat1.kk: -------------------------------------------------------------------------------- 1 | fun test1(x) { 2 | match(x) { 3 | 1 -> "yes" 4 | _ -> "no" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/type/warn1.kk: -------------------------------------------------------------------------------- 1 | // test shadow warnings 2 | fun f(xs) { 3 | fun len(xs) { 4 | match(xs) { 5 | Cons(_,xx) -> len(xx) 6 | _ -> 0 7 | } 8 | } 9 | len(xs) 10 | } 11 | -------------------------------------------------------------------------------- /test/type/warn1.kk.out: -------------------------------------------------------------------------------- 1 | type/warn1/f: forall (xs : list) -> int 2 | test/type/warn1@kk(3,11): type warning: xs shadows an earlier local definition or parameter -------------------------------------------------------------------------------- /test/type/wrong/div1.kk: -------------------------------------------------------------------------------- 1 | val wrong : int = recursive() 2 | 3 | fun recursive() { 4 | recursive() 5 | return wrong 6 | } -------------------------------------------------------------------------------- /test/type/wrong/div1.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/div1@kk(1, 5): type error: value definition is recursive@ 2 | recursive group: [type/wrong/div1/recursive,type/wrong/div1/wrong] -------------------------------------------------------------------------------- /test/type/wrong/div2.kk: -------------------------------------------------------------------------------- 1 | val wrong : int = recursive() 2 | 3 | fun recursive(x) : div int { 4 | recursive(wrong) 5 | } -------------------------------------------------------------------------------- /test/type/wrong/div2.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/div2@kk(1,19): type error: function has not enough arguments 2 | context : recursive() 3 | term : recursive 4 | inferred type: (x : int) -> int -------------------------------------------------------------------------------- /test/type/wrong/div3.kk: -------------------------------------------------------------------------------- 1 | val wrong : int = recursive(1) 2 | 3 | fun recursive(x) { 4 | recursive(wrong) 5 | } -------------------------------------------------------------------------------- /test/type/wrong/div3.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/div3@kk(1, 5): type error: value definition is recursive@ 2 | recursive group: [type/wrong/div3/recursive,type/wrong/div3/wrong] -------------------------------------------------------------------------------- /test/type/wrong/higherrank1.kk: -------------------------------------------------------------------------------- 1 | fun choose(x,y) { 2 | if (True) then x else y 3 | } 4 | 5 | val ids = [id : forall a -> a] 6 | 7 | fun wrong(x) { 8 | choose(x,ids) 9 | } -------------------------------------------------------------------------------- /test/type/wrong/higherrank1.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/higherrank1@kk(7,11): type error: unannotated parameters cannot be polymorphic 2 | context : fun wrong(x) { 3 | choose(x,ids) 4 | } 5 | term : x 6 | inferred type: list (a) -> a> 7 | hint : annotate the parameter with a polymorphic type -------------------------------------------------------------------------------- /test/type/wrong/higherrank2.kk: -------------------------------------------------------------------------------- 1 | fun auto(f) { 2 | f(f) 3 | } -------------------------------------------------------------------------------- /test/type/wrong/higherrank2.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/higherrank2@kk(2, 5): type error: types do not match (due to an infinite type) 2 | context : f(f) 3 | term : f 4 | inferred type: (_a) -> _e _b 5 | expected type: _a 6 | hint : give a type to the function definition? -------------------------------------------------------------------------------- /test/type/wrong/higherrank3.kk: -------------------------------------------------------------------------------- 1 | fun auto(f : forall a -> a) { f(f) } 2 | 3 | fun wrong(f) { 4 | (auto(f), f(1), f(true)) 5 | } 6 | -------------------------------------------------------------------------------- /test/type/wrong/higherrank3.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/higherrank3@kk(4, 9): type error: type is not polymorphic enough 2 | context : auto(f) 3 | term : f 4 | inferred type : ($a) -> $a 5 | is less general than: forall (b) -> b 6 | hint : give a higher-rank type annotation to a function parameter? -------------------------------------------------------------------------------- /test/type/wrong/higherrank3a.kk: -------------------------------------------------------------------------------- 1 | fun auto(f : forall a -> a) { f(f) } 2 | 3 | fun wrong(f) { 4 | (f(1), f(True), auto(f)) 5 | } 6 | -------------------------------------------------------------------------------- /test/type/wrong/higherrank3a.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/higherrank3a@kk(4,12): type error: True does not match the argument types 2 | context : True 3 | term : True 4 | inferred type: bool 5 | expected type: int -------------------------------------------------------------------------------- /test/type/wrong/higherrank3v.kk: -------------------------------------------------------------------------------- 1 | fun auto(f : forall a -> a) { f(f) } 2 | 3 | fun wrong(f) { 4 | (auto(f)) 5 | } 6 | -------------------------------------------------------------------------------- /test/type/wrong/higherrank3v.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/higherrank3v@kk(4, 9): type error: type is not polymorphic enough 2 | context : auto(f) 3 | term : f 4 | inferred type : ($a) -> $a 5 | is less general than: forall (b) -> b 6 | hint : give a higher-rank type annotation to a function parameter? -------------------------------------------------------------------------------- /test/type/wrong/hm1.kk: -------------------------------------------------------------------------------- 1 | val wrong = if (True) then 1 else True 2 | -------------------------------------------------------------------------------- /test/type/wrong/hm1.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hm1@kk(1,35): type error: True does not match the argument types 2 | context : True 3 | term : True 4 | inferred type: bool 5 | expected type: int -------------------------------------------------------------------------------- /test/type/wrong/hm2.kk: -------------------------------------------------------------------------------- 1 | fun selfapp(x) { x(x) } 2 | -------------------------------------------------------------------------------- /test/type/wrong/hm2.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hm2@kk(1,20): type error: types do not match (due to an infinite type) 2 | context : x(x) 3 | term : x 4 | inferred type: (_a) -> _e _b 5 | expected type: _a 6 | hint : give a type to the function definition? -------------------------------------------------------------------------------- /test/type/wrong/hm3.kk: -------------------------------------------------------------------------------- 1 | fun wrong(f) { 2 | (f(1),f(True)) 3 | } 4 | -------------------------------------------------------------------------------- /test/type/wrong/hm3.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hm3@kk(2,11): type error: True does not match the argument types 2 | context : True 3 | term : True 4 | inferred type: bool 5 | expected type: int -------------------------------------------------------------------------------- /test/type/wrong/hm4.kk: -------------------------------------------------------------------------------- 1 | fun f( g : int -> int ) { } 2 | 3 | fun main() { 4 | f({}) 5 | } 6 | -------------------------------------------------------------------------------- /test/type/wrong/hm4.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hm4@kk(4, 5): type error: Unit does not match the argument types 2 | context : {} 3 | term : {} 4 | inferred type: () 5 | expected type: int -------------------------------------------------------------------------------- /test/type/wrong/hm4a.kk: -------------------------------------------------------------------------------- 1 | fun f( g : int -> int ) { } 2 | 3 | fun main() { 4 | f({1}) 5 | } 6 | -------------------------------------------------------------------------------- /test/type/wrong/hm4a.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hm4a@kk(4, 5): type error: types do not match 2 | context : f({1}) 3 | term : {1} 4 | inferred type: () -> int 5 | expected type: (int) -> int -------------------------------------------------------------------------------- /test/type/wrong/hr1.kk: -------------------------------------------------------------------------------- 1 | fun runST( action : forall () -> ,exn> a ) : exn a { 2 | throw("runST") 3 | } 4 | 5 | fun wrong() { 6 | val r = ref(1) 7 | runST( fn(){ !r } ) 8 | } 9 | 10 | fun main() { 11 | print("hi") 12 | } -------------------------------------------------------------------------------- /test/type/wrong/hr1.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hr1@kk(7,10): type error: abstract type(s) escape(s) into the context 2 | term : fn(){ !r } 3 | inferred type: () -> ,exn> int 4 | hint : give a higher-rank type annotation to a function parameter? -------------------------------------------------------------------------------- /test/type/wrong/hr2.kk: -------------------------------------------------------------------------------- 1 | fun auto(f:forall a -> e a) : e (forall a -> e a) { 2 | f(f) 3 | } 4 | 5 | fun wrong(f) { 6 | auto(f) 7 | } -------------------------------------------------------------------------------- /test/type/wrong/hr2.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hr2@kk(6, 8): type error: type is not polymorphic enough 2 | context : auto(f) 3 | term : f 4 | inferred type : ($a) -> _e $a 5 | is less general than: forall (b) -> _e b 6 | hint : give a higher-rank type annotation to a function parameter? -------------------------------------------------------------------------------- /test/type/wrong/hr3.kk: -------------------------------------------------------------------------------- 1 | fun poly(xs : list a -> a>) { 2 | 1 3 | } 4 | 5 | fun wrong(x) { 6 | poly(x) 7 | } -------------------------------------------------------------------------------- /test/type/wrong/hr3.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hr3@kk(5,11): type error: unannotated parameters cannot be polymorphic 2 | context : fun wrong(x) { 3 | poly(x) 4 | } 5 | term : x 6 | inferred type: list (a) -> a> 7 | hint : annotate the parameter with a polymorphic type -------------------------------------------------------------------------------- /test/type/wrong/hr4.kk: -------------------------------------------------------------------------------- 1 | fun wrong(x) { 2 | (x : list a -> a>) 3 | } -------------------------------------------------------------------------------- /test/type/wrong/hr4.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hr4@kk(1,11): type error: unannotated parameters cannot be polymorphic 2 | context : fun wrong(x) { 3 | (x : list a -> a>) 4 | } 5 | term : x 6 | inferred type: list (a) -> a> 7 | hint : annotate the parameter with a polymorphic type -------------------------------------------------------------------------------- /test/type/wrong/hr5.kk: -------------------------------------------------------------------------------- 1 | val ids = [id : forall a -> a] 2 | 3 | val ids2 = (ids : forall list b -> a>) -------------------------------------------------------------------------------- /test/type/wrong/hr5.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hr5@kk(3,13): type error: types do not match 2 | context : ids : forall list b -> a> 3 | term : ids 4 | inferred type: list (a) -> a> 5 | expected type: forall list (b) -> a> 6 | because : type cannot be instantiated to match the annotation -------------------------------------------------------------------------------- /test/type/wrong/hr6.kk: -------------------------------------------------------------------------------- 1 | fun g (x : (forall a -> a) -> int) { 2 | x(id) 3 | } 4 | 5 | fun f(x : int -> int) { 6 | x(1) 7 | } 8 | 9 | val wrong = g(f) // invariant 10 | -------------------------------------------------------------------------------- /test/type/wrong/hr6.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hr6@kk(9,15): type error: types do not match 2 | context : g(f) 3 | term : f 4 | inferred type: (x : (int) -> int) -> _e int 5 | expected type: (forall (a) -> a) -> int -------------------------------------------------------------------------------- /test/type/wrong/hr7.kk: -------------------------------------------------------------------------------- 1 | // ,("(undefined :: some a. [a -> a] -> Int) (undefined :: some c. [(forall d. d -> c) -> c])", Wrong) 2 | 3 | fun wrong() { 4 | (throw("hi") : some list a> -> int)(throw("there") : some list<(forall d -> c) -> c>) 5 | } -------------------------------------------------------------------------------- /test/type/wrong/hr7.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hr7@kk(4,47): type error: types do not match (due to an infinite type) 2 | context : @@@ d -> c) -> c> 3 | term : @@@ d -> c) -> c> 4 | inferred type: list<(forall (b) -> _a) -> _a> 5 | expected type: list<(_a) -> _a> 6 | because : type cannot be instantiated to match the annotation 7 | hint : give a type to the function definition? -------------------------------------------------------------------------------- /test/type/wrong/hr7a.kk: -------------------------------------------------------------------------------- 1 | // ,("(undefined :: some a. [a -> a] -> Int) (undefined :: some c. [(forall d. d -> c) -> c])", Wrong) 2 | 3 | fun wrong() { 4 | (throw("hi") : some list a> -> int)(throw("there") : list<(forall d -> d) -> (int -> int)>) 5 | } -------------------------------------------------------------------------------- /test/type/wrong/hr7a.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/hr7a@kk(4,47): type error: types do not match 2 | context : @@@ d -> d) -> (int -> int)> 3 | term : @@@ d -> d) -> (int -> int)> 4 | inferred type: list<(forall (a) -> a) -> ((int) -> int)> 5 | expected type: list<((int) -> int) -> ((int) -> int)> 6 | because : type cannot be instantiated to match the annotation -------------------------------------------------------------------------------- /test/type/wrong/local-shadow.kk: -------------------------------------------------------------------------------- 1 | struct address 2 | hostname: string 3 | port: int 4 | 5 | fun log-connect(address: address) 6 | val port = 80 // shadow of `port` accessor 7 | println("connecting to port " ++ address.port.show) 8 | -------------------------------------------------------------------------------- /test/type/wrong/local-shadow.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/local-shadow@kk(7,44): type error: only functions or types with a copy constructor can be applied 2 | context : address@port 3 | term : port 4 | inferred type: int 5 | hint : port at position (6, 7) might be shadowing another function -------------------------------------------------------------------------------- /test/type/wrong/open1.kk: -------------------------------------------------------------------------------- 1 | open type test { 2 | X 3 | } 4 | 5 | extend type test1 { 6 | Y 7 | } -------------------------------------------------------------------------------- /test/type/wrong/open1.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/open1@kk(5, 1): kind error: Type test1 is not defined 2 | hint: bind the variable using forall ? 3 | test/type/wrong/open1@kk(5, 1): kind error: Type test1 is not defined 4 | hint: bind the variable using forall ? -------------------------------------------------------------------------------- /test/type/wrong/open2.kk: -------------------------------------------------------------------------------- 1 | open type test { 2 | X( x : a ) 3 | } 4 | 5 | extend type test { 6 | Y 7 | } -------------------------------------------------------------------------------- /test/type/wrong/open2.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/open2@kk(5, 1): kind error: Invalid type 2 | type context : extend type test 3 | type : extend type test 4 | inferred kind: V -> V 5 | expected kind: V 6 | because : extended type must have the same kind as the open type -------------------------------------------------------------------------------- /test/type/wrong/open3.kk: -------------------------------------------------------------------------------- 1 | open type test { 2 | X 3 | } 4 | 5 | extend type test { 6 | X 7 | } -------------------------------------------------------------------------------- /test/type/wrong/open3.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/open3@kk(6, 3): kind error: Constructor type/wrong/open3/X is already defined at (2, 3) -------------------------------------------------------------------------------- /test/type/wrong/overlap1.kk: -------------------------------------------------------------------------------- 1 | // test overlap error 2 | fun f( x : int, y : int ) { x } 3 | fun f( x : int, y : int ) { x } 4 | 5 | -------------------------------------------------------------------------------- /test/type/wrong/overlap1.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/overlap1@kk(3, 5): type error: definition f is already defined in this module, at (2, 5) 2 | hint: use a local qualifier? -------------------------------------------------------------------------------- /test/type/wrong/overlap2.kk: -------------------------------------------------------------------------------- 1 | // test overlap error 2 | fun g( x : int ) { x } 3 | fun g(x) { x } 4 | -------------------------------------------------------------------------------- /test/type/wrong/overlap2.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/overlap2@kk(3, 5): type error: definition g is already defined in this module, at (2, 5) 2 | hint: use a local qualifier? -------------------------------------------------------------------------------- /test/type/wrong/overlap3.kk: -------------------------------------------------------------------------------- 1 | // test overlap error 2 | val x = 1 3 | val x = True 4 | -------------------------------------------------------------------------------- /test/type/wrong/overlap3.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/overlap3@kk(3, 5): type error: definition x is already defined in this module, at (2, 5) 2 | hint: use a local qualifier? -------------------------------------------------------------------------------- /test/type/wrong/pat1.kk: -------------------------------------------------------------------------------- 1 | 2 | fun wrong(x : a) : string { 3 | match(x) { 4 | 1 -> "yes" 5 | _ -> "no" 6 | } 7 | } -------------------------------------------------------------------------------- /test/type/wrong/scheduler1.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/scheduler1@kk(18, 7): type error: effects do not match 2 | context : q 3 | term : q 4 | inferred effect: |_e> 5 | expected effect: total 6 | because : Polymorphic values cannot have an effect -------------------------------------------------------------------------------- /test/type/wrong/scheduler5.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/scheduler5@kk(40, 9): type error: effects do not match 2 | context : spawn(f) 3 | term : f 4 | inferred effect: |$e> 5 | expected effect: ,process,read,write,exn> -------------------------------------------------------------------------------- /test/type/wrong/st1.kk: -------------------------------------------------------------------------------- 1 | val r = ref([]) 2 | 3 | fun wrong() { 4 | r := [1] 5 | if ((!r).head) then 1 else 0 6 | } -------------------------------------------------------------------------------- /test/type/wrong/st1.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/st1@kk(1, 9): type error: effects do not match 2 | context : ref([]) 3 | term : ref 4 | inferred effect: |_e> 5 | expected effect: total 6 | because : Generalized values cannot have an effect -------------------------------------------------------------------------------- /test/type/wrong/val1.kk: -------------------------------------------------------------------------------- 1 | pub fun main() 2 | val r : forall ref> = ref([]) 3 | r := [1] 4 | println( if (!r).head.default(True) then "true" else "false" ) 5 | -------------------------------------------------------------------------------- /test/type/wrong/val1.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/val1@kk(2, 7): type error: effects do not match 2 | context : r 3 | term : r 4 | inferred effect: |_e> 5 | expected effect: total 6 | because : Polymorphic values cannot have an effect -------------------------------------------------------------------------------- /test/type/wrong/val1a.kk: -------------------------------------------------------------------------------- 1 | pub fun main() 2 | val r = ref([]) 3 | r := [1] 4 | println( if (!r).head.default(True) then "true" else "false" ) 5 | -------------------------------------------------------------------------------- /test/type/wrong/val1a.kk.out: -------------------------------------------------------------------------------- 1 | test/type/wrong/val1a@kk(4,33): type error: True does not match the argument types 2 | context : True 3 | term : True 4 | inferred type: bool 5 | expected type: int -------------------------------------------------------------------------------- /test/type/wrong/var1.kk: -------------------------------------------------------------------------------- 1 | fun escape() { 2 | var i := 1 3 | fn(){ i := i + 1; i } 4 | } 5 | 6 | fun main() { 7 | val f = escape() 8 | f().println 9 | f().println 10 | } --------------------------------------------------------------------------------