@igallegosagas

Very clear, doesn't It?
[ 1 reply ]
Alvinalexander
1 year ago
Scala

Demonstrating Scala collections methods with fruit

Demonstrating Scala collections methods with fruit.:) Kudos to whoever came up with this technique first.
Alvinalexander
1 year ago
Scala

The three principles of functional programming

As an example, here are the "three principles of functional programming," from this tweet:
...
Orthogonal composability 2.Maximum polymorphism 3.Maximum deferment
Conversely, here are the "three pillars of functional programming," from Functional and Reactive Domain Modeling:
...
Referential transparency 2.Substitution model 3.Equational reasoning
...
When I started learning FP (and later took two years to write Functional Programming, Simplified) I was surprised there wasn't a single accepted definition of functional programming.
New version of Scala !
[ 2 replies ]
Scala-lang
1 year ago
Scala

Scala 3.2.0 released!

What's new in Scala 3.2.0

...
-coverage
...
-Vprofile-sorted-by: prints the same output as -Vprofile, but it is sorted according to a specified column, for example: complexity or lines -Vprofile-details summarizes the profiles of the most complex methods
...
-Vprofile-sorted-by:
...
complexity
...
-Vprofile-details summarizes the profiles of the most complex methods
-Vprofile-details
...

Stabilised APIs

...
We thoroughly tested all release candidates for 3.2.0 to detect any source incompatibilities.We run a so-called Open Community Build, a compilation of nearly 1000 real-life projects on each compiler build.
Very good article by @adamwarski
[ 1 reply ]
SoftwareMill
1 year ago
Scala

The future of effects in Scala?

But as it turns out, there's no consensus as to what the problem actually is!
...
Instead, the proposal introduces suspend functions and continuations, which allow programming in a direct style, while keeping the above mentioned features of the monadic style.
...
However, I think there's one deeper issue before accepting it as a SIP and incorporating it into Scala.
...
Should the signature of the method indicate that it performs side-effects?
...
finally, Martin Odersky is starting a research program, Caprese to investigate possible ways to track effects in Scala, so this might yield new options.
...
Should the information about the effect propagate to callers all the way up to the boundaries of the application, or should it be eliminatable?
...
However, this isn't useful anymore on a JVM 19 runtime, which includes Loom.With Loom, most operations that have been run asynchronously for performance can now be run synchronously (even if behind the scenes, on a low level, an async implementation is used).Hence, tracking asynchronous operations in the type system no longer makes sense.
...
Another candidate, proposed by Martin Odersky is to track suspension points.
...
Finally, my proposition would be to track remote calls.
...
An important note here: not all participants of the discussion agree that it's really a problem; see for example this post by Li Haoyi.
...
John de Goes argues that we shouldn't focus on tracking effects, as such an approach is "commercially useless".
...
Instead, John proposes composable error handling as a solution.
...
Finally, an important part of the discussion has been taken by the impact of the upcoming Loom project, which will be previewed in JDK 19.Loom implements lightweight (virtual) threads on the JVM, making it possible to quickly start thousands of them, without the overhead that has been present so far.
...
Why would this concern Scala?The primary platform on which Scala is used, is the JVM.
...
In fact, the prototype suspend functions implementation mentioned in the proposal is based on Loom!
...
See also my article from two years ago where I try to investigate the topic a bit deeper: Will project Loom obliterate Java Futures?
...
Ultimately, it's up to the Scala stewards - Martin Odersky, EPFL, and the Scala Center - to decide which road Scala will take.
...
As always, exciting times for all Scala developers out there :)
Learning some Cats for wirk
[ 3 replies ]
Medium
1 year ago
Scala

9 tips about using cats in Scala you might want to know

The *> operator, defined on any Apply (so, Applicative, Monad etc.), simply means "process the original computation, and replace the result with whatever is given in the second argument", or, in code terms (in the Monad variant) :
...
more importantly, >> has the second operand be invoked call-by-name, i.e. fb: => F[B] .
...
mapN is a helpful utility function in the context of tuples.
Interesting read.
[ 2 replies ]
Alvinalexander
1 year ago
Scala

How to sort a sequence (Seq, List, Array, Vector) in Scala

(Or, how do I implement the Ordered trait in a custom class so I can use the sorted method (or operators like <, <=, >, and >=) to compare instances of my class?
...
The sorted method can sort collections with type Double, Float, Int, and any other type that has an implicit scala.math.Ordering: scala>val a = List(10, 5, 8, 1, 7).sorted a: List[Int] = List(1, 5, 7, 8, 10) scala>val b = List("banana", "pear", "apple", "orange").sorted b: List[String] = List(apple, banana, orange, pear) The "rich" versions of the numeric classes (like RichInt) and the StringOps class all extend the Ordered trait, so they can be used with the sorted method.
[ Load more ]