@effekt-lang/effekt 0.2.1 → 0.2.2
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/LICENSE +21 -0
- package/README.md +36 -0
- package/bin/effekt +0 -0
- package/bin/effekt.sh +2 -0
- package/libraries/chez/THIRD-PARTY.txt +11 -0
- package/libraries/chez/callcc/datatype.ss +188 -0
- package/libraries/chez/callcc/effekt.effekt +221 -0
- package/libraries/chez/callcc/effekt.ss +31 -0
- package/libraries/chez/callcc/seq.ss +44 -0
- package/libraries/chez/callcc/seq0.ss +69 -0
- package/libraries/chez/callcc/tail.ss +76 -0
- package/libraries/chez/callcc/tail0.ss +89 -0
- package/libraries/chez/common/effekt_matching.ss +100 -0
- package/libraries/chez/common/effekt_primitives.ss +97 -0
- package/libraries/chez/common/immutable/cslist.effekt +31 -0
- package/libraries/chez/common/immutable/dequeue.effekt +78 -0
- package/libraries/chez/common/immutable/list.effekt +643 -0
- package/libraries/chez/common/immutable/option.effekt +39 -0
- package/libraries/chez/common/immutable/result.effekt +29 -0
- package/libraries/chez/common/io/args.effekt +20 -0
- package/libraries/chez/common/mutable/array.effekt +27 -0
- package/libraries/chez/common/mutable/dict.effekt +30 -0
- package/libraries/chez/common/mutable/heap.effekt +12 -0
- package/libraries/chez/common/test.effekt +59 -0
- package/libraries/chez/common/text/pregexp.scm +772 -0
- package/libraries/chez/common/text/regex.effekt +33 -0
- package/libraries/chez/common/text/string.effekt +46 -0
- package/libraries/chez/lift/effekt.effekt +217 -0
- package/libraries/chez/lift/effekt.ss +118 -0
- package/libraries/chez/monadic/effekt.effekt +218 -0
- package/libraries/chez/monadic/effekt.ss +84 -0
- package/libraries/chez/monadic/seq0.ss +76 -0
- package/libraries/js/effekt.effekt +284 -0
- package/libraries/js/effekt_builtins.js +26 -0
- package/libraries/js/effekt_matching.js +79 -0
- package/libraries/js/effekt_runtime.js +385 -0
- package/libraries/js/immutable/dequeue.effekt +78 -0
- package/libraries/js/immutable/list.effekt +643 -0
- package/libraries/js/immutable/option.effekt +49 -0
- package/libraries/js/immutable/result.effekt +29 -0
- package/libraries/js/io/args.effekt +9 -0
- package/libraries/js/io/async.effekt +28 -0
- package/libraries/js/io/async.js +2 -0
- package/libraries/js/io/file.effekt +50 -0
- package/libraries/js/io/file_include.js +13 -0
- package/libraries/js/mutable/array.effekt +98 -0
- package/libraries/js/mutable/heap.effekt +32 -0
- package/libraries/js/mutable/map.effekt +32 -0
- package/libraries/js/test.effekt +59 -0
- package/libraries/js/text/regex.effekt +34 -0
- package/libraries/js/text/string.effekt +64 -0
- package/libraries/js/unsafe/cont.effekt +11 -0
- package/libraries/js/web/dom.effekt +45 -0
- package/libraries/llvm/buffer.c +181 -0
- package/libraries/llvm/effekt.effekt +243 -0
- package/libraries/llvm/forward-declare-c.ll +24 -0
- package/libraries/llvm/hole.c +11 -0
- package/libraries/llvm/immutable/list.effekt +678 -0
- package/libraries/llvm/immutable/option.effekt +53 -0
- package/libraries/llvm/immutable/result.effekt +29 -0
- package/libraries/llvm/io/args.effekt +24 -0
- package/libraries/llvm/io.c +24 -0
- package/libraries/llvm/main.c +39 -0
- package/libraries/llvm/rts.ll +619 -0
- package/libraries/llvm/sanity.c +16 -0
- package/libraries/llvm/text/string.effekt +179 -0
- package/libraries/llvm/types.c +20 -0
- package/libraries/ml/effekt.effekt +267 -0
- package/libraries/ml/effekt.sml +63 -0
- package/libraries/ml/immutable/dequeue.effekt +81 -0
- package/libraries/ml/immutable/list.effekt +674 -0
- package/libraries/ml/immutable/option.effekt +53 -0
- package/libraries/ml/immutable/result.effekt +29 -0
- package/libraries/ml/immutable/seq.effekt +903 -0
- package/libraries/ml/internal/option.effekt +18 -0
- package/libraries/ml/io/args.effekt +41 -0
- package/libraries/ml/mutable/array.effekt +43 -0
- package/libraries/ml/random.effekt +85 -0
- package/libraries/ml/test.effekt +60 -0
- package/libraries/ml/text/regex.effekt +107 -0
- package/libraries/ml/text/string.effekt +81 -0
- package/licenses/THIRD-PARTY.txt +21 -0
- package/licenses/apache-2.0 - license-2.0.txt +202 -0
- package/licenses/eclipse public license, version 2.0 - epl-2.0.html +61 -0
- package/licenses/kiama-license.txt +373 -0
- package/licenses/kiama-readme.txt +186 -0
- package/licenses/mit license - mit-license.html +769 -0
- package/licenses/the apache software license, version 2.0 - license-2.0.txt +202 -0
- package/licenses/the bsd license - bsd-license.html +762 -0
- package/licenses/the mit license - mit.html +769 -0
- package/package.json +26 -18
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module io/args
|
|
2
|
+
|
|
3
|
+
import effekt
|
|
4
|
+
import immutable/option
|
|
5
|
+
import immutable/cslist
|
|
6
|
+
import immutable/list
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// ================================================
|
|
10
|
+
//
|
|
11
|
+
// Conceptual Public Functions:
|
|
12
|
+
// - commandLineArgs(): List[String]
|
|
13
|
+
//
|
|
14
|
+
// ================================================
|
|
15
|
+
|
|
16
|
+
// Arguments passed to the script, first one is the file name itself, which we ignore.
|
|
17
|
+
extern io def nativeArgs(): CSList[String] =
|
|
18
|
+
"(cdr (command-line))"
|
|
19
|
+
|
|
20
|
+
def commandLineArgs(): List[String] = nativeArgs().fromChez
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module mutable/array
|
|
2
|
+
|
|
3
|
+
import immutable/option
|
|
4
|
+
import immutable/cslist
|
|
5
|
+
|
|
6
|
+
// a mutable array backed by a scheme vector
|
|
7
|
+
extern type Array[T]
|
|
8
|
+
|
|
9
|
+
extern pure def emptyArray[T](size: Int): Array[T] =
|
|
10
|
+
"(make-vector ${size})"
|
|
11
|
+
|
|
12
|
+
def get[T](arr: Array[T], index: Int): Option[T] =
|
|
13
|
+
if (index >= arr.size) None() else Some(arr.unsafeGet(index))
|
|
14
|
+
|
|
15
|
+
extern pure def size[T](arr: Array[T]): Int =
|
|
16
|
+
"(vector-length ${arr})"
|
|
17
|
+
|
|
18
|
+
// raises a scheme exception if out of bounds
|
|
19
|
+
extern pure def unsafeGet[T](arr: Array[T], index: Int): T =
|
|
20
|
+
"(vector-ref ${arr} ${index})"
|
|
21
|
+
|
|
22
|
+
// TODO raises a scheme exception if out of bounds
|
|
23
|
+
extern io def put[T](arr: Array[T], index: Int, value: T): Unit =
|
|
24
|
+
"(begin (vector-set! ${arr} ${index} ${value}) #f)"
|
|
25
|
+
|
|
26
|
+
extern pure def toArray[A](l: CSList[A]): Array[A] =
|
|
27
|
+
"(list->vector ${l})"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module mutable/dict
|
|
2
|
+
|
|
3
|
+
import immutable/option
|
|
4
|
+
|
|
5
|
+
// https://cisco.github.io/ChezScheme/csug9.5/compat.html#g148
|
|
6
|
+
extern type Dict[K, V]
|
|
7
|
+
|
|
8
|
+
extern io def emptyDict[K, V](): Dict[K, V] =
|
|
9
|
+
"(make-eq-hashtable)"
|
|
10
|
+
|
|
11
|
+
extern io def emptyWeakDict[K, V](): Dict[K, V] =
|
|
12
|
+
"(make-hash-table #t)"
|
|
13
|
+
|
|
14
|
+
extern io def put[K, V](d: Dict[K, V], key: K, value: V): Unit =
|
|
15
|
+
"(put-hash-table! ${d} ${key} ${value})"
|
|
16
|
+
|
|
17
|
+
extern io def get[K, V](d: Dict[K, V], key: K, default: V): V =
|
|
18
|
+
"(hashtable-ref ${d} ${key} ${default})"
|
|
19
|
+
|
|
20
|
+
extern io def unsafeGet[K, V](d: Dict[K, V], key: K): V =
|
|
21
|
+
"(hashtable-ref ${d} ${key} #f)"
|
|
22
|
+
|
|
23
|
+
extern io def contains[K, V](d: Dict[K, V], key: K): Boolean =
|
|
24
|
+
"(hashtable-contains? ${d} ${key})"
|
|
25
|
+
|
|
26
|
+
extern io def remove[K, V](d: Dict[K, V], key: K): Unit =
|
|
27
|
+
"(remove-hash-table! ${d} ${key})"
|
|
28
|
+
|
|
29
|
+
def get[K, V](d: Dict[K, V], key: K): Option[V] =
|
|
30
|
+
undefinedToOption(unsafeGet(d, key))
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module mutable/heap
|
|
2
|
+
|
|
3
|
+
extern type Ref[T]
|
|
4
|
+
|
|
5
|
+
extern io def fresh[T](init: T): Ref[T] =
|
|
6
|
+
"(box ${init})"
|
|
7
|
+
|
|
8
|
+
extern io def put[T](ref: Ref[T], value: T): Unit =
|
|
9
|
+
"(set-box! ${ref} ${value})"
|
|
10
|
+
|
|
11
|
+
extern io def get[T](ref: Ref[T]): T =
|
|
12
|
+
"(unbox ${ref})"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import text/string
|
|
2
|
+
|
|
3
|
+
interface Assertion {
|
|
4
|
+
def assert(condition: Boolean, msg: String): Unit
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
def assertTrue(condition: Boolean, msg: String) =
|
|
8
|
+
do assert(condition, msg)
|
|
9
|
+
|
|
10
|
+
def assertTrue(condition: Boolean) =
|
|
11
|
+
do assert(condition, "Assertion failed")
|
|
12
|
+
|
|
13
|
+
def assertFalse(condition: Boolean, msg: String) =
|
|
14
|
+
do assert(not(condition), msg)
|
|
15
|
+
|
|
16
|
+
def assertFalse(condition: Boolean) =
|
|
17
|
+
do assert(not(condition), "Assertion failed")
|
|
18
|
+
|
|
19
|
+
def assertEqual[A](obtained: A, expected: A, msg: String) =
|
|
20
|
+
do assert(obtained == expected, msg)
|
|
21
|
+
|
|
22
|
+
def assertEqual[A](obtained: A, expected: A) =
|
|
23
|
+
do assert(obtained == expected, "Obtained: " ++ obtained.show ++ "\n but expected:" ++ expected.show)
|
|
24
|
+
|
|
25
|
+
interface Test {
|
|
26
|
+
def success(name: String): Unit
|
|
27
|
+
def failure(name: String, msg: String): Unit
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
def test(name: String) { body: => Unit / Assertion } =
|
|
31
|
+
try { body(); do success(name) } with Assertion {
|
|
32
|
+
def assert(condition, msg) = if (condition) resume(()) else do failure(name, msg)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
def suite(name: String) { body: => Unit / Test }: Boolean = {
|
|
36
|
+
println("Running suite: " ++ name);
|
|
37
|
+
var failed = 0
|
|
38
|
+
var passed = 0
|
|
39
|
+
|
|
40
|
+
try { body() } with Test {
|
|
41
|
+
def success(name) = {
|
|
42
|
+
passed = passed + 1
|
|
43
|
+
println(ANSI_GREEN ++ "+ " ++ name ++ "" ++ ANSI_RESET);
|
|
44
|
+
resume(())
|
|
45
|
+
}
|
|
46
|
+
def failure(name, msg) = {
|
|
47
|
+
failed = failed + 1
|
|
48
|
+
println(ANSI_RED ++ "- (FAIL) " ++ name ++ "\n " ++ msg ++ ANSI_RESET);
|
|
49
|
+
resume(())
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (failed > 0) {
|
|
53
|
+
println(ANSI_RED ++ "Some tests failed (" ++ passed.show ++ " passed, " ++ failed.show ++ " failed)" ++ ANSI_RESET)
|
|
54
|
+
false
|
|
55
|
+
} else {
|
|
56
|
+
println(ANSI_GREEN ++ "All tests passed (" ++ passed.show ++ " passed)" ++ ANSI_RESET)
|
|
57
|
+
true
|
|
58
|
+
}
|
|
59
|
+
}
|