@effekt-lang/effekt 0.63.0 → 0.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/effekt CHANGED
Binary file
@@ -47,6 +47,7 @@
47
47
  [r (diff-ref realDiff)]
48
48
  [oldValue (ref-value r)])
49
49
  (ref-value-set! r (diff-value realDiff))
50
+ (ref-generation-set! r (diff-generation realDiff))
50
51
  (set-box! n (make-diff r oldValue (ref-generation r) currentDiff))
51
52
  (applyDiffs currentDiff (cdr diffs)))]))
52
53
 
@@ -60,7 +61,8 @@
60
61
  [store (snap-store snap)]
61
62
  [storeRoot (store-root store)])
62
63
  (reroot snapRoot storeRoot)
63
- (store-root-set! store snapRoot)))
64
+ (store-root-set! store snapRoot)
65
+ (store-generation-set! store (+ (snap-generation snap) 1))))
64
66
 
65
67
  ; Cont a = a, MetaCont -> #
66
68
  ; Prompt = Int
@@ -141,14 +141,14 @@ extern def show[R](value: R) at {}: String =
141
141
 
142
142
  // Strings
143
143
  // =======
144
- extern def infixConcat(s1: String, s2: String) at {}: String =
144
+ extern def infixPlusPlus(s1: String, s2: String) at {}: String =
145
145
  js "${s1} + ${s2}"
146
146
  chez "(string-append ${s1} ${s2})"
147
147
  llvm """
148
148
  %spz = call %Pos @c_bytearray_concatenate(%Pos ${s1}, %Pos ${s2})
149
149
  ret %Pos %spz
150
150
  """
151
- vm "effekt::infixConcat(String, String)"
151
+ vm "effekt::infixPlusPlus(String, String)"
152
152
 
153
153
  extern def length(str: String) at {}: Int =
154
154
  js "${str}.length"
@@ -345,29 +345,29 @@ extern def infixNeq(x: Byte, y: Byte) at {}: Bool =
345
345
 
346
346
  // Math ops
347
347
  // ========
348
- extern def infixAdd(x: Int, y: Int) at {}: Int =
348
+ extern def infixPlus(x: Int, y: Int) at {}: Int =
349
349
  js "(${x} + ${y})"
350
350
  chez "(+ ${x} ${y})"
351
351
  llvm "%z = add %Int ${x}, ${y} ret %Int %z"
352
- vm "effekt::infixAdd(Int, Int)"
352
+ vm "effekt::infixPlus(Int, Int)"
353
353
 
354
- extern def infixMul(x: Int, y: Int) at {}: Int =
354
+ extern def infixStar(x: Int, y: Int) at {}: Int =
355
355
  js "(${x} * ${y})"
356
356
  chez "(* ${x} ${y})"
357
357
  llvm "%z = mul %Int ${x}, ${y} ret %Int %z"
358
- vm "effekt::infixMul(Int, Int)"
358
+ vm "effekt::infixStar(Int, Int)"
359
359
 
360
- extern def infixDiv(x: Int, y: Int) at {}: Int =
360
+ extern def infixSlash(x: Int, y: Int) at {}: Int =
361
361
  js "Math.floor(${x} / ${y})"
362
362
  chez "(floor (/ ${x} ${y}))"
363
363
  llvm "%z = sdiv %Int ${x}, ${y} ret %Int %z"
364
- vm "effekt::infixDiv(Int, Int)"
364
+ vm "effekt::infixSlash(Int, Int)"
365
365
 
366
- extern def infixSub(x: Int, y: Int) at {}: Int =
366
+ extern def infixMinus(x: Int, y: Int) at {}: Int =
367
367
  js "(${x} - ${y})"
368
368
  chez "(- ${x} ${y})"
369
369
  llvm "%z = sub %Int ${x}, ${y} ret %Int %z"
370
- vm "effekt::infixSub(Int, Int)"
370
+ vm "effekt::infixMinus(Int, Int)"
371
371
 
372
372
  extern def mod(x: Int, y: Int) at {}: Int =
373
373
  js "(${x} % ${y})"
@@ -375,29 +375,29 @@ extern def mod(x: Int, y: Int) at {}: Int =
375
375
  llvm "%z = srem %Int ${x}, ${y} ret %Int %z"
376
376
  vm "effekt::mod(Int, Int)"
377
377
 
378
- extern def infixAdd(x: Double, y: Double) at {}: Double =
378
+ extern def infixPlus(x: Double, y: Double) at {}: Double =
379
379
  js "(${x} + ${y})"
380
380
  chez "(+ ${x} ${y})"
381
381
  llvm "%z = fadd %Double ${x}, ${y} ret %Double %z"
382
- vm "effekt::infixAdd(Double, Double)"
382
+ vm "effekt::infixPlus(Double, Double)"
383
383
 
384
- extern def infixMul(x: Double, y: Double) at {}: Double =
384
+ extern def infixStar(x: Double, y: Double) at {}: Double =
385
385
  js "(${x} * ${y})"
386
386
  chez "(* ${x} ${y})"
387
387
  llvm "%z = fmul %Double ${x}, ${y} ret %Double %z"
388
- vm "effekt::infixMul(Double, Double)"
388
+ vm "effekt::infixStar(Double, Double)"
389
389
 
390
- extern def infixSub(x: Double, y: Double) at {}: Double =
390
+ extern def infixMinus(x: Double, y: Double) at {}: Double =
391
391
  js "(${x} - ${y})"
392
392
  chez "(- ${x} ${y})"
393
393
  llvm "%z = fsub %Double ${x}, ${y} ret %Double %z"
394
- vm "effekt::infixSub(Double, Double)"
394
+ vm "effekt::infixMinus(Double, Double)"
395
395
 
396
- extern def infixDiv(x: Double, y: Double) at {}: Double =
396
+ extern def infixSlash(x: Double, y: Double) at {}: Double =
397
397
  js "(${x} / ${y})"
398
398
  chez "(fl/ ${x} ${y})"
399
399
  llvm "%z = fdiv %Double ${x}, ${y} ret %Double %z"
400
- vm "effekt::infixDiv(Double, Double)"
400
+ vm "effekt::infixSlash(Double, Double)"
401
401
 
402
402
  extern def cos(x: Double) at {}: Double =
403
403
  js "Math.cos(${x})"
@@ -661,10 +661,10 @@ extern def not(b: Bool) at {}: Bool =
661
661
  """
662
662
  vm "effekt::not(Bool)"
663
663
 
664
- def infixOr { first: => Bool } { second: => Bool }: Bool =
664
+ def infixBarBar { first: => Bool } { second: => Bool }: Bool =
665
665
  if (first()) true else second()
666
666
 
667
- def infixAnd { first: => Bool } { second: => Bool }: Bool =
667
+ def infixAmpAmp { first: => Bool } { second: => Bool }: Bool =
668
668
  if (first()) second() else false
669
669
 
670
670
 
@@ -419,6 +419,18 @@ def reverseOnto[A](l: List[A], other: List[A]): List[A] =
419
419
  def append[A](l: List[A], other: List[A]): List[A] =
420
420
  l.reverse.reverseOnto(other)
421
421
 
422
+ /// `l ++ other` is an alias for `l.append(other)`.
423
+ ///
424
+ /// Example:
425
+ /// ```
426
+ /// > [1, 2, 3] ++ [4, 5, 6]
427
+ /// [1, 2, 3, 4, 5, 6]
428
+ /// ```
429
+ ///
430
+ /// O(N)
431
+ def infixPlusPlus[A](l: List[A], other: List[A]): List[A] =
432
+ append(l, other)
433
+
422
434
  /// Flatten a list of lists into a single list.
423
435
  ///
424
436
  /// Examples:
@@ -43,7 +43,7 @@ extern def unsafeAllocate[T]() at global: Ref[T] =
43
43
  store i64 0, ptr %ref, align 8
44
44
  store ptr @c_ref_erase_field, ptr %refEraser, align 8
45
45
  store i64 0, ptr %fieldTag, align 8
46
- store ptr null, ptr %fieldData_pointer, align 8
46
+ store ptr null, ptr %fieldData_pointer, align 8
47
47
 
48
48
  %refWrap = insertvalue %Pos { i64 0, ptr poison }, ptr %ref, 1
49
49
  ret %Pos %refWrap
@@ -99,7 +99,7 @@ extern def set[T](ref: Ref[T], value: T) at global: Unit =
99
99
 
100
100
  tail call void @erasePositive(%Pos %field)
101
101
  store %Pos ${value}, ptr %field_pointer
102
- tail call void @erasePositive(%Pos ${ref})
102
+ tail call void @erasePositive(%Pos ${ref})
103
103
 
104
104
  ret %Pos zeroinitializer
105
105
  """
@@ -107,4 +107,8 @@ extern def set[T](ref: Ref[T], value: T) at global: Unit =
107
107
 
108
108
  /// Modifies the inner contents of the `ref` with a function `f`
109
109
  def map[T](ref: Ref[T]) { f: T => T }: Unit =
110
- ref.set(f(ref.get))
110
+ ref.set(f(ref.get))
111
+
112
+ /// `r := v` serves as an alias for `r.set(v)`
113
+ def infixColonEq[T](ref: Ref[T], v: T): Unit =
114
+ ref.set(v)
@@ -6,6 +6,9 @@
6
6
  // restore: O(|write operations since capture|)
7
7
  const Mem = null
8
8
 
9
+ // reusable buffer for rerooting
10
+ const _rerootPath = []
11
+
9
12
  function Arena() {
10
13
  const s = {
11
14
  root: { value: Mem },
@@ -46,25 +49,36 @@ function snapshot(s) {
46
49
  return snap
47
50
  }
48
51
 
49
- function reroot(n) {
50
- if (n.value === Mem) return;
51
-
52
- const diff = n.value
53
- const r = diff.ref
54
- const v = diff.value
55
- const g = diff.generation
56
- const n2 = diff.root
57
- reroot(n2)
58
- n.value = Mem
59
- n2.value = { ref: r, value: r.value, generation: r.generation, root: n}
60
- r.value = v
61
- r.generation = g
52
+ function reroot(target) {
53
+ // 1. Walk from target toward the Mem node, collecting the path into `_rerootPath`
54
+ _rerootPath.length = 0
55
+ let cur = target
56
+ while (cur.value !== Mem) {
57
+ _rerootPath.push(cur)
58
+ cur = cur.value.root
59
+ }
60
+ // cur is now Mem (the current root)
61
+
62
+ // 2. Walk back from current root toward target,
63
+ // reverse each edge, restore each ref.
64
+ for (let i = _rerootPath.length - 1; i >= 0; i--) {
65
+ const node = _rerootPath[i]
66
+ const diff = node.value // forward diff
67
+ const r = diff.ref
68
+ cur.value = { ref: r, value: r.value, generation: r.generation, root: node }
69
+ r.value = diff.value // restore ref's old value
70
+ r.generation = diff.generation // ... and old generation
71
+ node.value = Mem
72
+ cur = node
73
+ }
62
74
  }
63
75
 
64
76
  function restore(store, snap) {
65
- // linear in the number of modifications...
66
- reroot(snap.root)
67
- store.root = snap.root
77
+ if (snap.root.value !== Mem) {
78
+ // fast path: continuation is resumed immediately with no writes in between
79
+ reroot(snap.root)
80
+ store.root = snap.root
81
+ }
68
82
  store.generation = snap.generation + 1
69
83
  }
70
84
 
@@ -1,5 +1,5 @@
1
1
  <!doctype html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><title>Eclipse Public License 2.0 (EPL) | The Eclipse Foundation</title>
2
- <meta property="og:title" content="Eclipse Public License 2.0 (EPL) | The Eclipse Foundation"><meta name=twitter:title content="Eclipse Public License 2.0 (EPL) | The Eclipse Foundation"><meta name=description content="The Eclipse Foundation provides our global community of individuals and organisations with a mature, scalable, and business-friendly environment for open source …"><meta property="og:description" content="The Eclipse Foundation provides our global community of individuals and organisations with a mature, scalable, and business-friendly environment for open source …"><meta name=twitter:description content="The Eclipse Foundation provides our global community of individuals and organisations with a mature, scalable, and business-friendly environment for open source …"><meta name=author content="Wayne Beaton"><link href=/favicon.ico rel=icon type=image/x-icon><meta property="og:image" content="https://www.eclipse.org/images/og-image.jpg"><meta name=twitter:image content="https://www.eclipse.org/images/og-image.jpg"><meta name=twitter:card content="summary"><meta name=twitter:site content="@eclipsefdn"><meta name=twitter:creator content="@eclipsefdn"><meta property="og:url" content="https://www.eclipse.org/legal/epl-2.0/"><meta property="og:type" content="website"><meta property="og:site_name" content="Eclipse Foundation"><meta name=keywords content="epl,epl-2.0,legal,foundation,eclipse,eclipse public license,license,licenses"><meta name=generator content="Hugo 0.144.2"><link rel=canonical href=https://www.eclipse.org/legal/epl-2.0/><link rel=alternate href=/legal/epl-2.0/index.xml type=application/rss+xml title><link rel=stylesheet href="/public/css/styles.css?v=1772993988"><script>(function(e,t,n,s,o){e[s]=e[s]||[],e[s].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var a=t.getElementsByTagName(n)[0],i=t.createElement(n),r=s!="dataLayer"?"&l="+s:"";i.async=!0,i.src="https://www.googletagmanager.com/gtm.js?id="+o+r,a.parentNode.insertBefore(i,a)})(window,document,"script","dataLayer","GTM-5WLCZXC")</script><script>var tableClasses="table"</script><link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel=stylesheet type=text/css></head><body><noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5WLCZXC" height=0 width=0 style=display:none;visibility:hidden></iframe></noscript><a href=#main class=skip-link>Skip to content</a><div class=eclipsefdn-featured-story-banner data-publish-target=eclipse_org></div><header class="header-wrapper header-wrapper" id=header><div class="navigation-bar dark"><div class=container><div class=navigation-bar-inner><div class=navigation-bar-left><a class="focus-highlight focus-inverse" href=/><img class=navigation-bar-brand src=https://www.eclipse.org/eclipse.org-common/themes/solstice/public/images/logo/eclipse-foundation-white-orange.svg alt="Eclipse Foundation"></a></div><nav class="navigation-bar-nav hidden-xs hidden-sm"><ul><li><button type=button class="btn btn-link" data-target=join-us-menu>Join us</button></li><li><button type=button class="btn btn-link" data-target=what-we-do-menu>What we do</button></li><li><button type=button class="btn btn-link" data-target=resources-menu>Resources</button></li><li><button type=button class="btn btn-link" data-target=about-us-menu>About us</button></li></ul></nav><div class=navigation-bar-right><div class="navigation-bar-controls hidden-xs hidden-sm"><ul><li class=dropdown><a class="dropdown-toggle link-unstyled focus-highlight" tabindex=0 id=search-dropdown-toggle data-toggle=dropdown href=# aria-label=Search><i class="fa-solid fa-magnifying-glass" aria-hidden=true></i></a><form class="search-bar dropdown-menu dropdown-menu-right" aria-labelledby=search-dropdown-toggle action=https://www.eclipse.org/home/search/ method=get><input class=search-bar-input name=q placeholder=Search>
2
+ <meta property="og:title" content="Eclipse Public License 2.0 (EPL) | The Eclipse Foundation"><meta name=twitter:title content="Eclipse Public License 2.0 (EPL) | The Eclipse Foundation"><meta name=description content="The Eclipse Foundation provides our global community of individuals and organisations with a mature, scalable, and business-friendly environment for open source …"><meta property="og:description" content="The Eclipse Foundation provides our global community of individuals and organisations with a mature, scalable, and business-friendly environment for open source …"><meta name=twitter:description content="The Eclipse Foundation provides our global community of individuals and organisations with a mature, scalable, and business-friendly environment for open source …"><meta name=author content="Wayne Beaton"><link href=/favicon.ico rel=icon type=image/x-icon><meta property="og:image" content="https://www.eclipse.org/images/og-image.jpg"><meta name=twitter:image content="https://www.eclipse.org/images/og-image.jpg"><meta name=twitter:card content="summary"><meta name=twitter:site content="@eclipsefdn"><meta name=twitter:creator content="@eclipsefdn"><meta property="og:url" content="https://www.eclipse.org/legal/epl-2.0/"><meta property="og:type" content="website"><meta property="og:site_name" content="Eclipse Foundation"><meta name=keywords content="epl,epl-2.0,legal,foundation,eclipse,eclipse public license,license,licenses"><meta name=generator content="Hugo 0.144.2"><link rel=canonical href=https://www.eclipse.org/legal/epl-2.0/><link rel=alternate href=/legal/epl-2.0/index.xml type=application/rss+xml title><link rel=stylesheet href="/public/css/styles.css?v=1774203628"><script>(function(e,t,n,s,o){e[s]=e[s]||[],e[s].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var a=t.getElementsByTagName(n)[0],i=t.createElement(n),r=s!="dataLayer"?"&l="+s:"";i.async=!0,i.src="https://www.googletagmanager.com/gtm.js?id="+o+r,a.parentNode.insertBefore(i,a)})(window,document,"script","dataLayer","GTM-5WLCZXC")</script><script>var tableClasses="table"</script><link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel=stylesheet type=text/css></head><body><noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5WLCZXC" height=0 width=0 style=display:none;visibility:hidden></iframe></noscript><a href=#main class=skip-link>Skip to content</a><div class=eclipsefdn-featured-story-banner data-publish-target=eclipse_org></div><header class="header-wrapper header-wrapper" id=header><div class="navigation-bar dark"><div class=container><div class=navigation-bar-inner><div class=navigation-bar-left><a class="focus-highlight focus-inverse" href=/><img class=navigation-bar-brand src=https://www.eclipse.org/eclipse.org-common/themes/solstice/public/images/logo/eclipse-foundation-white-orange.svg alt="Eclipse Foundation"></a></div><nav class="navigation-bar-nav hidden-xs hidden-sm"><ul><li><button type=button class="btn btn-link" data-target=join-us-menu>Join us</button></li><li><button type=button class="btn btn-link" data-target=what-we-do-menu>What we do</button></li><li><button type=button class="btn btn-link" data-target=resources-menu>Resources</button></li><li><button type=button class="btn btn-link" data-target=about-us-menu>About us</button></li></ul></nav><div class=navigation-bar-right><div class="navigation-bar-controls hidden-xs hidden-sm"><ul><li class=dropdown><a class="dropdown-toggle link-unstyled focus-highlight" tabindex=0 id=search-dropdown-toggle data-toggle=dropdown href=# aria-label=Search><i class="fa-solid fa-magnifying-glass" aria-hidden=true></i></a><form class="search-bar dropdown-menu dropdown-menu-right" aria-labelledby=search-dropdown-toggle action=https://www.eclipse.org/home/search/ method=get><input class=search-bar-input name=q placeholder=Search>
3
3
  <button class="btn btn-link" type=submit>
4
4
  <i class="fa-solid fa-arrow-right"></i></button></form></li><li class=dropdown><a class="dropdown-toggle focus-highlight" id=user-menu href=# data-toggle=dropdown aria-haspopup=true aria-expanded=false tabindex=0><i class="fa-regular fa-user" aria-hidden=true></i></a><ul class="dropdown-menu dropdown-menu-right" aria-labelledby=user-menu><li><a href=https://accounts.eclipse.org/user><i class="fa-solid fa-user margin-right-10" aria-hidden=true></i>
5
5
  View my account</a></li><li><a href=https://accounts.eclipse.org/user/edit><i class="fa-solid fa-edit margin-right-10" aria-hidden=true></i>
@@ -43,4 +43,4 @@ Manage cookies</a></li></ul></li></ul></div><div class="navigation-bar-ctas hidd
43
43
  <i class="fa-brands fa-youtube fa-stack-1x fa-inverse" aria-hidden=true></i></span></a></li><li><a href=https://www.linkedin.com/company/eclipse-foundation aria-label=LinkedIn><span class=fa-stack><i class="fa-solid fa-circle fa-stack-2x" aria-hidden=true></i>
44
44
  <i class="fa-brands fa-linkedin-in fa-stack-1x fa-inverse" aria-hidden=true></i></span></a></li></ul></section><section class=newsletter-section><p class="subheading text-tertiary">Stay up to date</p><h2>Subscribe to our newsletter</h2><form class="newsletter-form margin-top-40" id=mc-embedded-subscribe-form action="https://eclipse.us6.list-manage.com/subscribe/post?u=eaf9e1f06f194eadc66788a85&amp;id=e7538485cd&amp;f_id=00f9c2e1f0" method=post novalidate target=_blank><div class=text-field-outlined><input name=EMAIL type=email placeholder="Your email">
45
45
  <button class=newsletter-form-submit type=submit name=subscribe id=mc-embedded-subscribe aria-label=Submit>
46
- <i class="fa-solid fa-arrow-right" aria-hidden=true></i></button></div></form></section><section class=footer-bottom-section><img class="img-responsive logo" src=https://www.eclipse.org/eclipse.org-common/themes/solstice/public/images/logo/eclipse-foundation-white.svg alt="Eclipse Foundation"><div class=legal-information><p>Copyright &copy; Eclipse Foundation AISBL. All rights reserved.</p><ul class=legal-links><li><a href=https://www.eclipse.org/legal/privacy/>Privacy policy</a></li><li><a href=https://www.eclipse.org/legal/terms-of-use/>Terms of use</a></li><li><a href=https://www.eclipse.org/legal/compliance/>Compliance</a></li><li><a href=https://www.eclipse.org/legal/>Legal</a></li></ul></div></section></div></div></footer><div id=footer-js><script src="/public/js/main.js?v1.0?v=1772993988"></script><script>(function(){})(jQuery,document)</script></div></body></html>
46
+ <i class="fa-solid fa-arrow-right" aria-hidden=true></i></button></div></form></section><section class=footer-bottom-section><img class="img-responsive logo" src=https://www.eclipse.org/eclipse.org-common/themes/solstice/public/images/logo/eclipse-foundation-white.svg alt="Eclipse Foundation"><div class=legal-information><p>Copyright &copy; Eclipse Foundation AISBL. All rights reserved.</p><ul class=legal-links><li><a href=https://www.eclipse.org/legal/privacy/>Privacy policy</a></li><li><a href=https://www.eclipse.org/legal/terms-of-use/>Terms of use</a></li><li><a href=https://www.eclipse.org/legal/compliance/>Compliance</a></li><li><a href=https://www.eclipse.org/legal/>Legal</a></li></ul></div></section></div></div></footer><div id=footer-js><script src="/public/js/main.js?v1.0?v=1774203628"></script><script>(function(){})(jQuery,document)</script></div></body></html>