These are chat archives for non/algebra

19th
Aug 2015
Adelbert Chang
@adelbertc
Aug 19 2015 23:01
sooo…. no Semigroup/Monoid instances for tuples?
im guessing these would be auto-gen’ed by SBT?
P. Oscar Boykin
@johnynek
Aug 19 2015 23:01
I think macros are the better way to go these days. We did autogen in algebird though.
but we recently added macros to cover case classes too.
Adelbert Chang
@adelbertc
Aug 19 2015 23:03
yeah im running into a couple situations in Cats where i want to fuse monoid traversals into a single pass
but no tuple instances so :(
Adelbert Chang
@adelbertc
Aug 19 2015 23:05
will take a look, thanks!
P. Oscar Boykin
@johnynek
Aug 19 2015 23:07
I know some folks use shapeless and fancy tricks to do the same thing.
my (pure) guess is that it takes longer to compile and does not perform as well at runtime as a macro.
Miles Sabin
@milessabin
Aug 19 2015 23:10
Yeah, I'm working on that in Kittens.
If compile time and runtime performance are your absolutely overriding consideration then it's hard to beat hand written code or a special case macro.
If generality is what you're after then shapeless (or shapeless-like techniques) are a better way to go.
Runtime performance for shapeless handling of tuples isn't too shabby though ... at runtime the bulk of the overhead is equivalent (after erasure) to unpacking a tuple into a vanilla scala List and then computing with that.
Erik Osheim
@non
Aug 19 2015 23:57
@johnynek i am tempted to use codegen for tuples, only because of the possibility about repeatedly synthesizing (or deriving) the same instance.