Resolving Implicit for `spire.math.JetDim`?

8 views
Skip to first unread message

Kevin Meredith

unread,
Apr 27, 2015, 12:50:14 PM4/27/15
to spire...@googlegroups.com
scala> import spire.math.Jet
import spire.math.Jet

scala> Jet(100)
<console>:9: error: could not find implicit value for parameter d: spire.math.JetDim
              Jet(100)
                 ^

When I ran into implicit issues before, I just imported the following package:

scala> import spire.implicits._
import spire.implicits._

But that did not work.

scala> Jet(100)
<console>:12: error: could not find implicit value for parameter d: spire.math.JetDim
              Jet(100)
                 ^

How can I import this implicit?

In the future, should I just grep for "implicit" and "X" in the whole project? 

Tom Switzer

unread,
Apr 27, 2015, 1:25:37 PM4/27/15
to Kevin Meredith, Spire User List
I think this is mostly related to how Jet is implemented. It needs an implicit `JetDim`, but we don't provide one by default (perhaps because there isn't a meaningful "default" dimension?). You'll need to do something like,

implicit val jetDim: JetDim = JetDim(23)

Tom Switzer

unread,
Apr 27, 2015, 1:26:24 PM4/27/15
to Kevin Meredith, Spire User List
I should add that I don't actually know much about Jet though, so I can't help much beyond the mechanics of the implicits :\

Erik Osheim

unread,
Apr 27, 2015, 1:28:49 PM4/27/15
to Tom Switzer, Kevin Meredith, Spire User List
We should add some documentation somewhere to explain this stuff.

I think that the Jet and FixedPoint types both share this pattern:
there is an implicit context which determines how the type should
be interpreted, but which has to be provided by the author (there
is no default).

I'll try to remember to open an issue for this if someone else doesn't
get to it sooner.

-- Erik

Kevin Meredith

unread,
Apr 27, 2015, 8:55:57 PM4/27/15
to spire...@googlegroups.com, thomas....@gmail.com, kevin.m....@gmail.com, er...@plastic-idolatry.com
Thanks to you both.

For others viewing, I also needed to include import spire.implicits._ for the implicit SemiRing parameter.
Reply all
Reply to author
Forward
0 new messages