Skip to content

Commit a0a3742

Browse files
Modularise compiletime primitive ops
1 parent 9acec6a commit a0a3742

File tree

4 files changed

+68
-66
lines changed

4 files changed

+68
-66
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package scala.compiletime
2+
package ops
3+
4+
object any:
5+
/** Equality comparison of two singleton types.
6+
* ```scala
7+
* val eq1: 1 == 1 = true
8+
* val eq2: 1 == "1" = false
9+
* val eq3: "1" == "1" = true
10+
* ```
11+
*/
12+
type ==[X, Y] <: Boolean
13+
14+
/** Inequality comparison of two singleton types.
15+
* ```scala
16+
* val eq1: 1 != 1 = false
17+
* val eq2: 1 != "1" = true
18+
* val eq3: "1" != "1" = false
19+
* ```
20+
*/
21+
type !=[X, Y] <: Boolean
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package scala.compiletime
2+
package ops
3+
4+
object boolean:
5+
6+
/** Negation of a `Boolean` singleton type.
7+
* ```scala
8+
* val notFalse: ![false] = true
9+
* val notTrue: ![true] = false
10+
* ```
11+
*/
12+
type ![X <: Boolean] <: Boolean
13+
14+
/** Exclusive disjunction of two `Boolean` singleton types.
15+
* ```scala
16+
* val a: true ^ true = false
17+
* val b: false ^ true = true
18+
* ```
19+
*/
20+
type ^[X <: Boolean, Y <: Boolean] <: Boolean
21+
22+
/** Conjunction of two `Boolean` singleton types.
23+
* ```scala
24+
* val a: true && true = true
25+
* val b: false && true = false
26+
* ```
27+
*/
28+
type &&[X <: Boolean, Y <: Boolean] <: Boolean
29+
30+
/** Disjunction of two `Boolean` singleton types.
31+
* ```scala
32+
* val a: true || false = true
33+
* val b: false || false = false
34+
* ```
35+
*/
36+
type ||[X <: Boolean, Y <: Boolean] <: Boolean

library/src/scala/compiletime/ops/package.scala renamed to library/src/scala/compiletime/ops/int.scala

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,7 @@
11
package scala.compiletime
22
package ops
33

4-
object any {
5-
/** Equality comparison of two singleton types.
6-
* ```scala
7-
* val eq1: 1 == 1 = true
8-
* val eq2: 1 == "1" = false
9-
* val eq3: "1" == "1" = true
10-
* ```
11-
*/
12-
type ==[X, Y] <: Boolean
13-
14-
/** Inequality comparison of two singleton types.
15-
* ```scala
16-
* val eq1: 1 != 1 = false
17-
* val eq2: 1 != "1" = true
18-
* val eq3: "1" != "1" = false
19-
* ```
20-
*/
21-
type !=[X, Y] <: Boolean
22-
}
23-
24-
object string {
25-
/** Concatenation of two `String` singleton types.
26-
* ```scala
27-
* val hello: "hello " + "world" = "hello world"
28-
* ```
29-
*/
30-
type +[X <: String, Y <: String] <: String
31-
}
32-
33-
object int {
4+
object int:
345
/** Addition of two `Int` singleton types.
356
* ```scala
367
* val sum: 2 + 2 = 4
@@ -176,39 +147,3 @@ object int {
176147
* ```
177148
*/
178149
type ToString[X <: Int] <: String
179-
}
180-
181-
object boolean {
182-
183-
/** Negation of a `Boolean` singleton type.
184-
* ```scala
185-
* val notFalse: ![false] = true
186-
* val notTrue: ![true] = false
187-
* ```
188-
*/
189-
type ![X <: Boolean] <: Boolean
190-
191-
/** Exclusive disjunction of two `Boolean` singleton types.
192-
* ```scala
193-
* val a: true ^ true = false
194-
* val b: false ^ true = true
195-
* ```
196-
*/
197-
type ^[X <: Boolean, Y <: Boolean] <: Boolean
198-
199-
/** Conjunction of two `Boolean` singleton types.
200-
* ```scala
201-
* val a: true && true = true
202-
* val b: false && true = false
203-
* ```
204-
*/
205-
type &&[X <: Boolean, Y <: Boolean] <: Boolean
206-
207-
/** Disjunction of two `Boolean` singleton types.
208-
* ```scala
209-
* val a: true || false = true
210-
* val b: false || false = false
211-
* ```
212-
*/
213-
type ||[X <: Boolean, Y <: Boolean] <: Boolean
214-
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package scala.compiletime
2+
package ops
3+
4+
object string:
5+
/** Concatenation of two `String` singleton types.
6+
* ```scala
7+
* val hello: "hello " + "world" = "hello world"
8+
* ```
9+
*/
10+
type +[X <: String, Y <: String] <: String

0 commit comments

Comments
 (0)