我定义了以下方法:
def add(
prefix: List[String],
resourceName: String,
subTree: ResourceTree): ResourceTree = {
//import ResourceTreeInstances.semigroupInstance
implicit val dummyInstance = ResourceTreeInstances.semigroupInstance
// Make a resource tree with a single path.
def mkSinglePathRT(gPrefix: List[String]): ResourceTree = ???
this |+| mkSinglePathRT(prefix)
}
如您所见,我需要使用| + |在Cats库中定义的Semigroup
方法。我Semigroup
ResourceTree
|+|
的实例,但使用注释导入导入它不起作用(找不到dummyInstance
运算符)。上面的$.each( res['data'], function( key, value ) {
htmlString+='<select>'; // WRONG since your target Element is the Select element
htmlString+='<option>'+value.state_name+'</option>';
htmlString+='</select>';
//console.log( key + ": " + value.name );
});
$('#state').empty().append(htmlString);
可以解决问题,但这看起来并不合适。
有关为什么实例未被此导入提出的任何想法?