Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 10:51
    dwijnand synchronize #9564
  • 10:07
    dwijnand demilestoned #12264
  • 10:07
    dwijnand milestoned #12264
  • 10:05
    dwijnand milestoned #7994
  • 10:04
    dwijnand milestoned #12361
  • 09:53
    dwijnand milestoned #12370
  • 09:50
    dwijnand synchronize #9441
  • 09:46
    dwijnand commented #9441
  • 09:33
    dwijnand review_requested #9565
  • 09:16
    dwijnand synchronize #9564
  • 09:13
    martijnhoekstra commented #1981
  • 09:13
    martijnhoekstra commented #1981
  • 09:07
    robstoll commented #1981
  • 09:05
    martijnhoekstra commented #1981
  • 08:20
    robstoll commented #1981
  • 07:39
    Ichoran commented #9565
  • 07:33
    Ichoran commented #9565
  • 07:24
    Ichoran commented #9565
  • 07:21
    Ichoran commented #9565
  • 07:19
    Ichoran commented #9565
Martijn
@martijnhoekstra:matrix.org
[m]
-Wwarn-macros:both requires your trees to be good before and after macro expansion
Luis Miguel Mejía Suárez
@BalmungSan
Yep.
both is the worst of both worlds.
Som wanted to add a mixed one that should be the best of both worlds, but I guess it is was too difficult to do.
Justin Reeves
@justinallenreeves
Are there scalafmt rules for StringContext interpolators?
My graphql and json are all over the place.
Rob Norris
@tpolecat
That's an interesting idea.
Justin Reeves
@justinallenreeves
I hate interesting ideas when I have a boring problem I just wish someone else had already solved :)
gitleet
@gitleet
val om = Some(Map("k1" -> "v1", "k2" -> "v2")) How do I get the 1st items value in the map or else just "" ?
Rob Norris
@tpolecat
What do you mean "first"? Maps aren't ordered.
Or do you mean, how do you get the value of k1?
gitleet
@gitleet
just any element then
om.map(myMap => myMap.map(k1 => k1._2))) ?
Rob Norris
@tpolecat
For that it would be om.flatMap(_.get("k1")).getOrElse("")
gitleet
@gitleet
thanks
Rob Norris
@tpolecat
So that would give you "v1" in this case but if it were None or the map didn't include that key you would get "".
Luis Miguel Mejía Suárez
@BalmungSan
@gitleet you said any element so I would do this:
om.flatMap(_.headOption).fold(ifEmpty = "")(_._2)
Note that headOption doesn't make much sense on a Map but if you want to pick just any element as long as there is at least one this works.
Seth Tisue
@SethTisue
or om.flatMap(_.keySet.headOption).getOrElse("")
Luis Miguel Mejía Suárez
@BalmungSan
Didn't he / she wanted the value?
But yeah, you may use _.valuesIterator.nextOption() in that case.
Aly
@aly:scuttlebug.space
[m]
Is there a Scala library for compiling Regexes to DFAs? Ideally I'd like to not depend on a Java library for this, it'd be nice if it worked in ScalaJS.
Aly
@aly:scuttlebug.space
[m]
It seems like https://github.com/non/antimirov is my best bet
Rob Norris
@tpolecat
Yeah Erik's stuff is great.
Justin Reeves
@justinallenreeves

Added Compile / scalacOptions ++= Seq(“Ywarn-macros:after”)
and Compile / scalacOptions --= Seq("-Xfatal-warnings”) while i’m just getting things up and running
compile runs without issue.
stage fails

[error] IO error while decoding Ywarn-macros:after with UTF-8: Ywarn-macros:after (No such file or directory)
[error] Please try specifying another one using the -encoding option
[error] one error found
[error] Scaladoc generation failed

I don’t really need scaladoc

Jorge Adriano Branco Aires
@jorgeadriano
So how do you guys usually deal with a groupBy that can fail? A Map[Option[K], V] cannot be sequenced out key-collected to Option[Map[K, V]] due to key collisions. And cats seem to offer no V-monoid based ready made solutions.
Luis Miguel Mejía Suárez
@BalmungSan
@jorgeadriano wdym with a groupBy that can fail?
@justinallenreeves -Y you are missing the hypen.
Justin Reeves
@justinallenreeves
oh oopsie
Jorge Adriano Branco Aires
@jorgeadriano
@BalmungSan groupBy(f) for some partial f.
Luis Miguel Mejía Suárez
@BalmungSan
And what do you want to do with values that do not match the predicate?
Exclude / filter them?
Jorge Adriano Branco Aires
@jorgeadriano
@BalmungSan or in other words some groupByOpt returning an Option[Map[K,V]]
@BalmungSan nah, just fail with None
Luis Miguel Mejía Suárez
@BalmungSan
Thus, if one fail everything fails?
Got it.
Jorge Adriano Branco Aires
@jorgeadriano
Just wondering if there's something ready made or close. At the moment I'm actually leaning towards just Try {s.groupBy(funExplodesIfFails)}.toOption.
Luis Miguel Mejía Suárez
@BalmungSan
Can you decompose that funExplodesIfFails into two functions?
Jorge Adriano Branco Aires
@jorgeadriano
@BalmungSan which kind of decomposition?
Luis Miguel Mejía Suárez
@BalmungSan
One that does the filtering and the other one for the grouping.
Jorge Adriano Branco Aires
@jorgeadriano
nah
Luis Miguel Mejía Suárez
@BalmungSan
Something like data.traverse(filterFun). map(_.groupBy(groupingFun))
Oh well, then you may either write your own function or just use Try as you already shown.
Jorge Adriano Branco Aires
@jorgeadriano
I mean I can do that but not shortly. If I were to do that might as well write the groupByOpt via toList to sequence it out and then back toMap. Just unsure if it's worth it.
Luis Miguel Mejía Suárez
@BalmungSan
I mean I would write my own function if I need it very often to make it fast and and clear.
Jorge Adriano Branco Aires
@jorgeadriano
Might do it. Feels like at least cats should be providing functions acting on keys, since it can deal with collisions provided the appropriate monoid on the value side. So thought maybe I could be missing something.
Luis Miguel Mejía Suárez
@BalmungSan
You may ask in their gitter channel.
It may end in you opening a PR :)
Jorge Adriano Branco Aires
@jorgeadriano
Maybe ;)
zeroexcuses
@zeroexcuses
if we run a regex R on a input string S, the worst case running time is O(2^|size R| * (size S)) ? i.e. linear in the input size, but possibly exponential in the size of the regex.
Rob Norris
@tpolecat
It depends on the regex language.