eggplantbr
eggplantbr

Reputation: 185

How to import === in scalaz

I need to use the EqualsOps (===) from scalaz, but importing scalaz.Scalaz._ gives me a naming conflict with anorm's get method.

Here is the compilation error:

reference to get is ambiguous;
[error] it is imported twice in the same scope by
[error] import scalaz.Scalaz._
[error] and import anorm.SqlParser._

How can I bring === into scope without causing the conflict with anorm?

Upvotes: 3

Views: 451

Answers (1)

triggerNZ
triggerNZ

Reputation: 4771

Remove import scalaz.Scalaz._

Assuming you are comparing primitives,

import scalaz._
import std.anyVal._
import syntax.equal._

If it is something else, say strings, replace std.anyVal._, with std.string._.

Essentially, the first line gives you the various scalaz types (if you don't want this, replace std with scalaz.std, and syntax with scalaz.syntax).

Line 2 gives you the implicit conversions for the primitives. That lets you treat primitives as Equal, or actually as any of the other scalaz typeclasses, (Monoid, etc.) Line 3 gives you EqualOps, which enables you to use the === syntax with things that can be Equal.

Hope that helps

Upvotes: 5

Related Questions