Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Luka Jacobowitz
@LukaJCB
I can’t read the stuff on nlab, but it seems to me like duoids are kinda like semirings with weaker laws?
Normal duoids, fascinating
Rob Norris
@tpolecat
@sellout has some diagrams like the cats infographic … maybe he can share one :-)
Greg Pfeil
@sellout
@LukaJCB Incompatible laws.
Billzabob
@Billzabob
Average/mean forms a lawful monoid doesn’t it?
Fabio Labella
@SystemFw
that's funny
one of the original reasons why the equivalent of Parallel was done in haskell was exactly to represent a weird Free/FreeAp hybrid
specifically Haxl-Like things
Luka Jacobowitz
@LukaJCB
@Billzabob yes, but it has to be lazily computed, otherwise it’s not associative (meaning it needs to be encoded as a pair of values)
Billzabob
@Billzabob
@LukaJCB Ahh ok thanks!
Simon Hafner
@reactormonk
How do I test Monoid instances? There doesn't seem to be any MonoidTests similar to the FunctorTests listed in the documentation
Luka Jacobowitz
@LukaJCB
@reactormonk it should be there, but in cats.kernel instead
Simon Hafner
@reactormonk
I guess intellij would help me with that if I ever got it set up correctly? ^^
Ah, found it
Jens Grassel
@jan0sch

Hi, I've a question regarding NonEmptySet (in cats 1.6.1).
I'm using it on a model but when I run some tests using scalacheck generators then a StackOverflowError is thrown.
Travis-Log: https://travis-ci.org/jan0sch/pfhais/jobs/574419505#L432
Code: https://github.com/jan0sch/pfhais/blob/master/impure/src/test/scala/com/wegtam/books/pfhais/impure/models/ProductTest.scala

Before I was using NonEmptyList which did not have these problems.
Is there something I am missing or how else can I avoid this?

A bit digging hinted that this might be caused by compare from the Order instances.
Luka Jacobowitz
@LukaJCB
@sellout that is an excellent read, thanks much!
Jens Grassel
@jan0sch

Interesting, the implicit Order instances seemed to be the culprit. I'm using refined and the following implementation caused a stack overflow:

  implicit val orderLanguageCode: Order[LanguageCode] = new Order[LanguageCode] {
    def compare(x: LanguageCode, y: LanguageCode): Int = x.compare(y)
  }

This one seems to work:

  implicit val orderLanguageCode: Order[LanguageCode] = new Order[LanguageCode] {
    def compare(x: LanguageCode, y: LanguageCode): Int = x.value.compare(y.value)
  }

But shouldn't using .value use "more" memory because the value classes won't be replaced by the underlying string instance? :thought_balloon:

Henry Story
@bblfish
Anyone know of a really good use case for a continuation monad in Scala?
Gavin Bisesi
@Daenyth
@jan0sch x.compare(y) is probably compiling as calling OrderOps#compare or something, hence the stack overflow - it's a recursive defintion
Jens Grassel
@jan0sch
Thanks for the enlightenment. I also noted that NeS is basically a sorted set. Wouldn't it be better renamed to SortedNonEmptySet or something like that?
Ah, there is already an issue and a PR for that. :-)
Simon Hafner
@reactormonk
Is there a Max newtype in cats?
Rob Norris
@tpolecat
No but I think newts has one.
Greg Pfeil
@sellout
I do have a diagram, like @tpolecat mentioned, but duoids don’t really connect to other things yet …
algebraic structures.png
Luka Jacobowitz
@LukaJCB
That is a tasty diagram
When are we gonna get all of this into cats
Julien Truffaut
@julien-truffaut
Christopher Davenport
@ChristopherDavenport
@reactormonk I still maintain Semigroups and Monoids which support this but with less of the newtype magic.
Luka Jacobowitz
@LukaJCB
@ChristopherDavenport I think those Max and Min could be Semilattices :)
Christopher Davenport
@ChristopherDavenport
@LukaJCB PR’s welcome. Needs an update anyways for 2.13. But if not I can sneak it in.
Luka Jacobowitz
@LukaJCB
Can you assign me to the issue I created? I’ll make a PR by the end of the week :)
thx
Christopher Davenport
@ChristopherDavenport
All yours. :smile:
Billzabob
@Billzabob
@LukaJCB What’s a Semilattice and where can I learn more about it :)
Luka Jacobowitz
@LukaJCB
Short answer: semilattice is a commutative, idempotent semigroup
Piotr Gawryś
@Avasil
You can also read about CRDT, this perspective can be helpful for understanding. e.g. https://github.com/ljwagerfield/crdt
Rob Norris
@tpolecat
@Billzabob simple example is sets, where a + b = b + a and a + a = a
or subtyping in scala, where A with B = B with A and A with A = A
Billzabob
@Billzabob
Cool. The set example helps a lot. Is there a Scala implementation somewhere to look at?
Luka Jacobowitz
@LukaJCB
cats.kernel.Semilattice :)
Billzabob
@Billzabob
Oh cool. Apparently there’s a lot of stuff in cats.kernel I never knew existed. Thanks!
Rob Norris
@tpolecat
All the stuff in kernel is aliased to cats.Whatever
which is slightly out of date as always
:-\