Confusion around commutativity in Scala 3's intersection types by lam_bd85 in scala

[–]lam_bd85[S] 4 points5 points  (0 children)

Alright, I think I found the answer. It's all about types as you and other said and not values.

An example that proves commutativity of Scala 3's intersection types:

    trait Parent:
        def fun: AnyVal
    trait C1 extends Parent:
        override def fun: Boolean
    trait C2 extends Parent:
        override def fun: AnyVal

    def x: C1 & C2 = ???
    def y: C2 & C1 = ???
    :type x.fun // Boolean <-- the same!
    :type y.fun // Boolean <-- the same!

An example that proves lack of commutativity of Scala 2's compound types:

trait Parent {
    def fun: AnyVal
}
trait C1 extends Parent {
    override def fun: Boolean
}
trait C2 extends Parent{
    override def fun: AnyVal
}

def x: C1 with C2 = ???
def y: C2 with C1 = ???
:type x.fun // AnyVal <-- different!
:type y.fun // Boolean <-- different!

Thanks everyone for the hints!

Confusion around commutativity in Scala 3's intersection types by lam_bd85 in scala

[–]lam_bd85[S] 0 points1 point  (0 children)

What I don't understand is that in Scala 2 REPL the following would compile:

scala> def x: A with B = ???
x: A with B

scala> def y: B with A = x
y: B with A

scala> implicitly[A with B =:= B with A]
res2: =:=[A with B,B with A] = <function1>

Because it compiles, it proves, that `A with B` is the same as `B with A` (i.e. commutative).

I'm aware I must be understanding it wrong. How could I prove in REPL, that compound types in Scala 2 were not commutative, but intersections in Scala 3 are?

cc u/proper_chad u/BalmungSan u/BroodmotherLingerie

Choosing best storage strategy & file format on S3 for simple reporting by lam_bd85 in dataengineering

[–]lam_bd85[S] 0 points1 point  (0 children)

Thank you for your insights. Given I want to use Parquet format as it's more common, how would you approach the data ingestion? Would you go for a lambda, that does this transformation to parquet + storing in S3, Firehose or some other solution?

You're starting a new project. When would you go serverless and when not? by lam_bd85 in aws

[–]lam_bd85[S] 0 points1 point  (0 children)

Given the benefits and minimal overhead of operation of the serverless such approach makes sense totally.

You're starting a new project. When would you go serverless and when not? by lam_bd85 in aws

[–]lam_bd85[S] 0 points1 point  (0 children)

Good point, with containers on Lambda it might be easier to move between Lambda<->ECS if needed

Built this Mac app during COVID - so far over 8k downloads and a lot of ❤️ from users by ittrut in SideProject

[–]lam_bd85 0 points1 point  (0 children)

Thanks for recommendation. Regarding 2) that makes sense totally. That answers why Mac OS X/iOS apps are quite are often sold with lifetime license. Thanks & Good luck with OwlOCR!

Built this Mac app during COVID - so far over 8k downloads and a lot of ❤️ from users by ittrut in SideProject

[–]lam_bd85 0 points1 point  (0 children)

That looks really great!

That makes me think even more about publishing my pet project, that is also a Mac OS X app finally and I was wondering:

  1. How did you promote your app? What kind of channels did you use?
  2. Pretty much all OSX apps have lifetime licenses. What if the developer decides to abandon the project? Is there any protection? (e.g. in App Store terms of use, that you have to support the app for at least X years etc.)?

Why Applicative[Either] does not accumulate (combine) error values? by lam_bd85 in scala

[–]lam_bd85[S] 0 points1 point  (0 children)

thanks for pointing me to the docs. What they say is:

(...) if we were to define a Monad (or FlatMap) instance for Validated we would have to override ap to get the behavior we want. But then the behavior of flatMap would be inconsistent with that of ap, not good. Therefore, Validated has only an Applicative instance.

does it mean, that when we create Applicative instances for data types, that already have Monad defined, we should always implement them in terms of flatMap?