Created
August 21, 2018 12:25
-
-
Save rhizoome/3d7f76b265781b29965463bcb8b0ca96 to your computer and use it in GitHub Desktop.
Kinda Polymorphism
This file contains hidden or 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 (main) | |
import Html exposing (Html) | |
type alias Positioned a = | |
{ a | x : Float, y : Float } | |
type alias Named a = | |
{ a | name : String } | |
type alias Moving a = | |
{ a | velocity : Float, angle : Float } | |
type alias Super = Named (Moving (Positioned {})) | |
dude: Super | |
dude = | |
{ x = 0 | |
, y = 0 | |
, name = "Clark Kent" | |
, velocity = 42 | |
, angle = degrees 30 | |
} | |
getName : Named a -> String | |
getName {name} = | |
name | |
main : Html msg | |
main = | |
Html.text (getName dude) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment