Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: koka-lang/koka
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8c2d1a224cef9bbc88acd21288cdb4cda7d614e0
Choose a base ref
..
head repository: koka-lang/koka
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c7258ce3c330d34022c89ed9470ca81eb9043a91
Choose a head ref
Showing with 1,240 additions and 1,177 deletions.
  1. +4 −0 doc/spec/news.mdk
  2. +1 −1 kklib/mimalloc
  3. +16 −16 kklib/src/init.c
  4. +2 −2 koka.cabal
  5. +21 −14 lib/std/core.kk
  6. +3 −2 lib/std/core/debug.kk
  7. +113 −82 lib/std/core/hnd.kk
  8. +4 −4 lib/std/core/inline/console.js
  9. +100 −85 lib/std/core/inline/hnd.c
  10. +24 −29 lib/std/core/inline/hnd.h
  11. +31 −42 lib/std/core/inline/hnd.js
  12. +1 −1 lib/std/core/int.kk
  13. +25 −14 lib/std/core/sslice.kk
  14. +11 −4 lib/std/core/types.kk
  15. +26 −1 lib/std/core/unsafe.kk
  16. +27 −8 lib/std/num/int32.kk
  17. +12 −4 lib/std/num/int64.kk
  18. +1 −1 lib/std/num/random.kk
  19. +2 −2 package.yaml
  20. +4 −1 readme.md
  21. +8 −2 samples/all.kk
  22. +32 −0 samples/handlers/named/ask-poly.kk
  23. +6 −7 samples/handlers/named/ask.kk
  24. +14 −19 samples/handlers/named/file-scoped.kk
  25. +9 −10 samples/handlers/named/file.kk
  26. +3 −3 samples/handlers/named/heap.kk
  27. +24 −24 samples/handlers/named/unify.kk
  28. +2 −0 samples/syntax/implicits.kk
  29. +2 −1 src/Backend/C/FromCore.hs
  30. +28 −28 src/Backend/C/Parc.hs
  31. +1 −1 src/Backend/C/ParcReuse.hs
  32. +7 −4 src/Common/Name.hs
  33. +16 −6 src/Common/NamePrim.hs
  34. +19 −3 src/Common/Syntax.hs
  35. +7 −3 src/Compile/Build.hs
  36. +3 −3 src/Compile/BuildContext.hs
  37. +3 −1 src/Compile/CodeGen.hs
  38. +6 −5 src/Compile/Options.hs
  39. +2 −2 src/Core/Core.hs
  40. +3 −3 src/Core/OpenResolve.hs
  41. +26 −15 src/Core/Parse.hs
  42. +2 −1 src/Core/Simplify.hs
  43. +13 −13 src/Core/Unroll.hs
  44. +2 −2 src/Interpreter/Interpret.hs
  45. +59 −27 src/Kind/Infer.hs
  46. +16 −2 src/Kind/InferKind.hs
  47. +1 −1 src/Kind/InferMonad.hs
  48. +26 −10 src/Kind/Kind.hs
  49. +28 −28 src/Kind/Repr.hs
  50. +2 −2 src/Static/BindingGroups.hs
  51. +4 −3 src/Syntax/GenDoc.hs
  52. +91 −63 src/Syntax/Parse.hs
  53. +1 −0 src/Syntax/Syntax.hs
  54. +30 −20 src/Type/Infer.hs
  55. +14 −13 src/Type/InferMonad.hs
  56. +47 −35 src/Type/Kind.hs
  57. +8 −8 src/Type/Operations.hs
  58. +11 −6 src/Type/Pretty.hs
  59. +43 −16 src/Type/Type.hs
  60. +64 −34 src/Type/TypeVar.hs
  61. +6 −5 src/Type/Unify.hs
  62. +2 −2 support/vscode/koka.language-koka/package.json
  63. +3 −1 test/Spec.hs
  64. +0 −1 test/algeff/eff-rec2.kk.out
  65. +0 −1 test/algeff/effs1.kk.out
  66. +0 −2 test/algeff/effs1a.kk.out
  67. +0 −1 test/algeff/effs1b.kk.out
  68. +0 −2 test/algeff/effs2.kk.out
  69. +0 −1 test/algeff/effs3.kk.out
  70. +0 −1 test/algeff/effs3b.kk.out
  71. +0 −2 test/algeff/effs3c.kk.out
  72. +0 −1 test/algeff/effs4.kk.out
  73. +0 −2 test/algeff/effs5.kk.out
  74. +2 −2 test/algeff/exn1.kk
  75. +0 −2 test/algeff/exn1.kk.out
  76. +0 −2 test/algeff/exn2.kk.out
  77. +0 −3 test/algeff/expr.kk.out
  78. +0 −11 test/algeff/implicits.kk.out
  79. +0 −1 test/algeff/linear1.kk.out
  80. +0 −1 test/algeff/linear2.kk.out
  81. +0 −1 test/algeff/linear3.kk.out
  82. +0 −1 test/algeff/match-error.kk.out
  83. +1 −1 test/algeff/nim.kk
  84. +1 −5 test/algeff/nim.kk.out
  85. +0 −271 test/algeff/nim1.kk
  86. +0 −2 test/algeff/noyield1.kk.out
  87. +0 −2 test/algeff/noyield2.kk.out
  88. +0 −2 test/algeff/parser.kk.out
  89. +10 −12 test/algeff/perf1e.kk
  90. +7 −7 test/algeff/perf2.kk
  91. +0 −1 test/algeff/perf2.kk.out
  92. +0 −1 test/algeff/rcontrol1.kk.out
  93. +1 −5 test/algeff/scoped.kk.out
  94. +2 −4 test/algeff/scoped2.kk.out
  95. +0 −2 test/algeff/shallow1.kk.out
  96. +0 −2 test/algeff/wrong/ops2.kk.out
  97. +2 −2 test/algeff/wrong/scoped1.kk.out
  98. +2 −2 test/cgen/ctail10.kk
  99. +1 −1 test/cgen/ctail9.kk
  100. +2 −2 test/cgen/inline4.kk
  101. +0 −1 test/finally/finally2.kk.out
  102. +0 −2 test/finally/finally2a.kk.out
  103. +0 −2 test/finally/finally2b.kk.out
  104. +0 −1 test/finally/finally3.kk.out
  105. +0 −2 test/finally/finally3a.kk.out
  106. +0 −2 test/finally/finally3b.kk.out
  107. +0 −1 test/finally/initially2.kk.out
  108. +0 −2 test/finally/initially2a.kk.out
  109. +0 −2 test/finally/initially2b.kk.out
  110. +8 −8 test/fip/src/ftree/ftree-fip.kk
  111. +1 −1 test/fip/src/ftree/ftree-std.kk
  112. +3 −3 test/fip/src/msort/msort-fip.kk
  113. +2 −2 test/fip/src/msort/msort-std.kk
  114. +2 −2 test/fip/src/qsort/qsort-fip.kk
  115. +3 −3 test/fip/src/qsort/qsort-std.kk
  116. +5 −5 test/fip/src/rbtree/rbtree-fip-clrs.kk
  117. +3 −3 test/fip/src/rbtree/rbtree-fip-icfp.kk
  118. +4 −4 test/fip/src/rbtree/rbtree-fip.kk
  119. +5 −5 test/fip/src/rbtree/rbtree-std.kk
  120. +2 −2 test/fip/src/tmap/tmap-fip.kk
  121. +2 −2 test/fip/src/tmap/tmap-std.kk
  122. +21 −1 test/lib/slice.kk
  123. +14 −1 test/lib/slice.kk.out
  124. +1 −2 test/mask/inject-behind1.kk.out
  125. +0 −1 test/mask/inject4.kk.out
  126. +0 −1 test/mask/inject4a.kk.out
  127. +0 −1 test/syntax/run/pattern_match_in_param.kk
  128. +1 −1 util/bundle.kk
  129. +1 −1 util/install.bat
  130. +1 −1 util/install.sh
  131. +1 −1 util/minbuild.sh
  132. +7 −4 whatsnew.md
4 changes: 4 additions & 0 deletions doc/spec/news.mdk
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
~ begin news
News:

* 2024-02-14: Koka v3.1.0 released with a concurrent build system
and improved language service over the stdio protocol. Redesign of named effect
typing to match the formal system more closely. See `samples/handlers/named` for examples.

* 2024-01-25: Koka v3.0.4 released with improved VS Code hover and inlay information.
Splits `std/core` in multiple modules, fixes bug in infinite expansion for implicits
and various other small improvements.
2 changes: 1 addition & 1 deletion kklib/mimalloc
Submodule mimalloc updated 207 files
32 changes: 16 additions & 16 deletions kklib/src/init.c
Original file line number Diff line number Diff line change
@@ -174,26 +174,26 @@ static void kklib_init(void) {
if (process_initialized) return;
process_initialized = true;
// for Koka, we need to be fully deterministic and careful when using C functionality that depends on global variables
setlocale(LC_ALL, "C.utf8");
setlocale(LC_ALL, "C.utf8");
#if defined(WIN32) && (defined(_CONSOLE) || defined(__MINGW32__))
SetConsoleOutputCP(65001); // set the console to utf-8 instead of OEM page
#endif
kk_cpu_init();
atexit(&kklib_done);
atexit(&kklib_done);

#if KK_USE_MEM_ARENA
#if (KK_INTB_SIZE==4)
const kk_ssize_t heap_size = kk_shlp(KK_IZ(1), KK_INTB_BITS + KK_BOX_PTR_SHIFT); // 16GiB
#elif KK_CHERI && (KK_INTB_SIZE==8)
const kk_ssize_t heap_size = 128 * KK_GiB; // todo: parameterize?
#else
#else
#error "define heap initialization for compressed pointers on this platform"
#endif
int err = mi_reserve_os_memory_ex(heap_size, false /* commit */, true /* allow large */, true /*exclusive*/, &arena);
if (err != 0) {
kk_fatal_error(err, "unable to reserve the initial heap of %zi bytes", heap_size);
}
arena_start = mi_arena_area(arena, &arena_size);
arena_start = mi_arena_area(arena, &arena_size);
#endif
}

@@ -209,7 +209,7 @@ bool kk_has_bmi1 = false;
bool kk_has_bmi2 = false;
bool kk_has_clmul = false;

#if defined(__GNUC__)
#if defined(__GNUC__)
#include <cpuid.h>

static inline bool kk_cpuid(uint32_t* regs4, uint32_t level) {
@@ -234,7 +234,7 @@ static inline int kk_cpuid(uint32_t* regs4, uint32_t level) {

#endif

static void kk_cpu_init(void)
static void kk_cpu_init(void)
{
//todo: do we need to set the IEEE floating point flags?
//fexcept_t fexn;
@@ -266,24 +266,24 @@ static void kk_cpu_init(void)
// The thread local context; usually passed explicitly for efficiency.
static kk_decl_thread kk_context_t* context;

static struct { kk_block_t _block; kk_integer_t cfc; } kk_evv_empty_static = {
{ KK_HEADER_STATIC(1,KK_TAG_EVV_VECTOR) }, { ((~KK_UB(0))^0x02) /*==-1 smallint*/}
static struct { kk_block_t _block; /* kk_integer_t cfc; */ } kk_evv_empty_static = {
{ KK_HEADER_STATIC(0,KK_TAG_EVV_VECTOR) } // , { ((~KK_UB(0))^0x02) /*==-1 smallint*/}
};

struct kk_evv_s {
kk_block_t _block;
kk_integer_t cfc;
// kk_integer_t cfc;
};

kk_datatype_ptr_t kk_evv_empty_singleton(kk_context_t* ctx) {
static struct kk_evv_s* evv = NULL;
if (evv == NULL) {
evv = kk_block_alloc_as(struct kk_evv_s, 1, KK_TAG_EVV_VECTOR, ctx);
evv->cfc = kk_integer_from_small(-1);
evv = kk_block_alloc_as(struct kk_evv_s, 0, KK_TAG_EVV_VECTOR, ctx);
// evv->cfc = kk_integer_from_small(-1);
}
kk_base_type_dup_as(struct kk_evv_s*, evv);
return kk_datatype_from_base(evv, ctx);
}
}


// Get the thread local context (also initializes on demand)
@@ -314,7 +314,7 @@ kk_context_t* kk_get_context(void) {
ctx->thread_id = (size_t)(&context);
ctx->unique = kk_integer_one;
context = ctx;
struct kk_box_any_s* boxany = kk_block_alloc_as(struct kk_box_any_s, 0, KK_TAG_BOX_ANY, ctx);
struct kk_box_any_s* boxany = kk_block_alloc_as(struct kk_box_any_s, 0, KK_TAG_BOX_ANY, ctx);
boxany->_unused = kk_integer_zero;
ctx->kk_box_any = kk_datatype_from_base(boxany, ctx);
ctx->evv = kk_evv_empty_singleton(ctx);
@@ -379,9 +379,9 @@ kk_decl_export void kk_main_end(kk_context_t* ctx) {
size_t page_reclaim;
size_t peak_commit;
kk_process_info(&user_time, &sys_time, &peak_rss, &page_faults, &page_reclaim, &peak_commit);
kk_info_message("elapsed: %" PRId64 ".%03lds, user: %ld.%03lds, sys : %ld.%03lds, rss : %lu%s\n",
wall_time.seconds, (long)(wall_time.attoseconds / (KK_I64(1000000) * KK_I64(1000000000))),
user_time/1000, user_time%1000, sys_time/1000, sys_time%1000,
kk_info_message("elapsed: %" PRId64 ".%03lds, user: %ld.%03lds, sys : %ld.%03lds, rss : %lu%s\n",
wall_time.seconds, (long)(wall_time.attoseconds / (KK_I64(1000000) * KK_I64(1000000000))),
user_time/1000, user_time%1000, sys_time/1000, sys_time%1000,
(peak_rss > 10*1024*1024 ? peak_rss/(1024*1024) : peak_rss/1024),
(peak_rss > 10*1024*1024 ? "mb" : "kb") );
}
4 changes: 2 additions & 2 deletions koka.cabal
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: koka
version: 3.0.5
version: 3.1.1
description: Please see the README on GitHub at <https://github.com/koka-lang/koka#readme>
homepage: https://github.com/koka-lang/koka#readme
bug-reports: https://github.com/koka-lang/koka/issues
@@ -138,7 +138,7 @@ library
CPP
OverloadedStrings
ghc-options: -j8 -O2
cpp-options: -DKOKA_MAIN="koka" -DKOKA_VARIANT="release" -DKOKA_VERSION="3.0.5" -DREADLINE=0
cpp-options: -DKOKA_MAIN="koka" -DKOKA_VARIANT="release" -DKOKA_VERSION="3.1.1" -DREADLINE=0
include-dirs:
src/Platform/cpp/Platform
c-sources:
35 changes: 21 additions & 14 deletions lib/std/core.kk
Original file line number Diff line number Diff line change
@@ -127,10 +127,6 @@ pub fun repeat( ^n : int, action : () -> e () ) : e ()
for(n) fn(i)
action()

// Executes `action` `n` times for each integer from `0` to `n-1`.
// If `n <= 0` the function returns without any call to `action` .
pub fun for( ^n : int, action : (int) -> e () ) : e ()
for(0, n - 1, action)

// Executes `action` for each integer from `start` to `end` (including `end` ).
// If `start > end` the function returns without any call to `action` .
@@ -141,12 +137,11 @@ pub fun range/for( ^start: int, end : int, action : (int) -> e () ) : e ()
rep(pretend-decreasing(i.inc))
rep(start)

// Executes `action` `n` times for each integer from `0` to `n-1`.
// If `n <= 0` the function returns without any call to `action` .
pub fun for( ^n : int, action : (int) -> e () ) : e ()
range/for(0, n - 1, action)

// Executes `action` for each integer between `start` to `end` (including `end` ).
// If `start > end` the function returns without any call to `action` .
// If `action` returns `Just`, the iteration is stopped and the result returned
pub fun for-while( n : int, action : (int) -> e maybe<a> ) : e maybe<a>
for-while(0, n - 1, action)

// Executes `action` for each integer between `start` to `end` (including `end` ).
// If `start > end` the function returns without any call to `action` .
@@ -160,23 +155,35 @@ pub fun range/for-while( start: int, end : int, action : (int) -> e maybe<a> ) :
else Nothing
rep(start)

// Executes `action` for each integer between [0,`n`) (excluding `n` ).
// If `n <= 0` the function returns without any call to `action` .
// If `action` returns `Just`, the iteration is stopped and the result returned
pub fun for-while( n : int, action : (int) -> e maybe<a> ) : e maybe<a>
range/for-while(0, n - 1, action)


// Fold over the integers between [`start`,`end`] (including `end`).
pub fun range/fold( start : int, end : int, init : a, f : (int,a) -> e a ) : e a
if start >= end then init else
if start > end then init else
val x = f(start,init)
fold(pretend-decreasing(start.inc), end, x, f)

// Fold over the integers between [0,`upto`) (excluding `upto`).
pub fun fold( upto : int, init : a, f : (int,a) -> e a ) : e a
fold( 0, upto.dec, init, f )
range/fold( 0, upto.dec, init, f )

// Fold over the integers between [`start``,`end`] (including `end`) or until `f` returns `Nothing`

// Fold over the integers between [`start`,`end`] (including `end`) or until `f` returns `Nothing`
pub fun range/fold-while( start : int, end : int, init : a, f : (int,a) -> e maybe<a> ) : e a
if start >= end then init else
if start > end then init else
match f(start,init)
Just(x) -> fold-while(pretend-decreasing(start.inc), end, x, f)
Just(x) -> range/fold-while(pretend-decreasing(start.inc), end, x, f)
Nothing -> init

// Fold over the integers between [0,`n`) (excluding `n`) or until `f` returns `Nothing`
pub fun fold-while( n : int, init : a, f : (int,a) -> e maybe<a> ) : e a
range/fold-while( 0, n.dec, init, f )


// ----------------------------------------------------------------------------
// Generic equality and comparison
5 changes: 3 additions & 2 deletions lib/std/core/debug.kk
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import std/core/types
import std/core/unsafe
import std/core/hnd
import std/core/string
import std/core/console

extern import
c file "inline/debug.c"
@@ -40,12 +41,12 @@ pub fun file/kk-file-line( ?kk-file, ?kk-line )
extern xtrace : ( message : string ) -> ()
c "kk_trace"
cs "Primitive.Trace"
js "_trace"
js "$std_core_console._trace"

extern xtrace-any : forall<a> ( message: string, x : a ) -> ()
c "kk_trace_any"
cs "Primitive.TraceAny"
js "_trace_any"
js "$std_core_console._trace_any"

val trace-enabled : ref<global,bool> = unsafe-total{ ref(True) }

Loading