Posts
Providing the USD/VES Rate, using C# Functional Extensions
As part of dobs, a C# CLI USD-VES converter, I wrote a library that provides the official exchange rate from the US dollar to Venezuelan Bolivars (VES). I developed the dobs app mainly for personal use and to practice building .NET applications in C#. I also took the opportunity to explore the CSharpFunctionalExtensions library. In this post, I describe this Rate Provider library, which can serve as an example use of CSharp Functional Extensions.
Posts
Calculating the nth prime in Rust, with memoization and thread-safety
Going through the Rust track at exercism.org, I found the Nth Prime exercise. The exercise asks to determine the nth prime for a given integer n, considering 2 as the 0th prime. To make it more interesting, I decided to memoize the calculated primes in a table and to make the calculation thread-safe so that several primes can be computed concurrently. The implementation described here is available as a GitHub repo.
Posts
Parsing Diff Output in Haskell
Parser combinators and the libraries available to build parsers using them are among the best features of Haskell. I describe here a parser for diff output written in Haskell using attoparsec, a monadic parser combinator library designed to be fast and efficient. The parser accepts git output in the normal or unified format, or the output produced by “git diff” when comparing two files. I assume the reader has some familiarity with monadic parsing in Haskell, particularly with the Attoparsec library, as well as with the diff formats parsed.
Posts
A Grammar For Diff Output (in Normal, Unified, and Git formats)
In this article, I describe a grammar for the normal and unified formats generated by the diff utility, and for the diff produced by git when comparing two files, which I’ll call git format. I describe the grammar in EBNF, as described on Wikipedia.
The first and second files being compared or diffed are usually called “original” and “new”, or “source” and “destination”. In this post, they are called left and right files.
Posts
A Gentle Introduction to optparse-applicative
Any command-line program that accepts several options and arguments requires parsing, handling, and validating them, as well as producing useful error and help messages. For most programming languages, you will find libraries designed to facilitate this task, which can become quite complex and repetitive. In this article, you’ll learn to use optparse-applicative, an excellent Haskell library for parsing arguments for command-line programs. We will create a parser for an example app with several kinds of options, incrementally introducing the most commonly used library features.