变形和小精灵scala:如何返回调用'as'的结果?

变形和小精灵scala:如何返回调用'as'的结果?,scala,gremlin,shapeless,Scala,Gremlin,Shapeless,因此,我将此函数调用为(gremlincala): 这使得它可以编译,但我仍然不能使用这个函数!每当我打电话给它,它都会向我抱怨 could not find implicit value for parameter p: shapeless.ops.hlist.Prepend[In,shapeless.::[A,shapeless.HNil]] 如何编写一个函数,将的结果返回为,其签名是什么 谢谢 正如您正确解释的,我们使用prepend的原因是将标有的步骤类型保持为。它将它们保持在相反的顺

因此,我将此函数调用为(
gremlincala
):

这使得它可以编译,但我仍然不能使用这个函数!每当我打电话给它,它都会向我抱怨

could not find implicit value for parameter p: shapeless.ops.hlist.Prepend[In,shapeless.::[A,shapeless.HNil]]
如何编写一个函数,将
的结果返回为
,其签名是什么


谢谢

正如您正确解释的,我们使用prepend的原因是将标有
的步骤类型保持为
。它将它们保持在相反的顺序,因为它更容易在两侧处理:用于捕获和重放

因此,
隐式p:Prepend[Labels,End::HNil]
在当前步骤中对类型进行了预处理,以便在第二个类型参数中捕获它(并且可以在以后的步骤中使用它,例如,
选择

据我所知,你做的事情完全正确,而且它确实有效。。。对我来说:)

这包括:

import gremlin.scala._
import shapeless.{HNil, ::}
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory
def graph = TinkerFactory.createModern.asScala
val gs1: GremlinScala[Vertex, Vertex :: HNil] = graph.V().as("a")
val gs2: GremlinScala[Vertex, Vertex :: HNil] = AsOperation("someLabel").operate(graph.V())

你是对的!这确实可以编译和工作。事实证明,我的问题是一个更高的层次,我在右折叠中使用Poly2来应用一系列这样的操作。我会为这个问题提出一个新问题,谢谢你的回答!(顺便说一下,我喜欢小精灵scala,谢谢你的写作:)好的,这里有个新问题:
could not find implicit value for parameter p: shapeless.ops.hlist.Prepend[In,shapeless.::[A,shapeless.HNil]]
import gremlin.scala._
import shapeless.{HNil, ::}
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory
def graph = TinkerFactory.createModern.asScala
val gs1: GremlinScala[Vertex, Vertex :: HNil] = graph.V().as("a")
val gs2: GremlinScala[Vertex, Vertex :: HNil] = AsOperation("someLabel").operate(graph.V())