This is part 2 in a series of blog posts on macro metaprogramming in Scala 3. (Click here for part 1) In the previous part I have introduced the two macro APIs as well as several related concepts of metaprogramming with type families and implicits. If you haven’t read it already, you should do so now as the rest of the article won’t be understandable without it. In this second part, we will apply all our knowledge to a practical example and learn how to generate new classes with macros. Quite a bit of arcane magic is necessary to make this possible and it is my goal of this blog series to share with you all the tricks that I have worked out to maneuver around limitations of the compiler.
With the release of Scala 3, one of the biggest changes to the language revolves around metaprogramming: Inline-functions, match types, generic-programming tools like tuple types and Mirror
s, as well as a new macro API have been added to make code generation a major concern of Scala. Naturally, one of the first things you may want to do is generate new classes, which is much harder than it sounds. My goal for this series of blog posts is to teach you all of the secret tricks to work around macro limitations and obtain the forbidden fruit (or something close to it). Part 2 can be found here.
Oha, dieses Projekt haben wir lange nicht angefasst. Die benutzten Bibliotheken hängen voller Spinnweben, und auch die Programmiersprachenversion war schon vor einem Jahr nicht mehr aktuell. Bevor ich loslegen kann, muss hier erst einmal aufgeräumt werden… Über Sicherheitslücken in den alten Bibliotheken will ich gar nicht nachdenken.
Nachdem im ersten Teil einige Catamorphismen vorgestellt wurden, die mit rekursiven Datenstrukturen arbeiten, beschäftigen wir uns nun erstmal mit dem Gegenteil. Ein Anamorphismus verwendet eine CoAlgebra von Typ a -> f a
, um eine Datentypen aufzubauen. Damit habe ich es auch eilig, denn ich bin es leid, mir Testdaten stets mühselig im Stile von Node 3 (Leaf (Node 4 Leaf Leaf))
aufzubauen.
Seit geraumer Zeit bin ich fasziniert von “recursion schemes” und habe mich in Scala und nun auch in Haskell mit ihnen beschäftigt. Aber was sind “recursion schemes” und worin liegt für mich ihre Faszination?
Am 07.03.2018 hielt ich beim Meetup der Lübecker Softwerkskammer einen Vortrag zum Thema Property-based Testing.
The last episode of this series covered the motivation behind Monad Transformers and gave some examples of their usage. Now it is time to show a small real world application. By chance I stumpled accross this section of code in an open source project:
Let’s say you are a typical scala programmer, making plenty of use of Future
s in your code. Sooner or later you end up having APIs like the following:
I found a post by Qiaochu Yuan that has the following definiton: A comathematician is a device for turning cotheorems into ffee.
Apparently this is a very funny joke. Could someone explain it to me and tell me where I could learn about the subject in question? Thank you very much in advance.
In our current project we just wanted to see which requests exceeded a certain response time threshold. Additionally we wanted to know where the time was spent, i.e. which backend requests (e.g. hitting the database or search engine) contributed how much to the overall response time. So we’d like to get log entries like this:
Today we talk about the little wiggly operator |@|
. Being slightly deaf and one of the few living persons on this planet who never watched a Star Wars movie, I always thought people call this the allah al akbar
operator, when in fact it is called the Admiral Ackbar
operator. If you haven’t so far, please read the post about Applicatives as this blog post builds on top of it.
Jetzt ist es offiziell: Seit 6 Monaten arbeiten wir von inoio zusammen mit weiteren Dienstleistern und Galeria Kaufhof an deren neuer Multi-Channel Online Plattform - Projektname “Jump”. Mit dem neuen System soll die Time-to-Market erheblich reduziert werden, wenn es um die Einbindung und Entwicklung neuer Features geht.
In the last installation of this series, we covered the Functor and now we take a turn to discuss the Applicative
type class.
In the last installation of this series, we covered the Foldable and now we take a turn to discuss the Functor
type class. Basically we cover some building blocks out of which more complex type classes can be build.
In the last installment of this series, we had a look at one of the most primitive type classes, the semigroup. Today we add one nifty feature to it, namely the notion of an identity element zero
:
trait Monoid[A] extends Semigroup {
def zero : A
}
Almost immediately when I started to program in Scala, I became intruiged by scalaz
, the scala type class library. After playing and learning a bit, I decided that I essentially rewrite the library to get a better understanding of its concepts. I do not intend to replace scalaz, I skip lots of the optimization techniques, and left out many of the “non essential functions”. Gradually I will blog about the experiences and compile a tutorial much in the style of the essential Learning scalaz by Eugene Yokota.
In our current project we have to consume a REST web service that provides data as a multipart document, e.g. a list of videos (or video metadata) where each video is a single part. While it’s common to submit or handle multipart requests (e.g. multipart/form-data), the multipart content type is not widely used for http responses. In consequence, the support of http clients for multipart responses is not as good as for requests. The Play Frameworks WS client for example does not directly support responses of type multipart/*
.
We develop custom software, sometimes from scratch, sometimes it will be included in existing ecosystems. In both cases, the customer oftentimes wants to fix which technology we should use. We take the customer’s requests into consideration a lot, but try not to give him what he wants, but the best overall solution given the parameters of the project. Oftentimes we recommend Scala as a programming language, despite the fact that customers want Plain Old Java.