These are chat archives for typelevel/cats

26th
Apr 2018
siyan
@blazingsiyan
Apr 26 08:01
em... how can I convert F[G[A]] to F[G[B]] if I have a function A => F[B], assume F, G are monads?
Luka Jacobowitz
@LukaJCB
Apr 26 08:02
That doesn't work genetically I'm afraid
siyan
@blazingsiyan
Apr 26 08:08
thanks. under what assumptions on F and G it might work?
Eli Jordan
@eli-jordan
Apr 26 08:09
If you have F ~> G you could make it work
Fabio Labella
@SystemFw
Apr 26 08:10
if G is a Traversable you might get it to work
do you have specific F and G in mind?
siyan
@blazingsiyan
Apr 26 08:15
Ok, just suppose F is IO and G is List?
Oleg Pyzhcov
@oleg-py
Apr 26 08:15
fga.flatMap(_.traverse(func))
Fabio Labella
@SystemFw
Apr 26 08:15
:+1:
siyan
@blazingsiyan
Apr 26 08:21
cool. thanks to you all
Cary Robbins
@carymrobbins
Apr 26 15:15
While working on a solution to a scala/bug#10849 where it tries to resolve the wrong implicit type for higher-kinded type class, i came up with the UnKind type class for converting a higher-kinded type class TC[F[_]] to one equivalent to TC[FA]; does something like this exist already, or maybe is there a simpler solution?
Oleg Pyzhcov
@oleg-py
Apr 26 15:17
Looks like good ol' Unapply
@carymrobbins by any chance, do you have partial unification enabled?
Colt Frederickson
@coltfred
Apr 26 16:07
Anyone had problems with insanely slow compile times (in general)? In my case I'm getting to the last error (before it prints the actual final error count) and it hangs for 20s. I have 0 clues on how to find out what it's actually doing during that time. I'm on 2.12 + sbt 1.1.2
(this is totally off topic for the room, sorry)
Cary Robbins
@carymrobbins
Apr 26 16:08
@oleg-py ahh i never understood scalaz's Unapply...now i do!
@oleg-py and no, i don't believe i do
should i?
(re: partial unification)
Cary Robbins
@carymrobbins
Apr 26 16:17
same deal with partial unification btw
[info] hasMatchingSymbol reported error: could not find implicit value for parameter F: cats.MonoidK[Option[String]]
Fabio Labella
@SystemFw
Apr 26 16:26
MonoidK[Option[String]] is ill-kinded
MonoidK[Option]
Cary Robbins
@carymrobbins
Apr 26 16:26
right
which is why i submitted that as a bug to scalac
Fabio Labella
@SystemFw
Apr 26 16:27
and if you had a problem that's solved by the equivalent of Unapply... that's what partial unification solves in most cases
@carymrobbins ah, right :)
Cary Robbins
@carymrobbins
Apr 26 16:27
scala/bug#10849
:smile:
tough to not come across as crass over chat :joy:
Jacob Barber
@Jacoby6000
Apr 26 20:49
does cats have a groupBy which preserves the order of the sub-lists?
Nel's group by will do what I want, looks like
Adelbert Chang
@adelbertc
Apr 26 21:01
does the stdlib groupBy not preserve order?
Jacob Barber
@Jacoby6000
Apr 26 21:19
nope
At least, it doesn't seem to. I can't produce an example of it right now, but it was causing tests to fail (ordering from database was not preserved in an end-end test). Switched to using Nel.groupBy and my issue is gone.
Jacob Barber
@Jacoby6000
Apr 26 21:32
Nevermind, was just a coincidence
my issue was something else
Bah nevermind
Jacob Barber
@Jacoby6000
Apr 26 21:41
stdlib groupby definitely does not preserve order.. though I can't figure out how to make a minimally reproducible example
I think they say that in the docs, so it's alright
Derek Williams
@derekjw
Apr 26 21:57
which docs? the stdlib doesn't mention order for groupBy, and the implementation adds each element to a builder of the original collection type, so Seq should have the same order.
Jacob Barber
@Jacoby6000
Apr 26 21:59
interesting. They even say they do preserve order
   *  @return  a pair of ${coll}s: the first $coll consists of all elements that
   *           satisfy the predicate `p` and the second $coll consists of all elements
   *           that don't. The relative order of the elements in the resulting ${coll}s
   *           is the same as in the original $coll.
Just switching my implementation to use Nel fixes this though
weird