Scaffolding a Blog Post

Posted on December 26, 2019 by Riccardo

It’s been two months since the last post. I had a chance to learn a lot of cool stuff that I cannot wait to share! But let’s start with something eazy.

Today, we are going to take a look at a short script written in Haskell with a simple goal in mind: scaffolding a new file with an empty frontmatter, ready to house a new blog post (including this one!).

Hopefully, this will also show how nice it is to use Haskell even in a simple case. Including how helpful is to have a strong type system holding our hands in the process.

We won’t be covering the specifics of the Stack script interpreter. That has been already covered in “Scripting in Haskell and PureScript”.

Suffice to say we need to have an executable file (i.e. chmod +x file.hs) and the following at the top of the file:

With that in place, ./file.hs is enough to execute the script.

But let’s dive right in the scaffolding one:

And frontmatter is an empty frontmatter ready to be filled:

The whole script can be found on Github.