Posted by Brian Hicks on Wed, 07/18/2018 - 22:11

This year at Elm Europe I gave a talk called “Let’s Make Nice Packages!”

It’s about research.

No, wait, come back!

Continue Reading

Posted by Alex Korban on Tue, 07/10/2018 - 03:00

Json.Decode.Pipeline is a popular package for building JSON decoders. It allows you to build decoders using the forward function application operator (|>) to chain field decoders in a convenient, DSL-like way. For example, we could have a decoder like this:

type alias Node =
{ nodeType : String
, relationName : String
, plans : Plans
, schema : String
, startupCost : Float
, totalCost : Float
}

decodeNode : Decode.Decoder Node
decodeNode =
decode Node
...

Posted by Alex Korban on Tue, 07/10/2018 - 03:00

I’m working on an intermediate level Elm book called Practical Elm for a Busy Developer. I wanted to post a quick note about it for people who are not on my mailing list, since I've just added a huge new section and the book is 70-80% complete now.

I chose not to include the basics (Elm syntax, the Elm architecture etc.) in the book because I think they are adequately covered by other sources. Instead, it will guide you through the practical tasks of creating applications with Elm: building UI...

Posted by Alex Korban on Fri, 06/22/2018 - 03:00

Suppose you have some JSON that describes map markers:

{
"name": "Rixos The Palm Dubai",
"lat": 25.1212,
"lon": 55.1535
}

Using Json.Decode, the decoder for this JSON looks like this:

decodeMarker : Json.Decode.Decoder Marker
decodeMarker =
Json.Decode.map3 Marker
(field "name" Json.Decode.string)
(field "lat" Json.Decode.float)
(field "lon" Json.Decode.float)

If your JSON acquires another field (say, marker color), you need to add one more field decoder ((...

Posted by Alex Korban on Thu, 06/14/2018 - 03:00

This post is adapted from my book, [Practical Elm for Busy Developers.]

As your Elm code base grows, you will want to start taking advantage of modules to split the code into manageable smaller parts.

In Elm, files and modules have a one-to-one correspondence. If you want to break out a piece of code into a separate file, you have to organise it as a module in that file.

The general approach I would suggest is to start your project with a single file (Main.elm), and keep adding to it until y...

Posted by Gizra on Tue, 05/22/2018 - 08:00

This is going to be a simple exercise to create a decoupled site using Drupal 8 as the backend and an Elm app in the frontend. I pursue two goals with this:

  • Evaluate how easy it will be to use Drupal 8 to create a restful backend.
  • Show a little bit how to set up a simple project with Elm.

We will implement a very simple functionality. On the backend, just a feed of blog posts with no authentication. On the frontend, we will have a list of blog posts and a page to visualize each post.

Our first step will be the backend.

Continue reading…

Posted by Alex Korban on Mon, 05/07/2018 - 03:00

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 ...

Posted by Alex Korban on Thu, 05/03/2018 - 03:00

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 ...

Posted by Alex Korban on Fri, 04/13/2018 - 03:00

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):...

Posted by Alex Korban on Fri, 04/13/2018 - 03:00

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):...

Posted by Alex Korban on Thu, 03/29/2018 - 03:00

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 ...

Posted by Alex Korban on Thu, 03/29/2018 - 03:00

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 ...

Posted by Alex Korban on Fri, 03/23/2018 - 03:00

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 ...

Posted by Alex Korban on Fri, 03/23/2018 - 03:00

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 ...

Posted by Alex Korban on Fri, 03/16/2018 - 02:00

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...