|
| 1 | +package scala.compiletime |
| 2 | +package ops |
| 3 | + |
| 4 | +object int: |
| 5 | + /** Successor of a natural number where zero is the type 0 and successors are reduced as if the definition was |
| 6 | + * |
| 7 | + * ```scala |
| 8 | + * type S[N <: Int] <: Int = N match { |
| 9 | + * case 0 => 1 |
| 10 | + * case 1 => 2 |
| 11 | + * case 2 => 3 |
| 12 | + * ... |
| 13 | + * case 2147483646 => 2147483647 |
| 14 | + * } |
| 15 | + * ``` |
| 16 | + * @syntax markdown |
| 17 | + */ |
| 18 | + type S[N <: Int] <: Int |
| 19 | + |
| 20 | + /** Addition of two `Int` singleton types. |
| 21 | + * ```scala |
| 22 | + * val sum: 2 + 2 = 4 |
| 23 | + * ``` |
| 24 | + * @syntax markdown |
| 25 | + */ |
| 26 | + type +[X <: Int, Y <: Int] <: Int |
| 27 | + |
| 28 | + /** Subtraction of two `Int` singleton types. |
| 29 | + * ```scala |
| 30 | + * val sub: 4 - 2 = 2 |
| 31 | + * ``` |
| 32 | + * @syntax markdown |
| 33 | + */ |
| 34 | + type -[X <: Int, Y <: Int] <: Int |
| 35 | + |
| 36 | + /** Multiplication of two `Int` singleton types. |
| 37 | + * ```scala |
| 38 | + * val mul: 4 * 2 = 8 |
| 39 | + * ``` |
| 40 | + * @syntax markdown |
| 41 | + */ |
| 42 | + type *[X <: Int, Y <: Int] <: Int |
| 43 | + |
| 44 | + /** Integer division of two `Int` singleton types. |
| 45 | + * ```scala |
| 46 | + * val div: 5 / 2 = 2 |
| 47 | + * ``` |
| 48 | + * @syntax markdown |
| 49 | + */ |
| 50 | + type /[X <: Int, Y <: Int] <: Int |
| 51 | + |
| 52 | + /** Remainder of the division of `X` by `Y`. |
| 53 | + * ```scala |
| 54 | + * val mod: 5 % 2 = 1 |
| 55 | + * ``` |
| 56 | + * @syntax markdown |
| 57 | + */ |
| 58 | + type %[X <: Int, Y <: Int] <: Int |
| 59 | + |
| 60 | + /** Binary left shift of `X` by `Y`. |
| 61 | + * ```scala |
| 62 | + * val lshift: 1 << 2 = 4 |
| 63 | + * ``` |
| 64 | + * @syntax markdown |
| 65 | + */ |
| 66 | + type <<[X <: Int, Y <: Int] <: Int |
| 67 | + |
| 68 | + /** Binary right shift of `X` by `Y`. |
| 69 | + * ```scala |
| 70 | + * val rshift: 10 >> 1 = 5 |
| 71 | + * ``` |
| 72 | + * @syntax markdown |
| 73 | + */ |
| 74 | + type >>[X <: Int, Y <: Int] <: Int |
| 75 | + |
| 76 | + /** Binary right shift of `X` by `Y`, filling the left with zeros. |
| 77 | + * ```scala |
| 78 | + * val rshiftzero: 10 >>> 1 = 5 |
| 79 | + * ``` |
| 80 | + * @syntax markdown |
| 81 | + */ |
| 82 | + type >>>[X <: Int, Y <: Int] <: Int |
| 83 | + |
| 84 | + /** Bitwise xor of `X` and `Y`. |
| 85 | + * ```scala |
| 86 | + * val xor: 10 ^ 30 = 20 |
| 87 | + * ``` |
| 88 | + * @syntax markdown |
| 89 | + */ |
| 90 | + type ^[X <: Int, Y <: Int] <: Int |
| 91 | + |
| 92 | + /** Less-than comparison of two `Int` singleton types. |
| 93 | + * ```scala |
| 94 | + * val lt1: 4 < 2 = false |
| 95 | + * val lt2: 2 < 4 = true |
| 96 | + * ``` |
| 97 | + * @syntax markdown |
| 98 | + */ |
| 99 | + type <[X <: Int, Y <: Int] <: Boolean |
| 100 | + |
| 101 | + /** Greater-than comparison of two `Int` singleton types. |
| 102 | + * ```scala |
| 103 | + * val gt1: 4 > 2 = true |
| 104 | + * val gt2: 2 > 2 = false |
| 105 | + * ``` |
| 106 | + * @syntax markdown |
| 107 | + */ |
| 108 | + type >[X <: Int, Y <: Int] <: Boolean |
| 109 | + |
| 110 | + /** Greater-or-equal comparison of two `Int` singleton types. |
| 111 | + * ```scala |
| 112 | + * val ge1: 4 >= 2 = true |
| 113 | + * val ge2: 2 >= 3 = false |
| 114 | + * ``` |
| 115 | + * @syntax markdown |
| 116 | + */ |
| 117 | + type >=[X <: Int, Y <: Int] <: Boolean |
| 118 | + |
| 119 | + /** Less-or-equal comparison of two `Int` singleton types. |
| 120 | + * ```scala |
| 121 | + * val lt1: 4 <= 2 = false |
| 122 | + * val lt2: 2 <= 2 = true |
| 123 | + * ``` |
| 124 | + * @syntax markdown |
| 125 | + */ |
| 126 | + type <=[X <: Int, Y <: Int] <: Boolean |
| 127 | + |
| 128 | + /** Bitwise and of `X` and `Y`. |
| 129 | + * ```scala |
| 130 | + * val and1: BitwiseAnd[4, 4] = 4 |
| 131 | + * val and2: BitwiseAnd[10, 5] = 0 |
| 132 | + * ``` |
| 133 | + * @syntax markdown |
| 134 | + */ |
| 135 | + type BitwiseAnd[X <: Int, Y <: Int] <: Int |
| 136 | + |
| 137 | + /** Bitwise or of `X` and `Y`. |
| 138 | + * ```scala |
| 139 | + * val or: BitwiseOr[10, 11] = 11 |
| 140 | + * ``` |
| 141 | + * @syntax markdown |
| 142 | + */ |
| 143 | + type BitwiseOr[X <: Int, Y <: Int] <: Int |
| 144 | + |
| 145 | + /** Absolute value of an `Int` singleton type. |
| 146 | + * ```scala |
| 147 | + * val abs: Abs[-1] = 1 |
| 148 | + * ``` |
| 149 | + * @syntax markdown |
| 150 | + */ |
| 151 | + type Abs[X <: Int] <: Int |
| 152 | + |
| 153 | + /** Negation of an `Int` singleton type. |
| 154 | + * ```scala |
| 155 | + * val neg1: Neg[-1] = 1 |
| 156 | + * val neg2: Neg[1] = -1 |
| 157 | + * ``` |
| 158 | + * @syntax markdown |
| 159 | + */ |
| 160 | + type Negate[X <: Int] <: Int |
| 161 | + |
| 162 | + /** Minimum of two `Int` singleton types. |
| 163 | + * ```scala |
| 164 | + * val min: Min[-1, 1] = -1 |
| 165 | + * ``` |
| 166 | + * @syntax markdown |
| 167 | + */ |
| 168 | + type Min[X <: Int, Y <: Int] <: Int |
| 169 | + |
| 170 | + /** Maximum of two `Int` singleton types. |
| 171 | + * ```scala |
| 172 | + * val max: Max[-1, 1] = 1 |
| 173 | + * ``` |
| 174 | + * @syntax markdown |
| 175 | + */ |
| 176 | + type Max[X <: Int, Y <: Int] <: Int |
| 177 | + |
| 178 | + /** String conversion of an `Int` singleton type. |
| 179 | + * ```scala |
| 180 | + * val abs: ToString[1] = "1" |
| 181 | + * ``` |
| 182 | + * @syntax markdown |
| 183 | + */ |
| 184 | + type ToString[X <: Int] <: String |
0 commit comments