"could not find implicit value for evidence parameter" with MongoCaseClassField

24 views
Skip to first unread message

Erik Allik

unread,
Apr 15, 2014, 9:48:19 AM4/15/14
to rogue...@googlegroups.com
I recently discovered the rather useful MongoCaseClassField, however, it seems that doing e.g. where(_.status eqs Pending) on it results in the following compilation error:

    could not find implicit value for evidence parameter of type com.foursquare.rogue.BSONType[my.pkg.JobStatus]

Where JobStatus is defined as sealed trait JobStatus with a bunch of case object definitions extending it.

Should this be reported as a bug? And are there any workarounds meanwhile?

Regards,
Erik

Erik Allik

unread,
Apr 15, 2014, 12:26:53 PM4/15/14
to rogue...@googlegroups.com
OK, it looks like this works:

      implicit object JobStatusIsBSONType extends com.foursquare.rogue.BSONType[JobStatus] {
        override def asBSONObject(v: JobStatus): AnyRef = v.toString
      }

Is my definition of JobStatusIsBSONType appropriate?

However, as far as I can tell, there is no way to generalize this to any ADT because there's no type to define the typeclass instance on—am I right?

Erik

Jason Liszka

unread,
Apr 15, 2014, 11:39:24 PM4/15/14
to rogue...@googlegroups.com
Hi Erik,

Unless you've implemented specialized serialization/deserialization logic for your case class, rogue isn't going to be able to deserialize it into the right subclass of JobStatus. I would recommend using an enum instead of case objects in this case.

Regards,
Jason


--
You received this message because you are subscribed to the Google Groups "rogue-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rogue-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages