Skip to content

Commit

Permalink
Fix REPL not failing where real code would fail by removing :fail and…
Browse files Browse the repository at this point in the history
… adding a comment
  • Loading branch information
Luka Jacobowitz committed Jul 12, 2017
1 parent 723da89 commit 10a5db5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/src/main/tut/typeclasses/imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ o.orEmpty
```

If you'd like to import à la carte, you can do so, by importing from `cats.instances` for the type class instances and `cats.syntax` for syntax enrichment.
For example, if you'd like to import the `Semigroup` instance for `String` and the corresponding syntax:
For example, if you'd like to import the `Monoid` instance for `String` and the corresponding syntax:
```tut:book
import cats.instances.string._
import cats.syntax.semigroup._
import cats.syntax.monoid._
"Hello, " |+| "World!"
```
Expand All @@ -66,14 +66,14 @@ NonEmptyList.of(1,2) <+> NonEmptyList.of(3,4)
**Note**: Beware that if you import a type class instance or its syntax twice, you will receive conflicting implicits with a less than helpful error message.
This usually happens when importing different type classes in the same hierarchy or when importing syntax enrichment for all type classes using `cats.syntax.all._` or `cats.implicits._` together with a more specific import like `cats.syntax.option._` or `cats.instances.either._`.
Below is an example of this phenomenon:
```tut:fail
```tut:silent
import cats.instances.all._
import cats.syntax.semigroup._
val x = -2 |+| 1
//now we also need access to isEmpty from Monoid
import cats.syntax.monoid._
(x |+| 1).isEmpty
(x |+| 1).isEmpty //error: value |+| is not a member of Int
```

Compilation fails on the second invocation of `|+|` because we now have conflicting implicits from `Monoid` and `Semigroup`.

0 comments on commit 10a5db5

Please sign in to comment.