Menu

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...

Choosing variance for a phantom type

When you use a type parameter to abstract over actual data in your ADT, there is typically only one variance that makes sense, if you choose to incorporate subtyping into your designs at all. This is the natural, “parametrically sound” variance. sealed abstract class MyModel[P, I, -T, +V] final case...

Higher-kinded types: the difference between giving up, and moving forward

As its opening sentence reminds the reader—a point often missed by many reviewers—the book Functional Programming in Scala is not a book about Scala. This [wise] choice occasionally manifests in peculiar ways. For example, you can go quite far into the book implementing its exercises in languages with simpler type...

Making internal state functional

This is the ninth of a series of articles on “Type Parameters and Type Members”. Scala’s CanBuildFrom API is relatively well-founded and flexible; in combination with GADTs, it can provide that flexibility in a fully type-safe way, if users choose not to circumvent it with typecasting. However, it is designed...

The Typelevel Summit in Boulder is Cancelled

As a result of LambdaConf’s decision to invite Curtis Yarvin as a speaker, the organizers of the Typelevel Summit Boulder have decided that affiliation with LambdaConf is no longer compatible with Typelevel’s goals, and we are cancelling the event, which was scheduled to happen on the Wednesday before the conference....