Skip to content

Instantly share code, notes, and snippets.

@SoshiHomma
Last active August 26, 2020 01:55
Show Gist options
  • Save SoshiHomma/2b75dced243a95e8831ee4e01a29cc0c to your computer and use it in GitHub Desktop.
Save SoshiHomma/2b75dced243a95e8831ee4e01a29cc0c to your computer and use it in GitHub Desktop.
Elm to see how type alias works
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