Context functions are one of the new contextual abstractions coming in Scala 3. The release is approaching quickly, the design is finalized, so let’s explore the feature in more detail!

If you’d prefer a live-coding video version, see the recent Scala In The City meetup on the same topic.

An audience with the King by Zofia Warska

What is a context function?

Before we dive into usage examples and consider why you would be at all interested in using context functions, let’s see what they are and how to use them.

val f: Int => String = (x: Int) => s"Got…

Shelly — a programming language for drawing — is one of our side-projects that we work on in-between other engagements.

Shelly delivers the well-known concept of turtle graphics in a modern package, with a friendly interface, instant drawing, rich…

The serverless model has a lot of appeal: simple to deploy, simple to scale, no hardware to manage, and no upfront financial commitments. However, we have to realize that using a serverless platform is in fact programming the [Amazon|Google|Microsoft] “virtual machine” which is induced by the myriad of services each of these clouds offers.

We can’t trust the data that reaches our servers. We have to make sure that it’s properly formatted, within range, that it references entities that exist in the database, or that the data matches dynamically defined business rules. A wide range of responsibility!

After a long series of RC releases, many planned and unplanned changes, the 3.0.0 release is here. Let’s take a brief look at what’s new & changed.

But what is sttp client?

It’s the Scala HTTP client that you always wanted! More elaborately, quoting the documentation:

sttp client is an open-source library which provides a clean, programmer-friendly API to describe HTTP requests and how to handle responses. Requests are sent using one of the backends, which wrap other Scala or Java HTTP client implementations. The backends can integrate with a variety of Scala stacks, providing both synchronous and asynchronous, procedural and functional interfaces.

Backend implementations…

Let’s apply functional programming to a practical problem. Can you guess what it’s going to be?

  • Scala, a type-safe, high-level functional language
  • sttp tapir to define the web socket server
  • sttp client to interact with the web socket as a client
  • http4s to expose the server to the outside world
  • Monix to manage and capture…

Tapir is a library for describing HTTP endpoints as immutable values, using a type-safe, composable API. Until recently, tapir’s main functionalities included the ability to describe “regular” REST-like endpoints, and interpret these descriptions as a server, client or OpenAPI documentation.

One of the most-voted feature is here in version 0.17!

Describing a web socket

In tapir, we already have a…

Time flies, and before you know it, we have another Java release. In line with the half-year release schedule, it’s time for Java 15, which paves the way for the upcoming Java 17 LTS (a year from now).

Recently at our semi-regular architecture discussion group, we’ve been looking at the Auth0 service: what it is, how it works and when it might be a good idea to use it.

For the past three months we’ve been working on an update to sttp client, which is now available as version 3.0.0-RC4.

More than ever, sttp client is THE Scala HTTP client you always wanted :)

There’s a couple of breaking changes — take a look at the release notes for the full overview. We’ll cover some of the new features below.

Beskid Żywiecki by Jacek Kunicki

Simpler web sockets

sttp client introduced web socket support in version 2. While the design was comprehensive, it was unnecessarily complex (too flexible!) and irregular. …

Adam Warski

Scala software engineer, Functional Programming enthusiast, SoftwareMill co-founder

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store