@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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/bin/effekt +0 -0
  4. package/bin/effekt.sh +2 -0
  5. package/libraries/chez/THIRD-PARTY.txt +11 -0
  6. package/libraries/chez/callcc/datatype.ss +188 -0
  7. package/libraries/chez/callcc/effekt.effekt +221 -0
  8. package/libraries/chez/callcc/effekt.ss +31 -0
  9. package/libraries/chez/callcc/seq.ss +44 -0
  10. package/libraries/chez/callcc/seq0.ss +69 -0
  11. package/libraries/chez/callcc/tail.ss +76 -0
  12. package/libraries/chez/callcc/tail0.ss +89 -0
  13. package/libraries/chez/common/effekt_matching.ss +100 -0
  14. package/libraries/chez/common/effekt_primitives.ss +97 -0
  15. package/libraries/chez/common/immutable/cslist.effekt +31 -0
  16. package/libraries/chez/common/immutable/dequeue.effekt +78 -0
  17. package/libraries/chez/common/immutable/list.effekt +643 -0
  18. package/libraries/chez/common/immutable/option.effekt +39 -0
  19. package/libraries/chez/common/immutable/result.effekt +29 -0
  20. package/libraries/chez/common/io/args.effekt +20 -0
  21. package/libraries/chez/common/mutable/array.effekt +27 -0
  22. package/libraries/chez/common/mutable/dict.effekt +30 -0
  23. package/libraries/chez/common/mutable/heap.effekt +12 -0
  24. package/libraries/chez/common/test.effekt +59 -0
  25. package/libraries/chez/common/text/pregexp.scm +772 -0
  26. package/libraries/chez/common/text/regex.effekt +33 -0
  27. package/libraries/chez/common/text/string.effekt +46 -0
  28. package/libraries/chez/lift/effekt.effekt +217 -0
  29. package/libraries/chez/lift/effekt.ss +118 -0
  30. package/libraries/chez/monadic/effekt.effekt +218 -0
  31. package/libraries/chez/monadic/effekt.ss +84 -0
  32. package/libraries/chez/monadic/seq0.ss +76 -0
  33. package/libraries/js/effekt.effekt +284 -0
  34. package/libraries/js/effekt_builtins.js +26 -0
  35. package/libraries/js/effekt_matching.js +79 -0
  36. package/libraries/js/effekt_runtime.js +385 -0
  37. package/libraries/js/immutable/dequeue.effekt +78 -0
  38. package/libraries/js/immutable/list.effekt +643 -0
  39. package/libraries/js/immutable/option.effekt +49 -0
  40. package/libraries/js/immutable/result.effekt +29 -0
  41. package/libraries/js/io/args.effekt +9 -0
  42. package/libraries/js/io/async.effekt +28 -0
  43. package/libraries/js/io/async.js +2 -0
  44. package/libraries/js/io/file.effekt +50 -0
  45. package/libraries/js/io/file_include.js +13 -0
  46. package/libraries/js/mutable/array.effekt +98 -0
  47. package/libraries/js/mutable/heap.effekt +32 -0
  48. package/libraries/js/mutable/map.effekt +32 -0
  49. package/libraries/js/test.effekt +59 -0
  50. package/libraries/js/text/regex.effekt +34 -0
  51. package/libraries/js/text/string.effekt +64 -0
  52. package/libraries/js/unsafe/cont.effekt +11 -0
  53. package/libraries/js/web/dom.effekt +45 -0
  54. package/libraries/llvm/buffer.c +181 -0
  55. package/libraries/llvm/effekt.effekt +243 -0
  56. package/libraries/llvm/forward-declare-c.ll +24 -0
  57. package/libraries/llvm/hole.c +11 -0
  58. package/libraries/llvm/immutable/list.effekt +678 -0
  59. package/libraries/llvm/immutable/option.effekt +53 -0
  60. package/libraries/llvm/immutable/result.effekt +29 -0
  61. package/libraries/llvm/io/args.effekt +24 -0
  62. package/libraries/llvm/io.c +24 -0
  63. package/libraries/llvm/main.c +39 -0
  64. package/libraries/llvm/rts.ll +619 -0
  65. package/libraries/llvm/sanity.c +16 -0
  66. package/libraries/llvm/text/string.effekt +179 -0
  67. package/libraries/llvm/types.c +20 -0
  68. package/libraries/ml/effekt.effekt +267 -0
  69. package/libraries/ml/effekt.sml +63 -0
  70. package/libraries/ml/immutable/dequeue.effekt +81 -0
  71. package/libraries/ml/immutable/list.effekt +674 -0
  72. package/libraries/ml/immutable/option.effekt +53 -0
  73. package/libraries/ml/immutable/result.effekt +29 -0
  74. package/libraries/ml/immutable/seq.effekt +903 -0
  75. package/libraries/ml/internal/option.effekt +18 -0
  76. package/libraries/ml/io/args.effekt +41 -0
  77. package/libraries/ml/mutable/array.effekt +43 -0
  78. package/libraries/ml/random.effekt +85 -0
  79. package/libraries/ml/test.effekt +60 -0
  80. package/libraries/ml/text/regex.effekt +107 -0
  81. package/libraries/ml/text/string.effekt +81 -0
  82. package/licenses/THIRD-PARTY.txt +21 -0
  83. package/licenses/apache-2.0 - license-2.0.txt +202 -0
  84. package/licenses/eclipse public license, version 2.0 - epl-2.0.html +61 -0
  85. package/licenses/kiama-license.txt +373 -0
  86. package/licenses/kiama-readme.txt +186 -0
  87. package/licenses/mit license - mit-license.html +769 -0
  88. package/licenses/the apache software license, version 2.0 - license-2.0.txt +202 -0
  89. package/licenses/the bsd license - bsd-license.html +762 -0
  90. package/licenses/the mit license - mit.html +769 -0
  91. package/package.json +26 -18
@@ -0,0 +1,29 @@
1
+ import immutable/option
2
+
3
+ // Results
4
+ // =======
5
+ // The "reification" of the Exception[E] effect.
6
+ type Result[A, E] {
7
+ Error(exception: E, msg: String);
8
+ Success(a: A)
9
+ }
10
+
11
+ def result[A, E] { f: () => A / Exception[E] }: Result[A, E] = try {
12
+ Success(f())
13
+ } with Exception[E] {
14
+ def raise(exc, msg) = Error(exc, msg)
15
+ }
16
+
17
+ /**
18
+ * Extracts the value of a result, if available
19
+ * Monadic "reflection"
20
+ */
21
+ def value[A, E](r: Result[A, E]): A / Exception[E] = r match {
22
+ case Success(a) => a
23
+ case Error(exc, msg) => do raise(exc, msg)
24
+ }
25
+
26
+ def toOption[A, E](r: Result[A, E]): Option[A] = r match {
27
+ case Success(a) => Some(a)
28
+ case Error(exc, msg) => None()
29
+ }
@@ -0,0 +1,24 @@
1
+ module io/args
2
+
3
+ import effekt
4
+ import immutable/list
5
+
6
+ extern io def get_argc(): Int = """
7
+ %c = call %Int @c_get_argc()
8
+ ret %Int %c
9
+ """
10
+ extern io def get_arg(i: Int): String = """
11
+ %s = call %Pos @c_get_arg(%Int %i)
12
+ ret %Pos %s
13
+ """
14
+
15
+ def commandLineArgs(): List[String] = {
16
+ def rec(start: Int, acc: List[String]): List[String] = {
17
+ if (start < 1) {
18
+ acc
19
+ } else {
20
+ rec(start-1, Cons(get_arg(start), acc))
21
+ }
22
+ }
23
+ rec(get_argc()-1, Nil())
24
+ }
@@ -0,0 +1,24 @@
1
+ #ifndef EFFEKT_IO_C
2
+ #define EFFEKT_IO_C
3
+
4
+ // println
5
+
6
+ void c_io_println_Int(const Int n) {
7
+ printf("%" PRId64 "\n", n);
8
+ }
9
+
10
+ void c_io_println_Boolean(const struct Pos p) {
11
+ printf("%s\n", p.tag ? "true" : "false");
12
+ }
13
+
14
+ void c_io_println_Double(const Double x) {
15
+ printf("%g\n", x);
16
+ }
17
+
18
+ void c_io_println_String(String text) {
19
+ for (uint64_t j = 0; j < c_buffer_length(text); ++j)
20
+ putchar(c_buffer_bytes(text)[j]);
21
+ putchar('\n');
22
+ }
23
+
24
+ #endif
@@ -0,0 +1,39 @@
1
+ #include <errno.h>
2
+ #include <inttypes.h>
3
+ #include <limits.h>
4
+ #include <stdbool.h>
5
+ #include <stdint.h>
6
+ #include <stdio.h>
7
+ #include <stdlib.h>
8
+ #include <unistd.h>
9
+
10
+ #define DEBUG_REFCOUNT (false)
11
+
12
+ #include "sanity.c"
13
+ #include "types.c"
14
+ #include "buffer.c"
15
+ #include "io.c"
16
+ #include "hole.c"
17
+
18
+
19
+ extern void effektMain();
20
+
21
+ int program_argc;
22
+ char** program_argv;
23
+
24
+ struct Pos c_get_arg(uint64_t idx) {
25
+ if(idx < program_argc) {
26
+ return c_buffer_construct_from_null_terminated_string(program_argv[idx]);
27
+ } else {
28
+ return c_buffer_construct_zeroed(1);
29
+ }
30
+ }
31
+ uint64_t c_get_argc() {
32
+ return program_argc;
33
+ }
34
+
35
+ int main(int argc, char *argv[]) {
36
+ program_argc = argc;
37
+ program_argv = argv;
38
+ effektMain();
39
+ }