Skip to content

Instantly share code, notes, and snippets.

@rhizoome
Created August 21, 2018 12:25
Show Gist options
  • Save rhizoome/3d7f76b265781b29965463bcb8b0ca96 to your computer and use it in GitHub Desktop.
Save rhizoome/3d7f76b265781b29965463bcb8b0ca96 to your computer and use it in GitHub Desktop.
Kinda Polymorphism
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