Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 10:58
    SethTisue labeled #8501
  • 10:55

    SethTisue on master

    Revamp CoC preamble and encoura… remove ambiguous term “micro-ag… improve CoC based on PR feedback and 4 more (compare)

  • 10:55
    SethTisue closed #1089
  • 10:53

    SethTisue on master

    Move the examples of harassment… change bullet list - to * revise intro to example points,… and 4 more (compare)

  • 10:53
    SethTisue closed #1087
  • 10:36
    SethTisue commented #1008
  • 10:31
    SethTisue commented #1008
  • 10:30
    SethTisue commented #1008
  • 10:29
    texasbruce commented #1470
  • 10:26
    SethTisue commented #1008
  • 10:20
    dwijnand commented #1008
  • 10:19
    SethTisue synchronize #1008
  • 10:14
    SethTisue synchronize #1008
  • 10:09
    SethTisue commented #1008
  • 10:06
    SethTisue commented #1008
  • 10:06
    SethTisue synchronize #1008
  • 09:42
    SethTisue commented #1008
  • 09:38
    gaelrenoux commented #1470
  • 09:35
    SethTisue commented #1008
  • 08:56
    SethTisue commented #1008
Drew Boardman
@drewboardman
@tpolecat I'm using your recommended 2.12.x compiler flags and it's angry about code in /target that's generated by scalaxb
is that intended?
[warn] /Users/d.boardman/code/lib-radial/target/scala-2.12/src_managed/main/sbt-scalaxb/scalaxb/scalaxb.scala:1014:42: pattern var scope in method transform is never used; `scope@_' suppresses this warning
[warn]         case x@Elem(prefix, label, attr, scope, _*) if attr exists(p => p.key == "id") =>
Rob Norris
@tpolecat
You can turn that warning off, or generate into a different sub-project that has the warning turned off
Drew Boardman
@drewboardman
you know what flag is throwing that warning?
any idea how to generate into a different side-project?
Gavin Bisesi
@Daenyth
sec
Rob Norris
@tpolecat
scope is bound but never referenced on the RHS of the =>
Gavin Bisesi
@Daenyth
-Ywarn-unused:patvars
Rob Norris
@tpolecat
not a big deal in generated code but it's often a bug in real code
Gavin Bisesi
@Daenyth
is the warning
:+1: on generating into a project
good for code reuse and separation of concerns anyway
Drew Boardman
@drewboardman
yeah i'd like to keep the warning on for real code
i know the scalaxb cli claims you can generate into anywhere you want
but that doesn't actually work, the cs eed3si9n/scalaxb fails
i'm using the sbt version
Rob Norris
@tpolecat
I'm sure you can configure the output directory. Look at the doc for that plugin
Drew Boardman
@drewboardman
i figured out how to make it generate to any dir i want. Are you suggesting that I generate them to a completely different project with a different build.sbt?
Gavin Bisesi
@Daenyth
no, a subproject
sbt supports multi-project builds
so you can have mylib-xml that has the xsd and generates the case classes and then mylib dependsOn that project, getting the compiled classes as though you had them from a jar
Drew Boardman
@drewboardman
yeah i see what you mean
how can i omit that project from my compilerflags
Gavin Bisesi
@Daenyth
FWIW we do exactly this with some avro schemas, works fine
you can set all configs specific to projects
Drew Boardman
@drewboardman
hmm
i usually have had 1 build.sbt
Gavin Bisesi
@Daenyth
so project(...).settings(scalacOptions -= "...")
yes, one build.sbt is fine
Drew Boardman
@drewboardman
ahh
i need move move my original folder "up" 1 right?
like nest it 1 deep?
Drew Boardman
@drewboardman
is it a bad idea to use different scala versions in each sub project?
Dermot Haughey
@hderms
Anyone use a remote computer to compile Scala code?
Trying to figure out if my best option is something like Jenkins or if there are better solutions
Marcell
@yohannesm
Hi guys
Rob Norris
@tpolecat
o/
Marcell
@yohannesm
Anyone could recommend me how to optimize this code a bit better... ? So I have this inheritance hierarchy..., but I need to collect the different elements and making new sequence based on its detail/implementation case class of the trait
Showing code probably faster..., I was just wondering if I can do this in one swoop, instead of doing collect() on each one of the type.
 trait SearchAssist

  case class WordAssist(word: String) extends SearchAssist

  case class BusinessAssist(title: String, businessId: Int) extends SearchAssist

  case class AnalyticsWordAssist(word: String, rank: Int) extends SearchAssist

  case class AnalyticsBusinessAssist(title: String, businessId: Int, rank: Int) extends SearchAssist

  val wa0 = WordAssist("pizza")
  val wa1 = WordAssist("pizzeria")
  val b0 = BusinessAssist("Pizza hut", 13)
  val b1 = BusinessAssist("Dominos", 27)
  val wa2 = WordAssist("Italian food")

  val seq: Seq[SearchAssist] = Seq(wa0, wa1, b0, b1, wa2)

  val seqWithIndex = seq.zipWithIndex

  val seqWords = seqWithIndex.collect{
    case (w: WordAssist, i) => AnalyticsWordAssist(w.word, i)
  }

  val seqBusiness = seqWithIndex.collect{
    case (b: BusinessAssist, i) => AnalyticsBusinessAssist(b.title, b.businessId, i)
  }

I need to capture the index/ranking of how these results are presented in the first sequence.
I am trying to avoid using var or mutable variable and having it more of a functional style.
I was just wondering if there's a way to do these collect in one swoop.

Also let say in the future , These types might extend more than just 2, so I definitely want to optimize this better.

I'd appreciate any input
Brian Maso
@bmaso

I would do it using a multi-partition fold; fold each element into one of several lists based on object type.

val (seqWords, seqBusiness) = seqWithIndex.fold((List.empty[WordAssist](), List.empty[BusinessAssist]()) {
    case ((sws, sbs), (sa, i)) => sa match {
      case w: WordAssist => (AnalyticsWordAssist(w.word, i) +: sws, sbs)
      case b: BusinessAssist => (sws, AnalyticsBusinessAssist(b.title, b.businessId, i) +: sbs)
      case _ => (sws, sbs)
    }

Note: off the cuff -- not actually tested

Marcell
@yohannesm
Ok, let me try that out
Marcell
@yohannesm
  val (seqWords, seqBusiness) = seqWithIndex.foldLeft(Vector.empty[AnalyticsWordAssist], Vector.empty[AnalyticsBusinessAssist]) {
    case ((partSeqWords, partSeqBusiness), (sa, i)) => sa match {
      case WordAssist(word) => (partSeqWords :+ AnalyticsWordAssist(word, i), partSeqBusiness)
      case BusinessAssist(title, businessId) => (partSeqWords, partSeqBusiness :+ AnalyticsBusinessAssist(title, businessId, i))
    }
  }
I think as this function grows though, might make sense to make a separate def as the type grows
Thanks again though
Martijn Hoekstra
@martijnhoekstra
seqWithIndex.partitionMap {
  case (WordAssist(word), i) => Left(AnalyticsWordAssist(word, i))
  case (BusinessAssist(title, businessId), i) => Right(AnalyticsWordAssist(title, businessId, i))
}
does the same but shorter
@drewboardman I don't see any upsides, and I o see downsides. I don't know what your usecase for that is, so who knows, but it sounds iffy