Add Safety to Your Elm JSON Encoders With Fuzz Testing

How do you keep your JSON encoders, decoders, and model in sync? You can skip fields in your encoder, right? But should you? And what about when you add new fields? Decoders are a little easier, but you have to sync them up with your encoders or you’ll lose data. And the worst part is that we can’t rely on the compiler to catch these classes of errors… argh!

This is a perfect situation for property tests (fuzz tests in elm-test lingo.) The test system will keep us honest by giving us random values to test with. You can assert that encoders and decoders mirror each other, and add a bit more safety to your app.

Read on

How do I get JSON out of a port?

Working with ports can be awkward. You’re really limited as to what values you can send through, so how do you get objects? Easy: write a JSON Decoder!

Read on

Introducing elm-benchmark

After the sets series finished, I got really curious… How fast were these sets, exactly? I had to shave a lot of yaks to answer that question, but to sum up: Elm now has a benchmarking library! Let’s take a look at how to use it!

Read on

State of Elm 2017

The State of Elm 2017 Survey is now live, please go take it. It will run through Friday, February 24, and the results will be available sometime after that.

Here are the results from last year, or as a slide deck.

Read on

Create Custom JSON Decoders in Elm 0.18

You’ve modeled your data exactly how it should be, and everything’s working fine. Now it’s time to finish your JSON Decoder, but certain fields are strings where in your Elm code they’re complex data types! This happens most often with dates, but tagged unions have this problem too.

In 0.17 we had customDecoder, which could turn any Result String a into a Decoder a, but it went away in 0.18. So… what do we do?

Read on