Skip to content

Commit fed2dc2

Browse files
authored
Merge pull request #2992 from LannyRipple/patch-1
Update phantom-types.md (typos/grammar)
2 parents ca30985 + e0222c7 commit fed2dc2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/docs/reference/phantom-types.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ package scala
6868
trait Phantom { // only an `object` can extend this trait
6969
protected final type Any // not a subtype of scala.Any
7070
protected final type Nothing // subtype of every subtype of this.Any
71-
protected final def assume: this.Nothig
71+
protected final def assume: this.Nothing
7272
}
7373
```
7474

@@ -81,8 +81,8 @@ New phantom types can be defined using `type XYZ <: OtherPhantom` (where `>: MyP
8181
will be inferred), this would be the equivalent of `class XYZ extends OtherClass` on a 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
84-
`this.Nothing` (or just `Any` and `Nothing` but not recommended). Using this we will define
85-
four the four phantoms: `Inky`, `Blinky`, `Pinky` and `Clyde`.
84+
`this.Nothing` (or just `Any` and `Nothing` but not recommended). Using this we will define
85+
the four phantoms: `Inky`, `Blinky`, `Pinky` and `Clyde`.
8686

8787
```scala
8888
object MyPhantoms extends Phantom {
@@ -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.Nothig` (or `MyPhantoms.Nothing`).
97+
used as a value of this phantom type as it's 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

@@ -109,7 +109,7 @@ object MyPhantoms extends Phantom {
109109

110110
### Using the phantoms
111111

112-
From the user of the phantom type there is almost no difference, except for stronger type guarantees.
112+
For the user of the phantom type there is almost no difference, except for stronger type guarantees.
113113
We can look at the following simple application:
114114

115115
```scala
@@ -123,7 +123,7 @@ object MyApp {
123123
}
124124
```
125125

126-
Note given the way we defined the phantoms it is impossible to call the `hide` as we did not
126+
Note that given the way we defined the phantoms it is impossible to call `hide` as we did not
127127
expose any value of type `Blinky` to the user. We cannot call `hide(MyPhantoms.assume)` as
128128
`assume` is protected, `hide(null.asInstanceOf[Blinky])` does not compile because it is impossible
129129
to cast to a phantom and `hide(throw new Exception)` (or `hide(???)`) does not compile as `throw` of

0 commit comments

Comments
 (0)