Hasql v2 is here! It can run natively in Haskell with no external dependencies or the same way it always has, using “libpq”. It’s the user’s choice now. No breaking changes in the API except for the choice of the adapter in the connection settings. With this release it enters a new era, where the native implementation matures incrementally without imposing risks on users and providing them the…
For years, every serious Haskell PostgreSQL driver has been chained to the same C library - libpq - with no clean way out. I tried to cut it loose twice, and both times I failed at the finish line. They say the third time’s the charm. I hope it will be - not because I’ve tried harder, but because I’ve changed the goal. I’m Nikita Volkov, author of hasql . This is the story of that reframe, and of…
Hi, I’m Nikita Volkov - architect, consultant, and the author of hasql , one of the two main PostgreSQL drivers in Haskell used in major production projects like PostgREST and IHP. After 25 years in IT and more late-night schema-drift fires than I care to count, I open-sourced something I wish had existed a decade ago: pGenie . Following is the story of how I went from shipping a popular ORM in…
If you’re working in an organization that maintains a private Haskell codebase chances are you’ve stumbled upon the problem of distribution of packages. The typical approaches to this are either to avoid that altogether by maintaining the whole codebase of the org as a monorepo or to manage a private Hackage server. Both come with their own sets of problems. The first tends to entangle the…
In this post I’m gonna highlight the issues of the “Internal” modularisation convention and provide a proper solution to the same set of problems. Contents About the Internal convention The issues of the convention The versioning policy The mess The solution The benefits About the Internal convention If you’ve been doing Haskell for any time at all you’ve probably already stumbled upon this…
Today I’m announcing the “compound-types” library . This library provides first-class multi-arity product- and sum-types and neat type-level utilities for their composition. The solution is quite simple and doesn’t require the advanced proficiency in the language to be applied in practice. Contents What are the product- and sum-types? Examples and benefits of “compound-types” What are those + and…
Recently a question by Chris Done on Reddit has spawned yet another debate on the subject of whether Haskell’s laziness is actually a good thing. With this post I’m not going to state my take on the matter, instead I’ll speculate on what Haskell could be like were it a strict language and how it would approach the standard problems. Contents Conditions Deferred Thunk Thoughts on compiler…
Have you ever looked for a numeric type with a zero to hundred range to describe percentage? Maybe a zero to one to describe a proper fraction of something? A positive integer (without the zero) to enumerate something? A vector of a specific length? Here that comes and not only with the Haskell refinement types library ( on GitHub , on Hackage )! Contents The problem The “refined” library Why do…
Today I’m releasing the “record” library , which is an API of just two quasi-quoters, providing a full-scale solution to the notorious records problem of Haskell! Contents The records problem Introduction to the “record” library Features Project status First, a bit of a background on the problem. The records problem The current record system is notorious for its major flaws: It does not solve the…
Like many other Haskellers even after considering myself an expert in the language I still get that amazing “wow” moment, when I learn another elegant thing about its basic concepts, from time to time. Recently I was working on a project, which required a primitive parsing functionality, and I discovered that amazing results in terms of performance can be achieved using the good old State monad.…
This post is all about the performance of the “hasql” library and particularly its PostgreSQL back end in comparison to its popular direct competitors: “HDBC” and “postgresql-simple”. Contents Benchmarks What makes Hasql so fast? Benchmarks The source of the PostgreSQL back end comes with a suite of 3 benchmarks . I’ll analyze them one by one. Results parsing In this benchmark a simple SELECT…
Composition and Decoupling Proficient programming is all about decomposition of complex problems into smaller pieces. Most of us know that. When the smaller pieces are completely decoupled from each other you achieve the zen of being able to work on each of them in complete isolation. This means that whatever the entities you define in those smaller abstraction pieces, you can be sure that they…
A couple of days ago I released the “stm-containers” library . In this post I’ll talk about the motivation behind the library, its features and performance. Contents Motivation Features Performance Ben, I need help! Update Motivation Why not a HashMap over TVars? The type TVar (HashMap (TVar a)) seems to be an evident solution. The problem about it is that while this datastructure captures the…
Profiling in Haskell can be an overwhelmingly confusing task. There’s plenty of little things you need to set up right to be able to perform it. This post aims to organize this information. Summary The project must be configured with profiling enabled. Some specific options must be set when configuring the profiling executable in the “.cabal” file. All the project’s dependencies must be installed…