It is somehow shared knowledge among Haskellers that applicatives allow performing static analysis, while monads do not. But what does it mean in practice? And what kind of static analysis is this referring to? The best answer I could find online is this answer on StackOverflow. In this post...
Haskell is a programming language well known for its usage of monads and for the over-abundance of tutorials trying to explain them. This is not one of those posts. On the other hand, in this post I’ll try to convince you that Haskell without monads (as a main concept) is not only possible, but...
In this post I’d like to try to discuss what functional optics are, without going too much into why they are so cool, and you should use them, or how they are implemented1 and should be used with a specific language and library. I personally think that functional optics should be a really easy...
When we think about interfaces in software development, it’s easy that our thoughts go the interface keyword used in many Object-Oriented languages like Java and C#. But interfaces are a much more general concept, and they could be defined as: an interface is a shared boundary across which...
When we are writing our beautiful code we often need to deal with dependencies, might they be tools, libraries, or simply other code we wrote some time ago. Choosing to use a dependency usually comes with its own set of tradeoffs and constraints. For example using a relational or a...
The level of progress in programming language design: Shortly after the first ever programming language was created, it’s author said that the language’s whole paradigm is flawed and we should do functional programming instead*. That was 46 years ago. We still use the same paradigm. *Can...
One of the aspects which sets Haskell apart from other programming languages is that we tend to handle our effects with care. We are used to using monads to encode side effects; for example we use Either e to encode failures, Reader r to describe configuration and State s for stateful...
Either is one of the easiest data structures which can be used to make your code safer and more composable. It is not particularly complex but sometimes it is still hard to grasp, especially for programmers used to a procedural or object oriented approach. In this post I’ll try to give an...
Soisy is an Italian startup working in the fintech sector, providing a payment by instalments system to affiliated e-shops. Some months ago the need to release a new version of our risk engine emerged, so we started considering how to actually build it. The decision we took was to use Haskell....
Edit: you can find this code on Hackage at free-vl. Algebraic effects seem to be a sort of holy grail in functional programming. What I mean when I say “algebraic effect” here is: treating any effect like a value or type in your program, while also having some simple operations (an algebra) to...
(Boy is there a lot of Haskell here now. What’s up with that?) This one comes by way of Shachaf Ben-Kiki, who found it originally and mentioned it to me. Data.Traversable and Data.Foldable are two Haskell typeclasses that express related notions of a data structure being “list-like” in the sense...
Free Monads are a powerful abstraction for modeling operations in your program. While there are many articles about free monads, there are relatively few about using free monads. At my current work we have a large Free Monad that abstracts various actions one might do against data in our system....
I spent a while talking with Greg Price about the Haskell Network.HTTP issue previously featured here, and he was unconvinced I had the whole story. He spent a while reading some source and thinking about folds, and pointed out today that my analysis was incomplete, and flat-out wrong for the...
For some reason I’ve been thinking about Continuation Passing Style a lot lately. I was reading some old code and realized it could have been simplified had it been done in a continuation monad. Did I really understand continuation passing style? When thinking about simple and unnecessary uses of...
yo dawg, I heard you like strings in your types so I put a type in your string so you could type check your strings while you stringify your types - Proxy “XZibit” The saying goes that one should encode as many invariants in the type system as possible. This way bad programs don’t type check,...
At the end of my post Type Families Make Life and Free Monads Simpler I conjectured whether it would be possible to write a “CRUD” library around the Free CrudF monad. The exact meaning of a library in this context is somewhat nuanced. What libraries look like when you’re doing type-level...
After watching Ollie Charles’ talk on Strongly Typed Publish/Subscribe over Websocks via Singleton Types, I felt very inspired to try some type-level programming in Haskell. Along the way I stumbled across a really handy design pattern I thought I would share. Recently I’ve been working with...
I love Nix. I’ve been running NixOS for the past few weeks and it’s been a great experience. However, I started a new job recently and have been thinking about our deployment pipeline and how we will manage build and run-time environments. Finding the boundary between Nix and Docker in this area...
I believe the most important value in a programming language is not performance, libraries, ecosystems, or tooling. While these are crucial to their adoption and success, a feature often overlooked is code comprehension. By this I mean: how easy is it for someone to read code and comprehend what...
I'm shocked and appalled at the fact that there is no generic regex substitution function in the GHC libraries. All I'm looking for is a simple function equivalent to perl's s/.../.../ expression. After digging around a bit, I found subRegex in regex-compat. While this works well, it does not use...