Observations on what's around me and projects I'm working on.


Posts tagged with scala

Configuring Helix for scalafmt

I don't do much Scala anymore, but when I do I make use of Scalafmt so I don't have to care about all that stuff.  In the Helix editor, to be able to run :fmt on a Scala file you need this in your ~/.config/helix/languages.toml file: [[language]]name = "scala"formatter = {   command = "scalafmt",   args = ["--stdout",...
Read more

Exclude Metals from your Docker builds of Scala projects

Metals is a Scala language server. It gives your editor IDE-like abilities. In one project it was failing to start,  which was causing me much head scratching because a Docker build of the same project also started failing. What’s the Docker build got to do with my editor? Doug spotted the source of the problem: it was...
Read more

Review Seq matching when porting to Scala 2.13

You know the routine for porting from Scala 2.12 to 2.13: you’ll get a bunch of compiler errors and warnings, and you can quickly enough hack your way through them. There is, though, one runtime issue I’ve bumped into. When pattern matching on Seq from a library, you need to be careful about what kind of a Seq you’ve...
Read more

Tips for moving from tut to mdoc

Creative Scala and Essential Slick use mdoc, as will Scala with Cats in the next edition. mdoc helps us be sure the code we describe works, no matter how often we update the text. It does this by typechecking and running the Scala source in our text. Before mdoc we used the mighty tut. We’ve learnt a few tricks as we...
Read more

Modelling JavaScript in Scala with Scala.js

Surely there’s something in JavaScript that Scala.js can’t handle? If there is, I’ve not found it yet. Each time I’ve faced some JavaScript obstacle I’ve been overjoyed to find an answer in Scala.js. In this post I’ll highlight 3 features from Scala.js 1.x that I’ve recently used to dig myself out of a hole:...
Read more

Day in the life of a functional programmer

Earlier this week I gave a 45 minute talk on “A day in the life of a functional programming”. The title is one Miles came up with when we were brainstorming the talk. The idea was to try to get across some of the exciting ideas in FP to non-Scala developers. We went for ADTs and type classes. Notes what I said (or...
Read more

Scala and 22

Back in 2014, when Scala 2.11 was released, an important limitation was removed: “Case classes with > 22 parameters are now allowed”. This may lead you to think there are no 22 limits in Scala, but that’s not the case. The limit lives on in functions and tuples. This post explores the limit, looks at an example from...
Read more

Scala.js is important for cloud services

More people are using serverless architectures than I would have guessed, and they are getting significant benefits from doing so. Scala is a great fit for these kinds of architectures because it can use the JVM and, thanks for Scala.js, JavaScript runtimes too. This post is a small observation regarding this. Examples...
Read more

Scala and AWS Lambda blueprints

AWS Lambda is a service that allows you deploy a function to the web. There are no servers to maintain, and billing is based on the compute time your function uses. At the end of 2015, Amazon launched a set of AWS Lambda blueprints to help developers get up and running with Lambda. These consists of Python and...
Read more

Using the Atom editor with Scala

If the IDE or editor you’re using for Scala isn’t working for you, or you want a change of scenery, try another tool. It’s easy to switch. This post looks at Atom.Inside Underscore there’s a mix of developer tools. Emacs, vim, Sublime Text, Eclipse, and IDEA all get used. I use Atom. Update: Visual Studio Code won. Atom...
Read more

SBT tricks

Dear Richard: these are the SBT tricks you should have known about. They are the ones you wish you could remember just when you need them, but you don’t. So here they are written down. Changing JVM Options Mid-session you sometimes want to change JVM flags. The javaOptions setting is good for that. For example… Trace...
Read more

Using slickless with plain SQL

With shapeless HList support available for Slick, we can make further use of shapeless to reduce boilerplate code. This post explores how to do this for the Slick GetResult type class. Plain SQL Slick allows you to write plain SQL queries. They look like this: val action = sql""" SELECT "id", "email" FROM "users"...
Read more

Upsert in Slick 3

An upsert means inserting a row into a database if it doesn’t already exist, or updating the row if it does exist. The Slick database library knows how to do upserts. This posts takes a look at the built-in support, and gives an example of what you can do if you need to roll your own upsert logic. This is part of a...
Read more

Towards browser and server utopia with Scala.js

At Scala Days 2015 in Amsterdam I talked about Scala.js, and in particular focussed on the great interoperability with JavaScript. This post gives additional links if you want to dig deeper.BackgroundIf you’re looking for more background information on CRDTs, Noel posted on this a while back.The algorithm I ran through...
Read more

Typechecking SQL in Slick and doobie

Querying a database is sometimes best done with hand-written SQL. Of course the trick is to find a way to avoid syntax and type errors at run time. This post will look at how Slick and doobie approach this problem. To keep things simple, we’re just going to look at one SQL statement: select "content" from "message" The...
Read more