相关疑难解决方法(0)

使用无形的任何维度的Scala矢量

我需要测量n维欧几里得空间的距离,所以我必须要创建多维向量,并能够比较它们的尺寸和执行像"+"或一些基本操作" - ".所以,我想我会使用类型类+无形,如下所示:

在Scala中实现通用Vector

但是在投入了大量时间之后,我仍然无法理解如何实现这一点.我的意思是,我可以理解类型类背后的想法可以使用它们,但不知道如何对它们应用无形.提前感谢任何帮助,比如至少最简单的示例,展示如何使用无形的类型类.

math scala vector shapeless

9
推荐指数
1
解决办法
859
查看次数

Scala对带有两个隐式参数的重载定义的模糊引用

lazy val productService = BeanLookup [ProductDataService]

object  BeanLookup {

    def apply[T](implicit manifest: Manifest[T], context: ActorContext) =    {
    val beanLookup =
      context.actorFor("/user/spring/beanLookup")
    Await.result(
      (beanLookup.ask(LookupBean(manifest.erasure))(timeout)).mapTo[T](manifest),
      timeout.duration)   }

  def apply[T](implicit manifest: Manifest[T], system: ActorSystem) =   {
    val beanLookup =
      system.actorFor("/user/spring/beanLookup")
    Await.result(
      (beanLookup.ask(LookupBean(manifest.erasure))(timeout)).mapTo[T](manifest),
      timeout.duration)   } }
Run Code Online (Sandbox Code Playgroud)

scalac抱怨:

 scala: ambiguous reference to overloaded definition,
both method apply in object BeanLookup of type (implicit manifest: Manifest[com.tooe.core.service.LocationCategoryDataService], implicit system: akka.actor.ActorSystem)com.tooe.core.service.LocationCategoryDataService
and  method apply in object BeanLookup of type (implicit manifest: Manifest[com.tooe.core.service.LocationCategoryDataService], implicit context: akka.actor.ActorContext)com.tooe.core.service.LocationCategoryDataService 
Run Code Online (Sandbox Code Playgroud)

scala overloading implicit erasure

1
推荐指数
1
解决办法
1973
查看次数

标签 统计

scala ×2

erasure ×1

implicit ×1

math ×1

overloading ×1

shapeless ×1

vector ×1