Articles from Alex Korban

Primary tabs

Elmstatic 0.3.1: generate subsections, make index pages, add page aliases

New release is out today. Now it allows you to:

Create subsections with their own posts
Create Index.elm pages which turn into index pages, both at the root level and at subsection level. For example, Pages/Index.elm becomes the page at / in contrast to Pages/Projects.elm which becomes /projects. At subsection level, Pages/Elm/Index.elm becomes the page at /elm, while Pages/Elm/Projects.elm becomes /elm/projects.
Use the postprocessing copy step to give pages aliases (eg /projects can be made ...

Introducing Elmstatic: an Elm-to-HTML static site generator

I've been using Elm to generate this site for a few months. It's still highly experimental and incomplete but I hope that other Elm enthusiasts may find it useful.

At the moment, it works for my needs and allows me to generate this site with a single command, but it requires manual intervention if I'm doing things like deleting pages or adding new Elm dependencies, and I'm sure there are many use cases it doesn't address.

I think I have something barebones but useful so I published it on NPM ...

Decoding recursive JSON in Elm

There are a number of posts about decoding recursive JSON in Elm, but I still found it was a slightly tricky task, particularly because the way the Elm compiler deals with recursion requires a workaround in the decoder code to avoid rather confusing runtime errors. In this post, I'd like to tell the story of implementing recursive decoders.

The path to a recursive decoder

The basic structure of the JSON we need to decode is like this (this happens to be the PostgreSQL EXPLAIN command output):...

Decoding recursive JSON in Elm

There are a number of posts about decoding recursive JSON in Elm, but I still found it was a slightly tricky task, particularly because the way the Elm compiler deals with recursion requires a workaround in the decoder code to avoid rather confusing runtime errors. In this post, I'd like to tell the story of implementing recursive decoders.

The path to a recursive decoder

The basic structure of the JSON we need to decode is like this (this happens to be the PostgreSQL EXPLAIN command output):...

Generating static HTML from Elm code with elm-static-html-lib

I've written a static site generator to produce my site (yaks have to be shaved, after all). Unlike thousands of other static site generators out there, mine allows me to write pages in Elm, specifically because I wanted to be able to use style-elements and get away from CSS.

I'm using eeue56/elm-static-html to convert Elm to plain HTML, and I'm about to switch to eeue56/elm-static-html-lib (thanks to Noah for his many contributions to Elm!).

But how does it work? Normally, our views produce ...

Generating static HTML from Elm code with elm-static-html-lib

I've written a static site generator to produce my site (yaks have to be shaved, after all). Unlike thousands of other static site generators out there, mine allows me to write pages in Elm, specifically because I wanted to be able to use style-elements and get away from CSS.

I'm using eeue56/elm-static-html to convert Elm to plain HTML, and I'm about to switch to eeue56/elm-static-html-lib (thanks to Noah for his many contributions to Elm!).

But how does it work? Normally, our views produce ...

Is the Elm ecosystem going stale? The numbers say no.

I've seen a lot of discussion and concern around Elm development activity recently. This comment on Hacker News is a good example: "Most packages I use and Elm itself is weeks and months old, makes me worried that it's just stale". Someone else paraphrased their boss's opinion as "Looks like it's dead now, no releases in over a year".

The concern is that this sentiment either puts people off trying Elm, or it makes them consider not using Elm anymore, or it stops them from recommending Elm to ...

Is the Elm ecosystem going stale? The numbers say no.

I've seen a lot of discussion and concern around Elm development activity recently. This comment on Hacker News is a good example: "Most packages I use and Elm itself is weeks and months old, makes me worried that it's just stale". Someone else paraphrased their boss's opinion as "Looks like it's dead now, no releases in over a year".

The concern is that this sentiment either puts people off trying Elm, or it makes them consider not using Elm anymore, or it stops them from recommending Elm to ...

How to extract values from union types in Elm

Union types are everywhere in Elm, but when you're starting to learn the language, they can be a bit unfamiliar and confusing, because they don't really exist in other languages like JavaScript or C#.

The main question I've seen people ask is: how do I extract a value from a union type?

Suppose you have a union type like this:

type UserId
= Id Int
| Uuid String

A UserId value can contain either an Int or a String. The solution for getting to those values is simple because Elm provid...

How to extract values from union types in Elm

Union types are everywhere in Elm, but when you're starting to learn the language, they can be a bit unfamiliar and confusing, because they don't really exist in other languages like JavaScript or C#.

The main question I've seen people ask is: how do I extract a value from a union type?

Suppose you have a union type like this:

type UserId
= Id Int
| Uuid String

A UserId value can contain either an Int or a String. The solution for getting to those values is simple because Elm provid...