Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 14 18:08
    @SethTisue banned @discjock:matrix.org
  • Sep 12 20:37
    @SethTisue banned @manuelzamoratetherbtcusa:matrix.org
  • Sep 06 14:29
    @SethTisue banned @white_hat_hacker:minds.com
  • Sep 06 14:29
    @SethTisue banned @alexchole:matrix.org
  • Aug 31 17:03
    @SethTisue banned @andersonwatts7:matrix.org
  • Jul 19 20:37
    @SethTisue banned @tonyobanon
  • Jan 02 23:58
    @SethTisue banned @fakubishes:nerdsin.space
  • Dec 15 2021 05:01
    som-snytt commented #12516
  • Dec 15 2021 04:38
    SethTisue edited #1312
  • Dec 15 2021 04:38
    SethTisue opened #2273
  • Dec 15 2021 04:31
    jackkoenig opened #12516
  • Dec 15 2021 04:29
    SethTisue edited #1312
  • Dec 15 2021 04:28
    SethTisue edited #1312
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    scala-jenkins milestoned #9831
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    SethTisue opened #9831
  • Dec 15 2021 03:35
    som-snytt commented #11339
  • Dec 15 2021 03:27
    som-snytt labeled #12494
  • Dec 15 2021 03:07
    SethTisue edited #1312
Fabio Labella
@SystemFw
even an open source one
Ichoran
@Ichoran
Well, you can always bolt on a typeclass.
Fabio Labella
@SystemFw
why should my DB library extend your custom interface that you use in user code?
Ichoran
@Ichoran
Okay, no, not always. Sometimes you can.
Fabio Labella
@SystemFw
final tagless is basically "bolting on a typeclass", and yeah you can
Ichoran
@Ichoran
Hm, that's an interesting way to look at it. "You are probably going to want a typeclass on here. So look, I've already got it prepared for you."
Maybe final tagless is drilling holes and threading them, so it's bolt-ready :)
("threading" = "tapping", to use correct machining terminology.)
Fabio Labella
@SystemFw
personally the reason I like it is that it's the most boilerplate-free, easy to compose thing to build custom languages/abstractions, and I find that building custom abstractions like that really multiplies my engineering power, since it allows me to craft a world where solving the problem at hand is easy, and what I have is now reduced to the smaller individual problems of implementing the primitives of my abstraction
Luis Miguel Mejía Suárez
@BalmungSan

Hi all, quick question,

Does scalatest provides a way to combine two assertions with an or (xor)?
Basically, I have a collection of values and I want to check that for all values of that collection one of their properties should be either A or B.

Ichoran
@Ichoran
Why not just write the xored statement inside a single property test?
upd
@prayagupd
maybe assert(List("expected value A", "expected value B").contains(actualValue))
Ichoran
@Ichoran
Oh, wait, I see, you mean that for collection X you can't find some values for which collection X has property A and other values where it has property B?
Luis Miguel Mejía Suárez
@BalmungSan

This is the test that I would like to write

  it should "have all rules come from either the Scalastyle or the Scapegaot rules repositories" in new Ctx {
    forEvery(rules) { rule =>
      rule.repoKey shouldBe "sonar-scala-scalastyle" or "sonar-scala-scapegoat"
    }
  }

Sadly it doesn't compile, and I can't find nothing related to combining assertions with ors, will try with ||

upd
@prayagupd
you can do assert(List("sonar-scala-scalastyle", "sonar-scala-scapegoat").contains(rule.repoKey))
in scalatest probably List("sonar-scala-scalastyle", "sonar-scala-scapegoat") should contain rule.repoKey
Luis Miguel Mejía Suárez
@BalmungSan

@prayagupd Well surely I can, and it does what I wanted, I just was expecting some nicer DSL...

I think I had a similar problem a few months ago and I solve it that way, so I was thinking it was a repetitive enough requirement to have an especial treatment.

Anyways, Thanks a lot :+1:

upd
@prayagupd
should contain is not a nice DSL? :)
there might be OR operator too i think
Josh
@joshlemer
@BalmungSan you can do:
rule.repoKey should matchPattern {
  case "foo" => 
  case "bar" => 
}
Luis Miguel Mejía Suárez
@BalmungSan

@prayagupd In the case when I want to check a collection contain some value it is, but for an OR of two assertions, IMHO, it is not.
I can't find that OR operator.

@joshlemer Oh, it looks better, thanks :)

Rob Norris
@tpolecat
10% write your tests
80% figure out the #$(&*$&#^ DSL
10% throw things
upd
@prayagupd
here is using or operator
"sonar-scala-scapegoat" should (be ("sonar-scala-scalastyle") or be ("sonar-scala-scapegoat"))
i dont know how nice DSL is it :)
Josh
@joshlemer
wow!
Luis Miguel Mejía Suárez
@BalmungSan

@tpolecat your comments always make my day :laughing:
I agree in not overusing operators, I haven't define one since I first learn Scala

But, Or is not so bad ;)

@prayagupd Wow, How can I missed that... sorry :confused:

AmirSarvestani
@AmirSarvestani
Hi Everyone, I'm thinking about a way to create One single object from a sequence of objects, Is that possible?
Like this , Seq[IncomeAndExpense] => Income( ) ; where attributes of income are fields in records from Income and expense
Ghost
@ghost~54f837fe15522ed4b3dcd6a3
I think you're looking for fold.
AmirSarvestani
@AmirSarvestani
Thanks! I'll try that
upd
@prayagupd
@AmirSarvestani you can. it also depends how you want to transform?
def income(incomeEx: Seq[IncomeAndExpense]): Income = Income(incomeEx.map { _.amount }.sum)
AmirSarvestani
@AmirSarvestani
Thank you guys, I'll lookm into it
ethicalbeginner
@nitishram
hi all
how to read xml in scala
Seth Tisue
@SethTisue
the scala-xml library may be suitable for light usage (reading config files and such), but you shouldn’t assume it’s industrial strength (for large files, for ingesting arbitrary XML from unknown sources, for lesser-used XML features, and so forth). for heavy/demanding XML work you may need to just use a Java library. there isn’t a Scala-based solution with a sterling reputation
I’m not especially expert on this subject but I’m answering since no one else has.
ethicalbeginner
@nitishram
@SethTisue what is the java API ?
ethicalbeginner
@nitishram
how to read and parse xml in scala using DOM parser
RoelofWobben
@RoelofWobben
good morning all
AmirSarvestani
@AmirSarvestani
@nitishram xml.XML.loadString(objectString)
It gives you a NodeSeq
RoelofWobben
@RoelofWobben
can I improve this :
def earliestFilm:Option[String]  = directors.filter(_.lastName == "McTiernan").flatMap(_.films).sortWith(_.yearOfRelease < _.yearOfRelease).headOption.map(_.name)
I have to find the earliest film of McTiernan
AmirSarvestani
@AmirSarvestani
I think you can change filter with headoption fo find with contains
RoelofWobben
@RoelofWobben
@AmirSarvestani how do you see this
AmirSarvestani
@AmirSarvestani
directors.find(.lastName.contains("McTiernan")).flatMap(.films).sortWith(.yearOfRelease < .yearOfRelease).map(_.name)