Skip to content

Instantly share code, notes, and snippets.

@hipertracker
hipertracker / Language.elm
Created November 19, 2016 17:08
Elm decoders for nested JSON structures
module Models.Language exposing (..)
import Json.Decode exposing (int, string, decodeString, Decoder)
import Json.Decode.Pipeline exposing (decode, required)
type alias Language =
{ id : Int
, name : String
, label : String
@yang-wei
yang-wei / destructuring.md
Last active December 2, 2024 06:40
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))