[scalaz seven] Multiply in Type Class Questions

34 views
Skip to first unread message

Anwar Rizal

unread,
Feb 25, 2012, 3:29:59 PM2/25/12
to sca...@googlegroups.com
Hi,

I notice that  in scalaz seven Monoid has multiply function, that is implemented by calling the replicate function.

Some questions on multiply functions:

1/ If I understand correctly, if I call 3  multiply(10), then append will be called 10 times. Is there a way to override the multiply implementation in the a class instance. For example, in the example 3  multiply(10), I would like to use integer multiplication instead of repetitively calling append ?

2/ Is there any reason why multiply is not defined in Semigroup. Is it because multiply must support 0 as the multiplication factor ? Similarly, I wonder if it is possible to make multiply to support negative number for Group ? 

Thanks,
Anwar .
      







Runar Bjarnason

unread,
Feb 26, 2012, 1:06:26 AM2/26/12
to sca...@googlegroups.com
We should probably make it possible to override this function.

> --
> You received this message because you are subscribed to the Google Groups
> "scalaz" group.
> To post to this group, send email to sca...@googlegroups.com.
> To unsubscribe from this group, send email to
> scalaz+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/scalaz?hl=en.

Anwar Rizal

unread,
Feb 26, 2012, 4:06:49 AM2/26/12
to sca...@googlegroups.com
Yeah, I think so too.

I would love to have it at Semigroup (that accepts only positive multiplier) and Group (that accepts also negative value).

Anwar.

Jason Zaugg

unread,
Feb 26, 2012, 5:11:28 AM2/26/12
to sca...@googlegroups.com
On Sun, Feb 26, 2012 at 10:06 AM, Anwar Rizal <anri...@gmail.com> wrote:
> Yeah, I think so too.
>
> I would love to have it at Semigroup (that accepts only positive multiplier)
> and Group (that accepts also negative value).
>
> Anwar.
>
>
> On Sun, Feb 26, 2012 at 7:06 AM, Runar Bjarnason <runar...@gmail.com>
> wrote:
>>
>> We should probably make it possible to override this function.

That all sounds reasonable. We could make it return Option[A].

-jason

Anwar Rizal

unread,
Feb 26, 2012, 2:44:56 PM2/26/12
to sca...@googlegroups.com
OK, I filed an issue here:  :
Reply all
Reply to author
Forward
0 new messages