Sum on monoid gone or just renamed?

20 views
Skip to first unread message

Viktor Hedefalk

unread,
Mar 16, 2015, 10:43:41 AM3/16/15
to spire...@googlegroups.com
Hi,

I'm just coming back to work on some stuff that has been lying for the past year when I've been on parental leave. I'm sorry if this question seems lazy or plain stupid, but I feel thick as a brick right now. I'm updating Spire:

-    "org.spire-math" %% "spire" % "0.7.1"
+    "org.spire-math" %% "spire" % "0.9.0"

because reasons and I have

type NumberType
implicit val addition: Monoid[NumberType]

def total = Monoid[Option[NumberType]].sum(List(fat, protein, carbs, alcohol, fibres))

which now gives me 

Error:(21, 43) value sum is not a member of spire.algebra.Monoid[Option[MacroNutrientsNumber.this.NumberType]]
  def total =  Monoid[Option[NumberType]].sum(List(fat, protein, carbs, alcohol, fibres))
                                          ^
I guess there was a an implicit under 
import spire.std.any._
for Option as a monoid because that's the only import I believe is relevant.

Is sum maybe just renamed to the more generic sounding combine? It looks like it does what I want…

Thanks,
Viktor


Erik Osheim

unread,
Mar 16, 2015, 12:04:31 PM3/16/15
to Viktor Hedefalk, spire...@googlegroups.com
On Mon, Mar 16, 2015 at 07:43:41AM -0700, Viktor Hedefalk wrote:
> Is sum maybe just renamed to the more generic sounding combine? It looks
> like it does what I want…

Yes, that's right.

I think there was a concern that sum here implied addition (in the
same way that product implies multiplication).

Sorry for the confusion! We need to get better about creating release
notes that outline these kinds of changes. I think things are mostly
settled now, although there is likely to be one more round of small
changes (integration with the algebra project).

Please let me know if you hit other issues. Good luck!

-- Erik

Viktor Hedefalk

unread,
Mar 16, 2015, 2:59:34 PM3/16/15
to Erik Osheim, spire...@googlegroups.com
Awesome, thanks for the quick reply!

Cheers,
Viktor
Reply all
Reply to author
Forward
0 new messages