Poly1 and mapper

20 views
Skip to first unread message

Jeff

unread,
Jun 10, 2015, 2:58:17 AM6/10/15
to shapel...@googlegroups.com
I can't for the life of me figure out why the following does not work. I've tried all sorts of combinations of implicit evidence and still can't get it to compile. What I am trying to do is a type safe map on the results of Jedis pipeline calls. These calls return a Result[T]. Once you call sync, you can then get the value returned from the result. This seems like the type of thing shapeless is suited for. Here is a very stripped down version of what I am trying to achieve. 

import redis.clients.jedis.{Response, Pipeline}

import shapeless._
import poly._

class RedisPipeline[T <: HList] private[client](pipeline: Pipeline, list: T = HNil) {
  import RedisPipeline._

  private[client] def sync() = {
    pipeline.sync()
    list.map(response)
  }
}

object RedisPipeline {
  object response extends (Response ~> Id) {
    def apply[T](f: Response[T]): Id[T] = f.get()
  }
}

I keep getting the following compiler error

[error] [...]/redis/client/RedisPipeline.scala:15: could not find implicit value for parameter mapper: shapeless.ops.hlist.Mapper[....redis.client.RedisPipeline.response.type,T]
[error]     list.map(response)
[error]             ^
[error] one error found

Any help would be greatly appreciated.
Reply all
Reply to author
Forward
0 new messages