Created
August 5, 2017 02:03
-
-
Save ethagnawl/596f75697e12727af0755149329951b7 to your computer and use it in GitHub Desktop.
elm extensible records example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main exposing (..) | |
import Html exposing (Html, text) | |
type alias Named a = { a | name : String } | |
foo : Compound -> String | |
foo named = named.name ++ "!" | |
type alias Position r = { r | x:Float } | |
type alias Velocity r = { r | vx:Float } | |
type alias Person r = { r | name:String } | |
type alias Compound = Person (Position (Velocity {})) | |
main : Html a | |
main = | |
let compound = {x = 1.0, vx = 1.1, name = "pete"} | |
in | |
text ("hi, " ++ foo compound) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment