I recently wrote tomlcheck, which, as the name implies, is a syntax checker for TOML files. Since I'd read a call-to-arms regarding the lack of concrete success stories in Haskell a few months ago, I figured I'd contribute one of mine.

# The Good

tomlcheck was an easy success. If you don't believe me, here's the language composition for my project, lovingly provided by tokei.

Language Files Lines Code Comments Blanks
Cabal 1 76 69 1 6
Haskell 3 43 31 4 8
YAML 3 121 103 3 15
Total 7 240 203 8 29

So it's only around 43 lines of Haskell, thanks to already available htoml package and the oprparse-generic package. I did admittedly rewrite a bit of the htoml package to use megaparsec, plus I had to write some patches for bugs which I may have introduced.

Megaparsec is really, really good. In addition to the fact that monadic parser combinators are far better than what's available in most languages, its builtin error pretty printer generates errors that vim can scan. This ended up being the primary reason I wrote tomlcheck in Haskell rather than Rust.

tomlcheck's performance is superb, and I am eminently satisfied with Haskell in this regard. Checking the largest file I could find in real use (182 lines), it takes around 3.5 ms - basically instantaneous. It feels different than yamllint.

You can see this in the tokei output too - there are around 120 lines of YAML required to configure Travis and Appveyor.