showell / elm-data-util / CodeSample

This module gives example code snippets using elm-syntax-dsl. It also provides a little convenience wrapper for pretty-printing.

formatCode : Elm.CodeGen.Expression -> String

use Elm.Pretty to print out code in nicely formatted style

Examples

In the examples I try to really break things down, by defining little snippets from the bottom up and combining them into the final code. You may prefer to inline things a bit more.

factorial : String

factorial (recursive style)

factorial2 : String

factorial using foldl

ranks : String

convert items to simple rankings like [ 4, 1, 2, 3 ] based on their order