Skip to content

Commit

Permalink
Make singleton operations covariant
Browse files Browse the repository at this point in the history
  • Loading branch information
mbovel committed Feb 11, 2022
1 parent b472e26 commit d913504
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 93 deletions.
8 changes: 4 additions & 4 deletions library/src/scala/compiletime/ops/any.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object any:
* ```
* @syntax markdown
*/
type ==[X, Y] <: Boolean
type ==[+X, +Y] <: Boolean

/** Inequality comparison of two singleton types.
* ```scala
Expand All @@ -22,7 +22,7 @@ object any:
* ```
* @syntax markdown
*/
type !=[X, Y] <: Boolean
type !=[+X, +Y] <: Boolean

/** Tests if a type is a constant.
* ```scala
Expand All @@ -42,7 +42,7 @@ object any:
* @syntax markdown
*/
@experimental
type IsConst[X] <: Boolean
type IsConst[+X] <: Boolean

/** String conversion of a constant singleton type.
* ```scala
Expand All @@ -52,4 +52,4 @@ object any:
* @syntax markdown
*/
@experimental
type ToString[X] <: String
type ToString[+X] <: String
8 changes: 4 additions & 4 deletions library/src/scala/compiletime/ops/boolean.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object boolean:
* ```
* @syntax markdown
*/
type ![X <: Boolean] <: Boolean
type ![+X <: Boolean] <: Boolean

/** Exclusive disjunction of two `Boolean` singleton types.
* ```scala
Expand All @@ -19,7 +19,7 @@ object boolean:
* ```
* @syntax markdown
*/
type ^[X <: Boolean, Y <: Boolean] <: Boolean
type ^[+X <: Boolean, +Y <: Boolean] <: Boolean

/** Conjunction of two `Boolean` singleton types.
* ```scala
Expand All @@ -28,7 +28,7 @@ object boolean:
* ```
* @syntax markdown
*/
type &&[X <: Boolean, Y <: Boolean] <: Boolean
type &&[+X <: Boolean, +Y <: Boolean] <: Boolean

/** Disjunction of two `Boolean` singleton types.
* ```scala
Expand All @@ -37,4 +37,4 @@ object boolean:
* ```
* @syntax markdown
*/
type ||[X <: Boolean, Y <: Boolean] <: Boolean
type ||[+X <: Boolean, +Y <: Boolean] <: Boolean
32 changes: 16 additions & 16 deletions library/src/scala/compiletime/ops/double.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,39 @@ object double:
* ```
* @syntax markdown
*/
type +[X <: Double, Y <: Double] <: Double
type +[+X <: Double, +Y <: Double] <: Double

/** Subtraction of two `Double` singleton types.
* ```scala
* val sub: 4.0 - 2.0 = 2.0
* ```
* @syntax markdown
*/
type -[X <: Double, Y <: Double] <: Double
type -[+X <: Double, +Y <: Double] <: Double

/** Multiplication of two `Double` singleton types.
* ```scala
* val mul: 4.0 * 2.0 = 8.0
* ```
* @syntax markdown
*/
type *[X <: Double, Y <: Double] <: Double
type *[+X <: Double, +Y <: Double] <: Double

/** Integer division of two `Double` singleton types.
* ```scala
* val div: 5.0 / 2.0 = 2.5
* ```
* @syntax markdown
*/
type /[X <: Double, Y <: Double] <: Double
type /[+X <: Double, +Y <: Double] <: Double

/** Remainder of the division of `X` by `Y`.
* ```scala
* val mod: 5.0 % 2.0 = 1.0
* ```
* @syntax markdown
*/
type %[X <: Double, Y <: Double] <: Double
type %[+X <: Double, +Y <: Double] <: Double

/** Less-than comparison of two `Double` singleton types.
* ```scala
Expand All @@ -52,7 +52,7 @@ object double:
* ```
* @syntax markdown
*/
type <[X <: Double, Y <: Double] <: Boolean
type <[+X <: Double, +Y <: Double] <: Boolean

/** Greater-than comparison of two `Double` singleton types.
* ```scala
Expand All @@ -61,7 +61,7 @@ object double:
* ```
* @syntax markdown
*/
type >[X <: Double, Y <: Double] <: Boolean
type >[+X <: Double, +Y <: Double] <: Boolean

/** Greater-or-equal comparison of two `Double` singleton types.
* ```scala
Expand All @@ -70,7 +70,7 @@ object double:
* ```
* @syntax markdown
*/
type >=[X <: Double, Y <: Double] <: Boolean
type >=[+X <: Double, +Y <: Double] <: Boolean

/** Less-or-equal comparison of two `Double` singleton types.
* ```scala
Expand All @@ -79,15 +79,15 @@ object double:
* ```
* @syntax markdown
*/
type <=[X <: Double, Y <: Double] <: Boolean
type <=[+X <: Double, +Y <: Double] <: Boolean

/** Absolute value of an `Double` singleton type.
* ```scala
* val abs: Abs[-1.0] = 1.0
* ```
* @syntax markdown
*/
type Abs[X <: Double] <: Double
type Abs[+X <: Double] <: Double

/** Negation of an `Double` singleton type.
* ```scala
Expand All @@ -96,44 +96,44 @@ object double:
* ```
* @syntax markdown
*/
type Negate[X <: Double] <: Double
type Negate[+X <: Double] <: Double

/** Minimum of two `Double` singleton types.
* ```scala
* val min: Min[-1.0, 1.0] = -1.0
* ```
* @syntax markdown
*/
type Min[X <: Double, Y <: Double] <: Double
type Min[+X <: Double, +Y <: Double] <: Double

/** Maximum of two `Double` singleton types.
* ```scala
* val max: Max[-1.0, 1.0] = 1.0
* ```
* @syntax markdown
*/
type Max[X <: Double, Y <: Double] <: Double
type Max[+X <: Double, +Y <: Double] <: Double

/** Int conversion of a `Double` singleton type.
* ```scala
* val x: ToInt[1.0] = 1
* ```
* @syntax markdown
*/
type ToInt[X <: Double] <: Int
type ToInt[+X <: Double] <: Int

/** Long conversion of a `Double` singleton type.
* ```scala
* val x: ToLong[1.0] = 1L
* ```
* @syntax markdown
*/
type ToLong[X <: Double] <: Long
type ToLong[+X <: Double] <: Long

/** Float conversion of a `Double` singleton type.
* ```scala
* val x: ToFloat[1.0] = 1.0f
* ```
* @syntax markdown
*/
type ToFloat[X <: Double] <: Float
type ToFloat[+X <: Double] <: Float
32 changes: 16 additions & 16 deletions library/src/scala/compiletime/ops/float.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,39 @@ object float:
* ```
* @syntax markdown
*/
type +[X <: Float, Y <: Float] <: Float
type +[+X <: Float, +Y <: Float] <: Float

/** Subtraction of two `Float` singleton types.
* ```scala
* val sub: 4.0f - 2.0f = 2.0f
* ```
* @syntax markdown
*/
type -[X <: Float, Y <: Float] <: Float
type -[+X <: Float, +Y <: Float] <: Float

/** Multiplication of two `Float` singleton types.
* ```scala
* val mul: 4.0f * 2.0f = 8.0f
* ```
* @syntax markdown
*/
type *[X <: Float, Y <: Float] <: Float
type *[+X <: Float, +Y <: Float] <: Float

/** Integer division of two `Float` singleton types.
* ```scala
* val div: 5.0f / 2.0f = 2.5f
* ```
* @syntax markdown
*/
type /[X <: Float, Y <: Float] <: Float
type /[+X <: Float, +Y <: Float] <: Float

/** Remainder of the division of `X` by `Y`.
* ```scala
* val mod: 5.0f % 2.0f = 1.0f
* ```
* @syntax markdown
*/
type %[X <: Float, Y <: Float] <: Float
type %[+X <: Float, +Y <: Float] <: Float

/** Less-than comparison of two `Float` singleton types.
* ```scala
Expand All @@ -52,7 +52,7 @@ object float:
* ```
* @syntax markdown
*/
type <[X <: Float, Y <: Float] <: Boolean
type <[+X <: Float, +Y <: Float] <: Boolean

/** Greater-than comparison of two `Float` singleton types.
* ```scala
Expand All @@ -61,7 +61,7 @@ object float:
* ```
* @syntax markdown
*/
type >[X <: Float, Y <: Float] <: Boolean
type >[+X <: Float, +Y <: Float] <: Boolean

/** Greater-or-equal comparison of two `Float` singleton types.
* ```scala
Expand All @@ -70,7 +70,7 @@ object float:
* ```
* @syntax markdown
*/
type >=[X <: Float, Y <: Float] <: Boolean
type >=[+X <: Float, +Y <: Float] <: Boolean

/** Less-or-equal comparison of two `Float` singleton types.
* ```scala
Expand All @@ -79,15 +79,15 @@ object float:
* ```
* @syntax markdown
*/
type <=[X <: Float, Y <: Float] <: Boolean
type <=[+X <: Float, +Y <: Float] <: Boolean

/** Absolute value of an `Float` singleton type.
* ```scala
* val abs: Abs[-1.0f] = 1.0f
* ```
* @syntax markdown
*/
type Abs[X <: Float] <: Float
type Abs[+X <: Float] <: Float

/** Negation of an `Float` singleton type.
* ```scala
Expand All @@ -96,44 +96,44 @@ object float:
* ```
* @syntax markdown
*/
type Negate[X <: Float] <: Float
type Negate[+X <: Float] <: Float

/** Minimum of two `Float` singleton types.
* ```scala
* val min: Min[-1.0f, 1.0f] = -1.0f
* ```
* @syntax markdown
*/
type Min[X <: Float, Y <: Float] <: Float
type Min[+X <: Float, +Y <: Float] <: Float

/** Maximum of two `Float` singleton types.
* ```scala
* val max: Max[-1.0f, 1.0f] = 1.0f
* ```
* @syntax markdown
*/
type Max[X <: Float, Y <: Float] <: Float
type Max[+X <: Float, +Y <: Float] <: Float

/** Int conversion of a `Float` singleton type.
* ```scala
* val x: ToInt[1.0f] = 1
* ```
* @syntax markdown
*/
type ToInt[X <: Float] <: Int
type ToInt[+X <: Float] <: Int

/** Long conversion of a `Float` singleton type.
* ```scala
* val x: ToLong[1.0f] = 1L
* ```
* @syntax markdown
*/
type ToLong[X <: Float] <: Long
type ToLong[+X <: Float] <: Long

/** Double conversion of a `Float` singleton type.
* ```scala
* val x: ToDouble[1.0f] = 1.0
* ```
* @syntax markdown
*/
type ToDouble[X <: Float] <: Double
type ToDouble[+X <: Float] <: Double
Loading

0 comments on commit d913504

Please sign in to comment.