Skip to content

Instantly share code, notes, and snippets.

@fredcy
Last active January 25, 2016 19:34
Show Gist options
  • Save fredcy/c02d5ecb50832f1ae6a2 to your computer and use it in GitHub Desktop.
Save fredcy/c02d5ecb50832f1ae6a2 to your computer and use it in GitHub Desktop.
Elm record usage example
import Graphics.Element exposing (show)
type Foo = A { x : Int, y : String }
| B { x : Int, m : Float }
f : Foo -> Foo
f foo =
let
incr v = { v | x = v.x + 1 }
in
case foo of
A v -> A (incr v)
B v -> B (incr v)
main =
A { x = 3, y = "blah" } |> f |> show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment