You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A special form of import is used to import implied instances. Example:
7
+
```scala
8
+
objectA {
9
+
classTC
10
+
implied tc forTC
11
+
deffgivenTC=???
12
+
}
13
+
objectB {
14
+
importA._
15
+
importimpliedA._
16
+
}
17
+
```
18
+
In the code above, the `import A._` clause of object `B` will import all members
19
+
of `A`_except_ the implied instance `tc`. Conversely, the second import `import implied A._` will import _only_ that implied instance.
20
+
21
+
Generally, a normal import clause brings all definitions except implied instances into scope whereas an `import implied` clause beings only implied instances into scope.
22
+
23
+
There are two main benefits arising from these rules:
24
+
25
+
- It is made clearer where implied instances in scope are coming from. In particular, it is not possible to hide imported implied instances in a long list of regular imports.
26
+
- It enables importing all implied instances
27
+
without importing anything else. This is particularly important since implied
28
+
instances can be anonymous, so the usual recourse of using named imports is not
0 commit comments