Last active
August 26, 2020 01:55
-
-
Save SoshiHomma/2b75dced243a95e8831ee4e01a29cc0c to your computer and use it in GitHub Desktop.
Elm to see how type alias works
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
import Html exposing (..) | |
type alias UserInfo = | |
{ name : String, age : Int } | |
type alias Coach = | |
{ name : String, age : Int, sports : String } | |
getUserAge : UserInfo -> Int | |
getUserAge userInfo = | |
userInfo.age | |
sam = UserInfo "Sam" 24 | |
charlie = Coach "Charlie" 52 "Basketball" | |
main = | |
text (getUserAge charlie |> String.fromInt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment