2014-12-05 35 views
2

我需要使用scalaz中的EqualsOps(===),但是导入scalaz.Scalaz._时会给我一个与anorm get方法的命名冲突。如何在scalaz中导入===

以下是编译错误:

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

我怎样才能把===为范围,而不会与ANORM冲突?

回答

3

删除import scalaz.Scalaz._

假设你是比较原语,

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

如果是别的东西,说弦,更换std.anyVal._,用std.string._

本质上,第一行为您提供了各种类型的scalaz(如果您不想要这样,请用scalaz.std替换std,并使用scalaz.syntax来更改语法)。

第2行为您提供了基元的隐式转换。这可以让您将原语视为Equal,或者实际上与其他任何类型的特拉斯(Monoid等) 一样,第3行为您提供EqualOps,这使您可以使用===语法,其中的内容可以是Equal

希望可以帮到