scala

bpholt's picture

Partial Application of Type Parameters in Scala

Scala doesn’t directly support partial application of type parameters, which can be frustrating when several are required but only a portion can be inferred by the compiler. For example, this implicit class wraps a request object from the Amazon Java SDK and defines a method that accepts an asynchronous function that should be used to execute the request. (This provides a more fluent Scala API than using the Java SDK directly.)

Since the effect type F is not bound anywhere else, it cannot be inferred. I would like to provide just the type of F and let the compiler infer Req and Res. Unfortunately, since Scala doesn’t support partial application of type parameters, the caller has to explicitly provide all three types.

There is a workaround. One can wrap the function in a class paramterized by the unknown types, define an apply() method on the class that is parameterized by the inferrable types, and provide a function returning a new instance of the class. (The details are more fully explained in this blog post by Tony Morris.)

Read the full details in the full post.

bpholt's picture

Scala, Docker, and our open-sourced SBT tools and libraries

At Dwolla, the platform team dedicates lots of time to writing tooling, making our teams’ lives easier. What’s particularly exciting is when those tools have wider application beyond the walls of Dwolla. Since our team spends lots of time with Scala microservices deployed using Docker, we’ve written several SBT plugins and helper libraries. These plugins help us manage our services, both in production and locally during development.

All of the projects described below have been released on GitHub using the MIT License—pull requests are welcome! Each project contains a Bintray badge in its README, linked to where its artifacts have been published in one of Dwolla’s Bintray repositories.

Syndicate content