@effekt-lang/effekt 0.2.1 → 0.3.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.
Files changed (75) 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.ss +31 -0
  8. package/libraries/chez/callcc/seq.ss +44 -0
  9. package/libraries/chez/callcc/seq0.ss +69 -0
  10. package/libraries/chez/callcc/tail.ss +76 -0
  11. package/libraries/chez/callcc/tail0.ss +89 -0
  12. package/libraries/chez/common/effekt_primitives.ss +105 -0
  13. package/libraries/chez/common/immutable/cslist.effekt +37 -0
  14. package/libraries/chez/common/mutable/dict.effekt +28 -0
  15. package/libraries/chez/common/text/pregexp.scm +772 -0
  16. package/libraries/chez/common/text/regex.effekt +31 -0
  17. package/libraries/chez/lift/effekt.ss +118 -0
  18. package/libraries/chez/monadic/effekt.ss +84 -0
  19. package/libraries/chez/monadic/seq0.ss +76 -0
  20. package/libraries/common/args.effekt +95 -0
  21. package/libraries/common/array.effekt +225 -0
  22. package/libraries/common/bench.effekt +60 -0
  23. package/libraries/common/buffer.effekt +123 -0
  24. package/libraries/common/bytes.effekt +125 -0
  25. package/libraries/common/dequeue.effekt +92 -0
  26. package/libraries/common/effekt.effekt +764 -0
  27. package/libraries/common/exception.effekt +122 -0
  28. package/libraries/common/io/console.effekt +66 -0
  29. package/libraries/common/io/error.effekt +365 -0
  30. package/libraries/common/io/files.effekt +282 -0
  31. package/libraries/common/io/network.effekt +105 -0
  32. package/libraries/common/io/time.effekt +15 -0
  33. package/libraries/common/io.effekt +158 -0
  34. package/libraries/common/list.effekt +687 -0
  35. package/libraries/common/option.effekt +72 -0
  36. package/libraries/common/process.effekt +10 -0
  37. package/libraries/common/queue.effekt +140 -0
  38. package/libraries/common/ref.effekt +63 -0
  39. package/libraries/common/result.effekt +45 -0
  40. package/libraries/common/seq.effekt +914 -0
  41. package/libraries/common/string.effekt +395 -0
  42. package/libraries/common/test.effekt +98 -0
  43. package/libraries/js/effekt_builtins.js +57 -0
  44. package/libraries/js/effekt_runtime.js +385 -0
  45. package/libraries/js/io.js +143 -0
  46. package/libraries/js/mutable/map.effekt +31 -0
  47. package/libraries/js/text/regex.effekt +33 -0
  48. package/libraries/js/unsafe/cont.effekt +11 -0
  49. package/libraries/js/web/dom.effekt +45 -0
  50. package/libraries/llvm/array.c +53 -0
  51. package/libraries/llvm/buffer.c +286 -0
  52. package/libraries/llvm/forward-declare-c.ll +43 -0
  53. package/libraries/llvm/hole.c +11 -0
  54. package/libraries/llvm/io.c +566 -0
  55. package/libraries/llvm/io.ll +19 -0
  56. package/libraries/llvm/main.c +41 -0
  57. package/libraries/llvm/ref.c +45 -0
  58. package/libraries/llvm/rts.ll +761 -0
  59. package/libraries/llvm/sanity.c +16 -0
  60. package/libraries/llvm/types.c +43 -0
  61. package/libraries/ml/effekt.sml +65 -0
  62. package/libraries/ml/internal/mllist.effekt +9 -0
  63. package/libraries/ml/internal/mloption.effekt +18 -0
  64. package/libraries/ml/random.effekt +85 -0
  65. package/libraries/ml/text/regex.effekt +102 -0
  66. package/licenses/THIRD-PARTY.txt +21 -0
  67. package/licenses/apache-2.0 - license-2.0.txt +202 -0
  68. package/licenses/eclipse public license, version 2.0 - epl-2.0.html +61 -0
  69. package/licenses/kiama-license.txt +373 -0
  70. package/licenses/kiama-readme.txt +186 -0
  71. package/licenses/mit license - mit-license.html +1239 -0
  72. package/licenses/the apache software license, version 2.0 - license-2.0.txt +202 -0
  73. package/licenses/the bsd license - bsd-license.html +1237 -0
  74. package/licenses/the mit license - mit.html +1239 -0
  75. package/package.json +26 -18
@@ -0,0 +1,16 @@
1
+ #ifndef EFFEKT_SANITY_C
2
+ #define EFFEKT_SANITY_C
3
+
4
+
5
+ #if CHAR_BIT != 8
6
+ #error Machine ought to have eight bits in a byte.
7
+ #endif
8
+
9
+
10
+ #define ASSERT_NON_NULL(PTR) if ((PTR) == NULL) { \
11
+ fprintf(stderr, "*** MALLOC PANIC\n"); \
12
+ fflush(stderr); \
13
+ exit(1); }
14
+
15
+
16
+ #endif
@@ -0,0 +1,43 @@
1
+ #ifndef EFFEKT_TYPES_C
2
+ #define EFFEKT_TYPES_C
3
+
4
+
5
+ typedef int64_t Int;
6
+ typedef double Double;
7
+
8
+ struct Header {
9
+ uint64_t rc;
10
+ void (*eraser)(void *);
11
+ };
12
+
13
+ struct Pos {
14
+ uint64_t tag; // type-local tag
15
+ void *obj; // pointer into the heap
16
+ };
17
+
18
+ struct Neg {
19
+ void *vtable;
20
+ void *obj;
21
+ };
22
+
23
+ static const struct Pos Unit = (struct Pos) { .tag = 0, .obj = NULL, };
24
+ static const struct Pos BooleanFalse = (struct Pos) { .tag = 0, .obj = NULL, };
25
+ static const struct Pos BooleanTrue = (struct Pos) { .tag = 1, .obj = NULL, };
26
+
27
+ typedef struct Pos String;
28
+
29
+
30
+ // Defined in rts.ll
31
+
32
+ extern void run(struct Neg);
33
+ extern void run_i64(struct Neg, int64_t);
34
+ extern void run_Pos(struct Neg, struct Pos);
35
+
36
+ // Reference counting primitives defined in LLVM
37
+ extern void eraseNegative(struct Neg);
38
+ extern void erasePositive(struct Pos);
39
+
40
+ extern void shareNegative(struct Neg);
41
+ extern void sharePositive(struct Pos);
42
+
43
+ #endif
@@ -0,0 +1,65 @@
1
+ (* EVIDENCE *)
2
+ fun lift m k1 k2 = m (fn a => k1 a k2);
3
+ fun nested ev1 ev2 m = ev1 (ev2 m);
4
+ fun here x = x;
5
+
6
+ (* REGIONS *)
7
+ (* type region = ((() -> () -> ()) list) ref *)
8
+ fun newRegion () = ref nil
9
+ fun backup cell = fn () => let val oldState = !cell in fn () => cell := oldState end
10
+ fun fresh r init = let val cell = ref init in (r := (backup cell) :: (!r); cell) end
11
+ fun withRegion body =
12
+ let val r = newRegion()
13
+ fun lift m k = let val fields = map (fn f => f()) (!r) in
14
+ m (fn a => (map (fn f => f()) fields; k a)) end
15
+ in body lift r end
16
+
17
+ (* SHOW INSTANCES *)
18
+ fun show'int x =
19
+ let val s = (Int.toString x) in
20
+ case String.sub (s, 0) of
21
+ #"~" => "-" ^ String.extract (s, 1, NONE)
22
+ | _ => s
23
+ end;
24
+
25
+ (*
26
+ To align with the js backend inf and nan is rewritten
27
+ - `nan` -> `NaN`
28
+ - `inf` -> `Infinity`
29
+ - `~2.1` -> `-2.1`
30
+ They do still disagree on the truncating of `2.0` to `2` (ml does not).
31
+ *)
32
+ fun show'real x =
33
+ let val s = (Real.toString x) in
34
+ case s of
35
+ "nan" => "NaN"
36
+ | "inf" => "Infinity"
37
+ | _ => case String.sub (s, 0) of
38
+ #"~" => "-" ^ String.extract (s, 1, NONE)
39
+ | _ => s
40
+ end;
41
+
42
+ fun show'unit x = ""
43
+
44
+ fun show'bool x = Bool.toString x
45
+
46
+ fun show'string x = x
47
+
48
+ (* TIMING *)
49
+ val mlStartTime = Time.toMilliseconds (Time.now ());
50
+
51
+ (* RANDOM *)
52
+ fun mlRandomReal () =
53
+ let
54
+ val r = MLton.Random.rand ();
55
+ val rreal = MLton.Real.fromWord r;
56
+ val wsize = Real.fromInt Word.wordSize;
57
+ fun shiftRight r shift = r / (Math.pow(2.0, shift))
58
+ in
59
+ shiftRight rreal wsize
60
+ end;
61
+
62
+ (* HOLES *)
63
+ exception Hole
64
+
65
+ exception Absurd
@@ -0,0 +1,9 @@
1
+ module internal/mllist
2
+
3
+ extern type MLList[Elem] // = 'elem list
4
+ extern pure def isEmpty[A](l: MLList[A]): Bool = ml "null ${l}"
5
+ extern pure def head[A](l: MLList[A]): A = ml "hd ${l}"
6
+ extern pure def tail[A](l: MLList[A]): MLList[A] = ml "tl ${l}"
7
+
8
+ def toList[A](l: MLList[A]): List[A] =
9
+ if (l.isEmpty) Nil() else Cons(l.head, toList(l.tail))
@@ -0,0 +1,18 @@
1
+ module internal/mloption
2
+
3
+ import effekt
4
+ import option
5
+
6
+ extern type MLOption[T]
7
+
8
+ extern pure def isDefined[T](opt: MLOption[T]): Bool =
9
+ ml "Option.isSome ${opt}"
10
+
11
+ def isEmpty[T](opt: MLOption[T]): Bool = not(opt.isDefined())
12
+
13
+ extern pure def force[T](opt: MLOption[T]): T =
14
+ ml "Option.valOf ${opt}"
15
+
16
+ def toOption[T](opt: MLOption[T]): Option[T] = {
17
+ if (isDefined(opt)) Some(force(opt)) else None()
18
+ }
@@ -0,0 +1,85 @@
1
+ module random
2
+
3
+ /**
4
+ * Imperative Random Numbers
5
+ * -------------------------
6
+ * The following are simple bindings for the following SML/NJ module:
7
+ * https://www.smlnj.org/doc/smlnj-lib/Util/str-Random.html
8
+ *
9
+ * They are not supposed to be used directly, but only via the
10
+ * effect [[Random]], below.
11
+ */
12
+ extern type RNG // = int * int
13
+ extern io def seed(n: Int, m: Int): RNG = ml "Random.rand (${n}, ${m})"
14
+ extern pure def toString(s: RNG): String = ml "Random.toString ${s}"
15
+
16
+ extern io def int(s: RNG): Int = ml "Random.randInt ${s}"
17
+ extern io def int(s: RNG, from: Int, to: Int): Int = ml "Random.randRange (${from}, ${to}) ${s}"
18
+ extern io def double(s: RNG): Double = ml "Random.randReal ${s}"
19
+
20
+
21
+ /**
22
+ * Functional Random Numbers
23
+ * -------------------------
24
+ * The following are simple bindings for the following SML/NJ module:
25
+ * https://www.smlnj.org/doc/smlnj-lib/Util/str-Rand.html
26
+ *
27
+ * They are not supposed to be used directly, but only via the
28
+ * effect [[Random]], below.
29
+ */
30
+ extern type PseudoRNG
31
+ extern pure def random(s: PseudoRNG): PseudoRNG =
32
+ ml "Rand.random ${s}"
33
+ extern pure def range(s: PseudoRNG, n: Int, m: Int): Int =
34
+ ml "Rand.range (${n}, ${m}) ${s}"
35
+ extern pure def norm(s: PseudoRNG): Double =
36
+ ml "Rand.norm ${s}"
37
+
38
+ // converting two integers into a word that is between randMin and randMax is completely made up
39
+ extern pure def pseudo(n: Int, m: Int): PseudoRNG =
40
+ ml "Word.fromInt ((Word.toInt Rand.randMin) + ((abs (${n} * ${m})) mod (Word.toInt Rand.randMax)))"
41
+
42
+
43
+
44
+ // "Public" API
45
+ // ------------
46
+
47
+ /**
48
+ * A random number generator.
49
+ *
50
+ * Supposed to be used as an effect: `do randomInt(0, 10)`.
51
+ * There are two canonical implementations as effect handlers (see below).
52
+ */
53
+ interface Random {
54
+ // returns a random integer between `from` and `to`
55
+ def randomInt(from: Int, to: Int): Int
56
+ // returns a random double between 0.0 and 1.0
57
+ def randomDouble(): Double
58
+ }
59
+
60
+ /**
61
+ * Imperative random numbers. Does not perform backtracking.
62
+ */
63
+ def withRandom[R](n: Int, m: Int) { prog: => R / Random } = {
64
+ // should be second class, is mutated...
65
+ val rng = seed(n, m)
66
+ try { prog() }
67
+ with Random {
68
+ def randomInt(from, to) = resume(rng.int(from, to))
69
+ def randomDouble() = resume(rng.double())
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Functional, pseudo random numbers. According to SMLNJ docs it is faster than the imperative version
75
+ */
76
+ def withPseudoRandom[R](n: Int, m: Int) { prog: => R / Random } = {
77
+ // should be second class, is mutated...
78
+ var rng = pseudo(n, m)
79
+ def next() = rng = random(rng);
80
+ try { prog() }
81
+ with Random {
82
+ def randomInt(from, to) = { next(); resume(rng.range(from, to)) }
83
+ def randomDouble() = { next(); resume(rng.norm()) }
84
+ }
85
+ }
@@ -0,0 +1,102 @@
1
+ module text/regex
2
+
3
+ import internal/mllist
4
+ import internal/mloption
5
+
6
+ extern type Char // TODO move to text/string
7
+ type Chars = MLList[Char]
8
+
9
+
10
+ extern pure def chars(str: String): Chars = ml "String.explode ${str}"
11
+ extern pure def toString(chars: Chars): String = ml "String.implode ${chars}"
12
+
13
+ extern ml """
14
+
15
+ (** The RegExp module is created by choosing a parser (P) and an engine (E)
16
+ * for regular expressions.
17
+ *
18
+ * There is no big choice for the parser, since only Awk syntax is supported.
19
+ * For the regular expression engine, we choose Ken Thompson's algorighm.
20
+ *
21
+ * Also see:
22
+ * <https://stackoverflow.com/questions/35462919/how-to-use-regex-in-smlnj>
23
+ * <https://www.smlnj.org/doc/smlnj-lib/RegExp/fun-RegExpFn.html>
24
+ *)
25
+ structure RegExp = RegExpFn(
26
+ structure P = AwkSyntax
27
+ structure E = ThompsonEngine
28
+ (* structure E = BackTrackEngine *)
29
+ (* structure E = DfaEngine *)
30
+ )
31
+ """
32
+
33
+ // The type of regular expressions (ML representation)
34
+ extern type Regex
35
+
36
+ record Match(matched: String)
37
+
38
+ // TODO handle CannotParse and CannotCompile ml exceptions.
39
+ extern pure def regex(regexString: String): Regex =
40
+ ml "RegExp.compileString ${regexString}"
41
+
42
+
43
+ // A stream of elements of type Elem, read from a source of type Source
44
+ extern type MLStream[Elem, Source] // = ('elem, 'source) StringCvt.reader
45
+
46
+ // Internal ml type that represents matches
47
+ // <https://www.smlnj.org/doc/smlnj-lib/RegExp/str-MatchTree.html>
48
+ extern type MLMatchResult // = match * char list
49
+
50
+ extern ml """
51
+ type regex_match = {len: int, pos: char list} MatchTree.match_tree;
52
+ fun matchedString (match : regex_match * char list) =
53
+ let val res = MatchTree.root (#1 match)
54
+ in String.implode (List.take (#pos res, #len res)) end;
55
+
56
+ fun remainderChars (match : regex_match * char list) =
57
+ let val res = MatchTree.root (#1 match)
58
+ in List.drop (#pos res, #len res) end;
59
+
60
+ (** The remainder is just a draft and doesn't work yet...) *)
61
+
62
+ (** MatchTree -> string list **)
63
+ fun allMatched (matchtree: regex_match) =
64
+ MatchTree.foldl (fn (m, b) => (String.implode (List.take (#pos m, #len m))) :: b) nil matchtree
65
+ fun allBut str = RegExp.compileString ("[^" ^ str ^ "]+");
66
+
67
+ fun unsafeSplit str sep =
68
+ case (RegExp.find (allBut str) List.getItem (String.explode str)) of
69
+ NONE => nil
70
+ | SOME v => allMatched (#1 v);
71
+ """
72
+
73
+ extern pure def getMatch(result: MLMatchResult): String =
74
+ ml "matchedString ${result}"
75
+ extern pure def getRemainder(result: MLMatchResult): Chars =
76
+ ml "remainderChars ${result}"
77
+
78
+ extern pure def unsafeSplit(str: String, ch: Char): MLList[String] =
79
+ ml "String.fields (fn c => c = ${ch}) ${str}"
80
+
81
+ extern pure def unsafeMatchPrefix(r: Regex, str: Chars): MLOption[MLMatchResult] =
82
+ ml "RegExp.prefix ${r} List.getItem ${str}"
83
+
84
+ extern pure def unsafeSplit(str: String, sep: String): MLList[String] =
85
+ ml "unsafeSplit ${str} ${sep}"
86
+
87
+ extern ml """
88
+ val NEWLINE_CHAR = #"\n";
89
+ """
90
+
91
+ extern pure def unsafeLines(str: String): MLList[String] =
92
+ ml "String.fields (fn c => c = NEWLINE_CHAR) ${str}"
93
+
94
+ def lines(str: String): List[String] = unsafeLines(str).toList
95
+
96
+ def split(str: String, sep: String): List[String] = unsafeSplit(str, sep).toList
97
+
98
+ def exec(reg: Regex, str: String): Option[Match] = {
99
+ val matched = reg.unsafeMatchPrefix(str.chars)
100
+ if (matched.isDefined) { Some(Match(matched.force.getMatch())) }
101
+ else { None() }
102
+ }
@@ -0,0 +1,21 @@
1
+
2
+ Lists of 19 third-party dependencies.
3
+ (The Apache Software License, Version 2.0) FindBugs-jsr305 (com.google.code.findbugs:jsr305:3.0.2 - http://findbugs.sourceforge.net/)
4
+ (Apache-2.0) Gson (com.google.code.gson:gson:2.8.9 - https://github.com/google/gson/gson)
5
+ (Apache 2.0) error-prone annotations (com.google.errorprone:error_prone_annotations:2.2.0 - http://nexus.sonatype.org/oss-repository-hosting.html/error_prone_parent/error_prone_annotations)
6
+ (The Apache Software License, Version 2.0) Guava InternalFutureFailureAccess and InternalFutures (com.google.guava:failureaccess:1.0.1 - https://github.com/google/guava/failureaccess)
7
+ (The Apache Software License, Version 2.0) Guava: Google Core Libraries for Java (com.google.guava:guava:27.1-jre - https://github.com/google/guava/guava)
8
+ (The Apache Software License, Version 2.0) Guava ListenableFuture only (com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava - https://github.com/google/guava/listenablefuture)
9
+ (The Apache Software License, Version 2.0) J2ObjC Annotations (com.google.j2objc:j2objc-annotations:1.1 - https://github.com/google/j2objc/)
10
+ (The BSD License) JLine (jline:jline:2.14.6 - http://nexus.sonatype.org/oss-repository-hosting.html/jline)
11
+ (The MIT License) Checker Qual (org.checkerframework:checker-qual:2.5.2 - https://checkerframework.org)
12
+ (MIT license) Animal Sniffer Annotations (org.codehaus.mojo:animal-sniffer-annotations:1.17 - http://www.mojohaus.org/animal-sniffer/animal-sniffer-annotations)
13
+ (Eclipse Public License, Version 2.0) LSP4J (org.eclipse.lsp4j:org.eclipse.lsp4j:0.12.0 - https://github.com/eclipse/lsp4j)
14
+ (Eclipse Public License, Version 2.0) LSP4J Generator (org.eclipse.lsp4j:org.eclipse.lsp4j.generator:0.12.0 - https://github.com/eclipse/lsp4j)
15
+ (Eclipse Public License, Version 2.0) LSP4J JSON-RPC (org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.12.0 - https://github.com/eclipse/lsp4j)
16
+ (Eclipse Public License, Version 2.0) Eclipse Xtend Runtime Library (org.eclipse.xtend:org.eclipse.xtend.lib:2.24.0 - https://www.eclipse.org/Xtext/)
17
+ (Eclipse Public License, Version 2.0) Eclipse Xtend Active Annotations Library (org.eclipse.xtend:org.eclipse.xtend.lib.macro:2.24.0 - https://www.eclipse.org/Xtext/)
18
+ (Eclipse Public License, Version 2.0) Eclipse Xbase Runtime Library (org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.24.0 - https://www.eclipse.org/Xtext/)
19
+ (MIT License) scallop (org.rogach:scallop_3:4.1.0 - https://github.com/scallop/scallop)
20
+ (Apache-2.0) Scala Library (org.scala-lang:scala-library:2.13.5 - https://www.scala-lang.org/)
21
+ (Apache-2.0) scala3-library-bootstrapped (org.scala-lang:scala3-library_3:3.0.0 - https://github.com/lampepfl/dotty)
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.