Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 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
  • Dec 15 2021 03:07
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 02:58
    SethTisue edited #1312
Fabio Labella
@SystemFw
interpreters are in the form of Add[Int] (which evals), or Add[String] (which pretty prints)
adding new ops like this doesn't require you to change any code
new ops would be a new Mult[A]
which also doesn't require you to change any code
calling code would be bar[A: Add: Mult]
when you instantiate it at Int, if you don't have both instances things won't compile
Ichoran
@Ichoran
So you have to change all the call sites instead of all the class definitions and/or pattern matches?
Fabio Labella
@SystemFw
(there are a few differences among languages: here I'm passing things implicitly, so two interpreters with the same result type should be newtyped to keep coherence, you could also pass them explicitly)
@Ichoran not all the call sites
only the call sites that need the new op
which isn't "changing the call sites"
if you need the op, you need to call it, right?
Ichoran
@Ichoran
I guess that makes some sense.
Fabio Labella
@SystemFw
the shape people normally rave about have an F[_] type parameter
which allows you to encode effects
which compose seamlessly since typeclass constraints already compose
and can have multiple interpretations (e.g. test, prod)
Ichoran
@Ichoran
But it penalizes you pretty heavily for deeply nested code, doesn't it? Because if you need Mult, you have to adorn the entire call stack with it.
Fabio Labella
@SystemFw
isn't that the case with every constraint ever?
Ichoran
@Ichoran
No, because it's smuggled in via the class definition in an OO setting.
Fabio Labella
@SystemFw
right, I get what you mean, but that's because that one isn't a constraint
Ichoran
@Ichoran
Right. You're making people state their constraints instead of just using whatever is available, which seems like strictly more work. Safer and more minimal, but sometimes that's not very important.
Fabio Labella
@SystemFw
note that your approach also assumes you control the code that defines the language
i.e. if that's in a library, you're kinda screwed
Ichoran
@Ichoran
If it's a closed-source library, yeah.
Fabio Labella
@SystemFw
you can't make something extend an interface retroactively
Ichoran
@Ichoran
I pretty much decide I'm screwed regardless in that case, though :)
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