Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Anton Sviridov
@keynmol
A is probably not going to be the edge or node type, otherwise there's only so much you can do structurally to fit this signature

Quiver is based on a comonad of graph decompositions and it solved my use case without any monadic craziness.

Lack of maintained graph libraries in the ecosystem suggests that either this usecase is super narrow, or people are using a Java library instead

Soren
@srnb_gitlab
The graph decomposition comonad is something I do know about
Anton Sviridov
@keynmol
I linked that blog post just in case, I myself attempted to read it a few times and never got through it :)
Fabio Labella
@SystemFw
ideas here:
  • find someone that wants to maintain quiver (which is inspired by fgl btw)
  • flesh out the scala port of alga
Paul Snively
@paul-snively
I would bet that Tim Perrett would wish to maintain quiver.
Maybe Rúnar, who wrote it in the first place.
Anton Sviridov
@keynmol
I've created an issue on the nelson fork, hopefully Tim (I've seen Ross Baker there, too) will respond. I have all sorts of cross platform/scala versions publishing and just want to make sure there's actually a release process :)
Adam Rosien
@arosien
i've wanted to play with alga, looks cool.
Soren
@srnb_gitlab
  1. is there a way to automatically optimize non-dependent for-comprehensions into a mapN?
  2. is using mapN fine for things that need to be ordered?
  3. is using mapN going to give me a speed increase over a for-comprehension when using an effect type?
Ignore how badly written the project is in general; Is it useful to turn the steps not dependent on eachother into mapNs?
Raas Ahsan
@RaasAhsan
  1. AFAIK there isn't, for comprehensions always desugar into a series of nested flatMaps. not sure if there are compiler plugins that do otherwise
  2. mapN will evaluate effects in the order in which they appear in the tuple
  3. likely not, Applicative functions for Monads are usually written in terms of flatMap
Soren
@srnb_gitlab
@RaasAhsan What about IO? Isn't there this thing where mapN on IO/Task parallelize?
Raas Ahsan
@RaasAhsan
it will for Parallel operations like parMapN, but the regular Applicative instances will evaluate sequentially
Soren
@srnb_gitlab
Hmm
Raas Ahsan
@RaasAhsan
mapN will evaluate multiple independent effects sequentially, parMapNwill evaluate multiple independent effects in parallel
Soren
@srnb_gitlab
Can I say "use parMapN if possible, otherwise mapN"?
Raas Ahsan
@RaasAhsan
I think that's reasonable :) but if the effects are very fast to compute or don't involve I/O, the overhead of shifting executors might cause parMapN to be slower
Soren
@srnb_gitlab
hmm
the effects will be very fast to compute so :+1:
I'll just use a for loop
comp
Alex Henning Johannessen
@ahjohannessen
Thanks @tpolecat :)
Enrico Benini
@benkio

A question

https://github.com/typelevel/cats/blob/master/core/src/main/scala/cats/data/WriterT.scala#L330

In here liftF requires an Applicative, but it just uses map, why it just don't require a Functor instance?
Cheers

Gavin Bisesi
@Daenyth
Looks likely to be an error.
1 reply
Ethan
@esuntag
@srnb_gitlab I get joy out of overengineering hackerrank type problems. In this case what it boils down to is you start with an array of Int, and a target value, and you want to find the two values that add up to the target.
def compute[A: Monoid, F[_]: Foldable: Comonad](fa: F[A], target: A): Option[String] = 
    fa.coflatten.foldMapK(f => {
      val a = f.extract
      f.foldMapK(b => Option.when((a |+| b) == target)(s"$a $b"))
    })
Gavin Bisesi
@Daenyth
oh my
wonder what the asymptotics are on that using list/vector vs zipper
"find the two values" is that pairwise values?
or any two values?
Ethan
@esuntag
There's guaranteed to be a unique solution, so there will be precisely two numbers in the initial array that add up to the target. Still missing the semantics in that disallowing selecting the same one twice, not sure if there's something better than a filter for that
Don't worry, this is going nowhere near production
Ethan
@esuntag
For example, compute(NonEmptyList(1,List(,2,3,4,5)),9) should give 4 5
Steven Fines
@sfines-clgx
alright, it is time for Steve's stupid Cats Question of the day:
say I have a list, and I want to use a functor to filter, then compute on the list, what is the best way to do that? logically to me it seems like it should be compose, but that seems to want a List[List[]] instead of composing two functions
Christopher Davenport
@ChristopherDavenport
You probably just want FunctorFilter
Steven Fines
@sfines-clgx
where is that in the docs?
You can use collect with a PartialFunction to filter and compute in one go
Steven Fines
@sfines-clgx
cool. That wasn't on the main docs page ;)
that is exactly what I want
Christopher Davenport
@ChristopherDavenport
Always more to document. PR's appreciated. :smile:
Adrian
@adrian-salajan
hi, i can't find the Eq instances for Array. any gotchas ?
Gavin Bisesi
@Daenyth
might be in alleycats
One gotcha is that unlike most of scala, Array uses reference equality for ==
You compare values with sameElements
James Earl Douglas
@earldouglas
Does cats have a memoization wrapper like scalaz's Memo? Eval is close, but looks like it only memoizes thunks. I need to memoize a function1.
Jacob Wang
@jatcwang
@earldouglas I'm not aware of one in cats directly, but https://monix.io/docs/current/eval/coeval.html
Aloïs Cochard
@aloiscochard
hey there, taking inpsiration from the release process of cats (and usage of sbt-release). I do wonder how developer manage and set which GPG key should be used when publishing/releasing locally? cheers