MLabs Publications
The many minds at MLabs present news, case studies, editorials, tutorials, whitepapers, Cardano Catalyst proposals, and more.
Fast Findings with SWAR and the FFI: The Good, the Bad, and the Inefficient
In this post, we compare three ways to find the first matching byte in an ASCII sequence—naive loops, SWAR (SIMD Within A Register) techniques, and the C memchr via Haskell’s FFI. You’ll learn how each performs in real benchmarks, where FFI can deliver 50× speedups, and why overhead can erase those gains in certain workloads.
Our Performance is massiv: Getting the Most Out of Your Hardware in Haskell
In this post, we explore how to write high-performance Haskell code using multi-dimensional arrays—comparing vector and massiv across clarity, parallelism, and raw speed. You'll learn how array layout, indexing strategies, and stencil-based computation can unlock massive performance gains by leveraging modern hardware more effectively.
First Know Thyself: Understanding String Matching Performance With ASCII
In this post, we explore the performance characteristics of string matching in ASCII text, comparing brute force, Boyer-Moore-Horspool, and DAWG-based approaches. You'll learn how benchmarking, algorithmic analysis, and practical implementation tradeoffs intersect—revealing when optimizations help, when they hurt, and how understanding your tools leads to better real-world performance.
The 'A' is for 'Accelerated': Checking ASCII with SWAR
In this post, discover how to push Haskell’s performance boundaries by using SWAR (“SIMD Within A Register”) techniques to validate ASCII data in bulk. You’ll see how packing bytes into registers—using bit masking to flag non-ASCII values in parallel—and unrolling loops to leverage the CPU’s superscalar engine both drive down overhead. By the end, we'll transfer a simple foldl'-based ASCII detecting function into a version running 10x faster.
Quasiquoting for Fun, Profit, Expressions and Patterns
In this post, discover how quasiquoters overcome three key smart-constructor limitations—compile-time errors, lack of pattern matching, and fixed syntax—by leveraging Template Haskell to produce both expressions and patterns with familiar, literal syntax.