## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
Fabio Labella
@SystemFw
if you also have monad, the "associativity" of >>= implies the one of *>through ap = <*>
ah wait
Luka Jacobowitz
@LukaJCB
But that’s not Monad, that’s Bind :P
Fabio Labella
@SystemFw
I don't think that's relevant in this case
I guess I'm unclear on what laws Semigroupal has
Luka Jacobowitz
@LukaJCB
In other news, I was thinking of finally posting my type class proposal to contributors.scala
Michael Pilquist
@mpilquist
:confetti_ball:
Fabio Labella
@SystemFw
ah, nice!
Luka Jacobowitz
@LukaJCB
IMO Semigroupal is practically lawless
Michael Pilquist
@mpilquist
associativity of product?
Ross A. Baker
@rossabaker
  def semigroupalAssociativity[A, B, C](fa: F[A], fb: F[B], fc: F[C]): (F[(A, (B, C))], F[((A, B), C)]) =
(F.product(fa, F.product(fb, fc)), F.product(F.product(fa, fb), fc))
Fabio Labella
@SystemFw
then Apply doesn't add anything I don't think
Luka Jacobowitz
@LukaJCB
But the only way to actually check if those are equal is to use map 😜
Or use Isomorphisms
Ross A. Baker
@rossabaker
Yeah, what is this law even saying?
Fabio Labella
@SystemFw
ah ok, I see then
well actually I'm not sure
the fact that checking the laws requires extra constraints doesn't mean the constraints should be in the class
Michael Pilquist
@mpilquist
Fabio Labella
@SystemFw
e.g. checking <*> = ap requires Sync (or in general the ability to observe effects)
Ross A. Baker
@rossabaker
      "semigroupal associativity" -> forAll((fa: F[A], fb: F[B], fc: F[C]) => iso.associativity(laws.semigroupalAssociativity(fa, fb, fc)))
Michael Pilquist
@mpilquist
Fabio Labella
@SystemFw
ah, cool :)
Michael Pilquist
@mpilquist
note the iso requirement exists for regular lax monoidal functors too
Ross A. Baker
@rossabaker
I was thrown off by a law just returning a pair.
I'm trying to implement Semigroupal[Set].
Luka Jacobowitz
@LukaJCB
Semigroupal[Set] should be possible, no?
Ross A. Baker
@rossabaker
I'm trying to test it with the Bad from Set is not a functor mkay
I need an Invariant[Set] to get the Isomorphism[Set], or bring my own.
Luka Jacobowitz
@LukaJCB
Ross A. Baker
@rossabaker

This passes:

case class Bad(a: Int) { override def equals(a: Any) = true }
checkAll("Semigroupal[Set]", SemigroupalTests[Set].semigroupal[Bad, Bad, Bad])

Bad is chosen to emphasize that there is no Functor[Set].

Ross A. Baker
@rossabaker
I got what I needed for Haskell Study Group at work today, but I could probably polish up that instance (and Map) for a PR next week.
Luka Jacobowitz
@LukaJCB
Nice, thanks Ross! :)
Vojtech Letal
@letalvoj
Is there a dual method for Monoid? Like for example:
If not... would it be accepted? And where it should be placed?
Jakub Kozłowski
@kubukoz
I kinda wish our encoding of Monoid was like Haskell's
with e.g. implicit Monoid[A] => implicit Monoid[A @@ Dual]
Fabio Labella
@SystemFw
well, that's doable
it's just dependent on choosing a newtype solution
Vojtech Letal
@letalvoj
@kubukoz is not it inconvenient to use?
Fabio Labella
@SystemFw
@letalvoj there are some smart convienence functions
e.g. foldMap ala Min [1,2,3]
Vojtech Letal
@letalvoj
@SystemFw in cats? I still do not see how you pass the dual monoid to foldMap[A:Monoid,B] if you are constrained by the A using Dual tag
Fabio Labella
@SystemFw
@letalvoj ah sorry, I assumed you meant in Haskell :grimacing:
Jakub Kozłowski
@kubukoz
yeah in Scala it's not that convenient I guess
Rob Norris
@tpolecat
 implicit class ParallelTraverseOps[F[_]: Traverse, A](fa: F[A]) {
def jankyParTraverse[G[_]: Concurrent, B](f: A => G[B]): G[F[B]] =
fa.traverse(a => f(a).start).flatMap(fs => fs.traverse(_.join))
}
thoughts?
Jakub Kozłowski
@kubukoz
I was actually thinking about something similar a few days ago
Fabio Labella
@SystemFw
we used to have the exact same thing in fs2
Jakub Kozłowski
@kubukoz
when I was asking for Traverse[Set], but well fsck there isn't one
Rob Norris
@tpolecat
haha