Skip to content

Commit c45b7c9

Browse files
committed
More doc pages updates
1 parent 280f094 commit c45b7c9

25 files changed

+64
-64
lines changed

docs/docs/internals/explicit-nulls.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ The reason for casting to `x.type & T`, as opposed to just `T`, is that it allow
111111
support flow typing for paths of length greater than one.
112112

113113
```scala
114-
abstract class Node:
114+
abstract class Node with
115115
val x: String
116116
val next: Node | Null
117117

docs/docs/reference/changed-features/implicit-resolution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ no longer applies.
4444

4545
given a: A = A()
4646

47-
object o:
47+
object o with
4848
given b: B = B()
4949
type C
5050
```

docs/docs/reference/changed-features/numeric-literals.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ whole numbers with a given radix, for numbers with a decimal point, and for
8686
numbers that can have both a decimal point and an exponent:
8787

8888
```scala
89-
object FromDigits:
89+
object FromDigits with
9090

9191
/** A subclass of `FromDigits` that also allows to convert whole
9292
* number literals with a radix other than 10
@@ -203,7 +203,7 @@ into a macro, i.e. make it an inline method with a splice as right-hand side.
203203
To do this, replace the `FromDigits` instance in the `BigFloat` object by the following two definitions:
204204

205205
```scala
206-
object BigFloat:
206+
object BigFloat with
207207
...
208208

209209
class FromDigits extends FromDigits.Floating[BigFloat] with

docs/docs/reference/changed-features/pattern-matching.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ For example:
100100
<!-- To be kept in sync with tests/new/patmat-spec.scala -->
101101

102102
```scala
103-
object Even:
103+
object Even with
104104
def unapply(s: String): Boolean = s.size % 2 == 0
105105

106106
"even" match
@@ -130,7 +130,7 @@ class FirstChars(s: String) extends Product with
130130
def productArity: Int = ???
131131
def productElement(n: Int): Any = ???
132132

133-
object FirstChars:
133+
object FirstChars with
134134
def unapply(s: String): FirstChars = new FirstChars(s)
135135

136136
"Hi!" match
@@ -151,7 +151,7 @@ class Nat(val x: Int) with
151151
def get: Int = x
152152
def isEmpty = x < 0
153153

154-
object Nat:
154+
object Nat with
155155
def unapply(x: Int): Nat = new Nat(x)
156156

157157
5 match
@@ -167,7 +167,7 @@ object Nat:
167167
- Pattern-matching on exactly `N` patterns with types `P1, P2, ..., PN`
168168

169169
```Scala
170-
object ProdEmpty:
170+
object ProdEmpty with
171171
def _1: Int = ???
172172
def _2: String = ???
173173
def isEmpty = true
@@ -199,7 +199,7 @@ type X = {
199199
<!-- To be kept in sync with tests/new/patmat-spec.scala -->
200200

201201
```scala
202-
object CharList:
202+
object CharList with
203203
def unapplySeq(s: String): Option[Seq[Char]] = Some(s.toList)
204204

205205
"example" match
@@ -221,7 +221,7 @@ object CharList:
221221

222222
```Scala
223223
class Foo(val name: String, val children: Int *)
224-
object Foo:
224+
object Foo with
225225
def unapplySeq(f: Foo): Option[(String, Seq[Int])] =
226226
Some((f.name, f.children))
227227

docs/docs/reference/changed-features/structural-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ defines the necessary `selectDynamic` member.
152152
`Vehicle` could also extend some other subclass of `scala.Selectable` that implements `selectDynamic` and `applyDynamic` differently. But if it does not extend a `Selectable` at all, the code would no longer typecheck:
153153

154154
```scala
155-
trait Vehicle:
155+
trait Vehicle with
156156
val wheels: Int
157157

158158
val i3 = new Vehicle: // i3: Vehicle

docs/docs/reference/contextual/context-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ With that setup, the table construction code above compiles and expands to:
116116
As a larger example, here is a way to define constructs for checking arbitrary postconditions using an extension method `ensuring` so that the checked result can be referred to simply by `result`. The example combines opaque type aliases, context function types, and extension methods to provide a zero-overhead abstraction.
117117

118118
```scala
119-
object PostConditions:
119+
object PostConditions with
120120
opaque type WrappedResult[T] = T
121121

122122
def result[T](using r: WrappedResult[T]): T = r

docs/docs/reference/contextual/derivation-macro.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ import scala.quoted._
142142
trait Eq[T]:
143143
def eqv(x: T, y: T): Boolean
144144

145-
object Eq:
145+
object Eq with
146146
given Eq[String] with
147147
def eqv(x: String, y: String) = x == y
148148

@@ -195,7 +195,7 @@ object Eq:
195195
end derived
196196
end Eq
197197

198-
object Macro3:
198+
object Macro3 with
199199
extension [T](inline x: T)
200200
inline def === (inline y: T)(using eq: Eq[T]): Boolean = eq.eqv(x, y)
201201

docs/docs/reference/contextual/derivation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ They also provide minimal term level infrastructure to allow higher level librar
4040
derivation support.
4141

4242
```scala
43-
sealed trait Mirror:
43+
sealed trait Mirror with
4444

4545
/** the type being mirrored */
4646
type MirroredType
@@ -57,7 +57,7 @@ sealed trait Mirror:
5757
/** The names of the elements of the type */
5858
type MirroredElemLabels <: Tuple
5959

60-
object Mirror:
60+
object Mirror with
6161

6262
/** The Mirror for a product type */
6363
trait Product extends Mirror:
@@ -242,7 +242,7 @@ inline def summonAll[T <: Tuple]: List[Eq[_]] =
242242
trait Eq[T]:
243243
def eqv(x: T, y: T): Boolean
244244

245-
object Eq:
245+
object Eq with
246246
given Eq[Int] with
247247
def eqv(x: Int, y: Int) = x == y
248248

docs/docs/reference/contextual/given-imports.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ title: "Importing Givens"
66
A special form of import wildcard selector is used to import given instances. Example:
77

88
```scala
9-
object A:
9+
object A with
1010
class TC
1111
given tc: TC = ???
1212
def f(using TC) = ???
1313

14-
object B:
14+
object B with
1515
import A._
1616
import A.given
1717
...
@@ -22,7 +22,7 @@ of `A` _except_ the given instance `tc`. Conversely, the second import `import A
2222
The two import clauses can also be merged into one:
2323

2424
```scala
25-
object B:
25+
object B with
2626
import A.{given, _}
2727
...
2828
```
@@ -58,7 +58,7 @@ Importing all given instances of a parameterized type is expressed by wildcard a
5858
For instance, assuming the object
5959

6060
```scala
61-
object Instances:
61+
object Instances with
6262
given intOrd: Ordering[Int] = ...
6363
given listOrd[T: Ordering]: Ordering[List[T]] = ...
6464
given ec: ExecutionContext = ...

docs/docs/reference/contextual/multiversal-equality.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import annotation.implicitNotFound
5454
@implicitNotFound("Values of types ${L} and ${R} cannot be compared with == or !=")
5555
sealed trait CanEqual[-L, -R]
5656

57-
object CanEqual:
57+
object CanEqual with
5858
object derived extends CanEqual[Any, Any]
5959
```
6060

docs/docs/reference/dropped-features/delayed-init.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ for benchmarking! Also, if you want to access the command line arguments,
2020
you need to use an explicit `main` method for that.
2121

2222
```scala
23-
object Hello:
23+
object Hello with
2424
def main(args: Array[String]) =
2525
println(s"Hello, ${args(0)}")
2626
```

docs/docs/reference/enums/adts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ enum Option[+T] with
6767
case None => false
6868
case some => true
6969

70-
object Option:
70+
object Option with
7171

7272
def apply[T >: Null](x: T): Option[T] =
7373
if x == null then None else Some(x)

docs/docs/reference/enums/enums.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: "Enumerations"
66
An enumeration is used to define a type consisting of a set of named values.
77

88
```scala
9-
enum Color:
9+
enum Color with
1010
case Red, Green, Blue
1111
```
1212

@@ -79,7 +79,7 @@ end Planet
7979
It is also possible to define an explicit companion object for an enum:
8080

8181
```scala
82-
object Planet:
82+
object Planet with
8383
def main(args: Array[String]) =
8484
val earthWeight = args(0).toDouble
8585
val mass = earthWeight / Earth.surfaceGravity

docs/docs/reference/metaprogramming/erased-terms.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class Off extends State
2020

2121
@implicitNotFound("State must be Off")
2222
class IsOff[S <: State]
23-
object IsOff:
23+
object IsOff with
2424
given isOff: IsOff[Off] = new IsOff[Off]
2525

2626
class Machine[S <: State] with
@@ -118,14 +118,14 @@ final class Off extends State
118118

119119
@implicitNotFound("State must be Off")
120120
class IsOff[S <: State]
121-
object IsOff:
121+
object IsOff with
122122
// will not be called at runtime for turnedOn, the
123123
// compiler will only require that this evidence exists
124124
given IsOff[Off] = new IsOff[Off]
125125

126126
@implicitNotFound("State must be On")
127127
class IsOn[S <: State]
128-
object IsOn:
128+
object IsOn with
129129
// will not exist at runtime, the compiler will only
130130
// require that this evidence exists at compile time
131131
erased given IsOn[On] = new IsOn[On]
@@ -135,7 +135,7 @@ class Machine[S <: State] private () with
135135
def turnedOn(using erased ev: IsOff[S]): Machine[On] = new Machine[On]
136136
def turnedOff(using erased ev: IsOn[S]): Machine[Off] = new Machine[Off]
137137

138-
object Machine:
138+
object Machine with
139139
def newMachine(): Machine[Off] = new Machine[Off]
140140

141141
@main def test =
@@ -174,7 +174,7 @@ class Machine[S <: State] with
174174
case _: On => new Machine[Off]
175175
case _: Off => error("Turning off an already turned off machine")
176176

177-
object Machine:
177+
object Machine with
178178
def newMachine(): Machine[Off] =
179179
println("newMachine")
180180
new Machine[Off]

docs/docs/reference/metaprogramming/inline.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ title: Inline
99
definition will be inlined at the point of use. Example:
1010

1111
```scala
12-
object Config:
12+
object Config with
1313
inline val logging = false
1414

15-
object Logger:
15+
object Logger with
1616

1717
private var indent = 0
1818

@@ -235,7 +235,7 @@ inline val four: 4 = 4
235235
It is also possible to have inline vals of types that do not have a syntax, such as `Short(4)`.
236236

237237
```scala
238-
trait InlineConstants:
238+
trait InlineConstants with
239239
inline val myShort: Short
240240

241241
object Constants extends InlineConstants:

docs/docs/reference/metaprogramming/macros-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ given AsFunction1[T, U]: Conversion[Expr[T => U], Expr[T] => Expr[U]] with
211211
```
212212
This assumes an extractor
213213
```scala
214-
object Lambda:
214+
object Lambda with
215215
def unapply[T, U](x: Expr[T => U]): Option[Expr[T] => Expr[U]]
216216
```
217217
Once we allow inspection of code via extractors, it’s tempting to also

docs/docs/reference/metaprogramming/macros.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ In some cases we want to remove the lambda from the code, for this we provide th
168168
describing a function into a function mapping trees to trees.
169169

170170
```scala
171-
object Expr:
171+
object Expr with
172172
...
173173
def betaReduce[...](...)(...): ... = ...
174174
```
@@ -231,7 +231,7 @@ a compiler through staging.
231231
```scala
232232
import scala.quoted._
233233

234-
enum Exp:
234+
enum Exp with
235235
case Num(n: Int)
236236
case Plus(e1: Exp, e2: Exp)
237237
case Var(x: String)
@@ -284,7 +284,7 @@ The `Expr.apply` method is defined in package `quoted`:
284284
```scala
285285
package quoted
286286

287-
object Expr:
287+
object Expr with
288288
...
289289
def apply[T: ToExpr](x: T)(using Quotes): Expr[T] =
290290
summon[ToExpr[T]].toExpr(x)
@@ -391,7 +391,7 @@ a macro library and a quoted program. For instance, here’s the `assert` macro
391391
again together with a program that calls `assert`.
392392

393393
```scala
394-
object Macros:
394+
object Macros with
395395

396396
inline def assert(inline expr: Boolean): Unit =
397397
${ assertImpl('expr) }
@@ -525,7 +525,7 @@ Assume we have two methods, one `map` that takes an `Expr[Array[T]]` and a
525525
function `f` and one `sum` that performs a sum by delegating to `map`.
526526

527527
```scala
528-
object Macros:
528+
object Macros with
529529

530530
def map[T](arr: Expr[Array[T]], f: Expr[T] => Expr[Unit])
531531
(using Type[T], Quotes): Expr[Unit] = '{

docs/docs/reference/new-types/intersection-types.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Used on types, the `&` operator creates an intersection type.
1010
The type `S & T` represents values that are of the type `S` and `T` at the same time.
1111

1212
```scala
13-
trait Resettable:
13+
trait Resettable with
1414
def reset(): Unit
1515

1616
trait Growable[T]:
@@ -34,10 +34,10 @@ If a member appears in both `A` and `B`, its type in `A & B` is the intersection
3434
of its type in `A` and its type in `B`. For instance, assume the definitions:
3535

3636
```scala
37-
trait A:
37+
trait A with
3838
def children: List[A]
3939

40-
trait B:
40+
trait B with
4141
def children: List[B]
4242

4343
val x: A & B = new C

docs/docs/reference/other-new-features/creator-applications.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This works since a companion object with two `apply` methods
2020
is generated together with the class. The object looks like this:
2121

2222
```scala
23-
object StringBuilder:
23+
object StringBuilder with
2424
inline def apply(s: String): StringBuilder = new StringBuilder(s)
2525
inline def apply(): StringBuilder = new StringBuilder()
2626
```

0 commit comments

Comments
 (0)