Menu

Equivalence versus Equality

This is a guest post by Tomas Mikula. It was initially published as a document in the hasheq. It has been slightly edited and is being republished here with the permission of the original author. This article describes what we mean when we say that the data structures in this...

Four ways to escape a cake

The mixin style of importing in which classes and traits are defined within traits, as seen in scala.reflect.Universe, ScalaTest, and other Scala styles, seems to be infectious. By that, I mean once you define something in a trait to be mixed in, to produce another reusable module that calls that...

There are more types than classes

As programmers, we are very incautious with our use of the word “type”. The concept of “type” is sufficiently abstract and specific that we are tempted to understand it by analogy, so much that we begin to confuse analogy with sameness. The colloquial “runtime type”, a fair approximation of “class”,...

Endorsing the new Scala Code of Conduct

A couple of days ago, the new Scala Code of Conduct was published. It applies to all official Scala channels, including mailing lists, Gitter channels and GitHub repositories. We would like to take this opportunity to endorse this new Code of Conduct. From our perspective, it does a good job...

API Design for Heaps (aka Priority Queues)

This is a guest post by Chris Okasaki. It was initially published as the design document behind scads. It is being republished here with the permission of the original author. A heap (or priority queue) is a collection of elements ordered by some Ordering, optimized for retrieving the first element...

EDSLs as functions

This is the second of a series of articles on “Monadic EDSLs in Scala.” Perhaps the most direct way to start writing an EDSL is to start writing functions. Let’s say we want a language for talking about sets of integers. trait SetLang { def add(i: Int, set: Set[Int]): Set[Int]...

Typelevel representative at the Scala Center Advisory Board

It is our pleasure to announce that the Scala Center Advisory Board has invited us to nominate a member of the Typelevel community to serve as a community representative, alongside Bill Venners. To figure out whether or not we should accept this offer and who we pick we have held...

Let's build ourselves a small ScalaCheck

ScalaCheck is a well-known property-based testing library, based on ideas from Haskell’s QuickCheck. It is also a Typelevel project. In this post, I’d like to show some of the underlying mechanisms, stripped down to the bare minimum. Testing with properties is well-understood in academia and widely used in parts of...

Subtype type classes don't work

The common encoding of type classes in Scala relies on subtyping. This singular fact gives us a certain cleanliness in the code, but at what cost? Problem Consider the following hierarchy of type classes. A similar hierarchy can be found in both Cats and Scalaz 7. trait Functor[F[_]] trait Applicative[F[_]]...

It's programs all the way down

This is the first of a series of articles on “Monadic EDSLs in Scala.” Embedded domain specific languages (EDSLs) are a powerful tool for abstracting complexities such as effects and business logic from our programs. Instead of mixing ad-hoc error handling, database access, and web calls through our code, we...