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
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
Gavin Bisesi
@Daenyth
I think that's handled by sbt-pgp (or is it sbt-gpg?)
docs for that plugin should point you
Rob Norris
@tpolecat
@aloiscochard I highly recommend sbt-ci-release. It has doc for the whole process. I have been using it for a while.
Also hi o/
Aloïs Cochard
@aloiscochard
hi @tpolecat :), that plugin is really nice and seems to sum up all the best practice in order to sign and publish from TravisCI ty! But looking at this job from last tag: https://travis-ci.org/github/typelevel/cats/builds/723799804 I am under the impression that cats is not using this approach but instead rely on developers/maintainer doing sbt release, we quite like that as this prevent potentially leaking GPG key and passphrase to the CI vendor.
so this get me curious, how does people doing the release of cats do with their GPG configuration? my current thinking is that they do it in their global.sbt in their home directory.
Rob Norris
@tpolecat
I’m not sure. @kailuowang or @LukaJCB could tell you.