Skip to content

Commit 2aa5950

Browse files
Merge pull request #3573 from k0ala/doc-ref-newtypes-typos
Fix typos in documentation: reference > new types
2 parents 924234f + 8258a32 commit 2aa5950

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

docs/docs/reference/implicit-function-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ An implicit function type describes functions with implicit parameters. Example:
1010
A value of implicit function type is applied to implicit arguments, in
1111
the same way a method with implicit parameters is applied. For instance:
1212

13-
implicit ctx: Context = ...
13+
implicit val ctx: Context = ...
1414

1515
def f(x: Int): Contextual[Int] = ...
1616

@@ -93,7 +93,7 @@ With that setup, the table construction code above compiles and expands to:
9393
cell("top right")($r)
9494
}($t)
9595
row { implicit $r: Row =>
96-
cell("botttom left")($r)
96+
cell("bottom left")($r)
9797
cell("bottom right")($r)
9898
}($t)
9999
}

docs/docs/reference/phantom-types.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ When saying that they have no effect on the runtime we do not only mean side eff
1616
like IO, field mutation, exceptions and so on. We also imply that if a function receives
1717
a phantom its result will not be affected by this argument.
1818

19-
As phantom do not live at runtime they cannot be subtypes of `scala.Any`, which defines
19+
As phantoms do not live at runtime they cannot be subtypes of `scala.Any`, which defines
2020
methods such as `hashCode`, `equals`, `getClass`, `asInstanceOf` and `isInstanceOf`.
2121
All these operations cannot exist on phantoms as there will not be an underlying object
2222
instance at runtime. At first glance this could look like a limitation, but in fact not
@@ -49,13 +49,13 @@ In fact we allow multiple phantom universes to exist.
4949
+---------+ +-------------------+ +------------------------+
5050
```
5151

52-
Inside a universe it types support the full Dotty type system. But we cannot mix types from
53-
different universes with `&`, `|` or in type bounds. Each type must be fully defined one universe.
52+
Inside a universe the full Dotty type system is supported. But we cannot mix types from
53+
different universes with `&`, `|` or in type bounds. Each type must be fully defined in a single universe.
5454

5555

5656
Implement your own phantom type
5757
-------------------------------
58-
Phantom types are definded by an `object` extending `scala.Phantom`. This object will represent
58+
Phantom types are defined by an `object` extending `scala.Phantom`. This object will represent
5959
a universe of phantom types that is completely separated from types in `scala.Any` or other
6060
phantom universes. We can define our phantom universe `MyPhantoms`.
6161

@@ -78,7 +78,7 @@ of the phantom types in `MyPhantoms`, these bounds are `protected` and can not b
7878
from outside `MyPhantoms` unless an alias is defined for them.
7979

8080
New phantom types can be defined using `type XYZ <: OtherPhantom` (where `>: MyPhantom.Nothing`
81-
will be inferred), this would be the equivalent of `class XYZ extends OtherClass` on a types
81+
will be inferred), this would be the equivalent of `class XYZ extends OtherClass` on types
8282
only (no runtime definitions). Or aliased with `type MyAny = OtherPhantom`. Within `MyPhantoms`
8383
it is possible to refer to `MyPhantoms.Any` and `MyPhantoms.Nothing` with `this.Any` and
8484
`this.Nothing` (or just `Any` and `Nothing` but not recommended). Using this we will define
@@ -94,7 +94,7 @@ object MyPhantoms extends Phantom {
9494
```
9595

9696
Values of phantom type can be created using the `protected def assume`. This value can be
97-
used as a value of this phantom type as it's type is `this.Nothing` (or `MyPhantoms.Nothing`).
97+
used as a value of this phantom type as its type is `this.Nothing` (or `MyPhantoms.Nothing`).
9898
Usually this value will be used to define a `implicit def` that returns the phantom with a more
9999
precise type. In our example we will only create values of type `Pinky` and `Clyde`
100100

@@ -136,8 +136,8 @@ What happens with Phantoms at runtime?
136136

137137
Disclaimer: Most of phantom erasure is implemented, but not all of is has been merged in `dotty/master` yet.
138138

139-
As phantom have no effect on the result of a method invocation we just remove them for the call an definition.
140-
The evaluation of the phantom parameter is still be done unless it can be optimized away.
139+
As phantoms have no effect on the result of a method invocation we just remove them for the call and definition.
140+
The evaluation of the phantom parameter is still done unless it can be optimized away.
141141
By removing them we also restrict overloading as `def f()` and `def f(x: MyPhantom)` will
142142
have the same signature in the bytecode, just use different names to avoid this.
143143

docs/docs/reference/singleton-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: doc-page
33
title: "Literal Singleton Types"
44
---
55

6-
Literal Singleton Types allows primitive literals to be used as types. For example:
6+
Literal Singleton Types allow primitive literals to be used as types. For example:
77

88
```scala
99
val t: 42 = 42

docs/docs/reference/union-types.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ Union types are dual of intersection types. Values of type `A | B` are
2626
all values of type `A` and all values of type `B`. `|` is _commutative_:
2727
`A | B` is the same type as `B | A`.
2828

29-
The compiler will assign an expression a union type only if such a
29+
The compiler will assign a union type to an expression only if such a
3030
type is explicitly given.
31-
This can be seen in the folling REPL
32-
transcript:
31+
This can be seen in the following REPL transcript:
3332

3433
```scala
3534
scala> val password = Password(123)
@@ -45,7 +44,7 @@ val either: Password | UserName = UserName(Eve)
4544
The type of `res2` is `Object & Product`, which is a supertype of
4645
`UserName` and `Product`, but not the least supertype `Password |
4746
UserName`. If we want the least supertype, we have to give it
48-
explicitely, as is done for the type of `either`. More precisely, the
47+
explicitly, as is done for the type of `either`. More precisely, the
4948
typechecker will _widen_ a union type to a non-union type when
5049
inferring the type of `val` or `var`, or the result type of a `def`,
5150
or the argument to pass for a type parameter. The widened type of `A

0 commit comments

Comments
 (0)