[elm-discuss] Re: How do I organize "inheritance" between my data types?

2016-07-18 Thread Evan
Both Max and Aaron PS suggested using extensible records for this scenario, but I don't think that is the right way to go. It is particularly tempting for folks who want Elm to just work like an OO language, but it isn't like that. I think Tessa put it very nicely in her post

[elm-discuss] Re: How do I organize "inheritance" between my data types?

2016-07-18 Thread Leroy Campbell
It may help to watch this talk on modeling from a functional programming perspective (features F#, but applicable to Elm since they both are ML-based): https://vimeo.com/162036084 On Sunday, July 17, 2016 at 7:06:32 PM UTC-4, Leonardo Sá wrote: > > Short question: > > What is the best way to cr

[elm-discuss] Re: How do I organize "inheritance" between my data types?

2016-07-17 Thread Max Goldstein
Aaron's solution is a good one, but since customers and employees are both people, you may want: type alias Person a = { a | name : String , address : String } type alias Employee = Person { department : String } type alias Customer = Person { itemsPurchased : Int } -- You

[elm-discuss] Re: How do I organize "inheritance" between my data types?

2016-07-17 Thread Aaron PS
Hello, you might be looking for "extensible records", check this out http://elm-lang.org/docs/records import Html exposing (Html, div, ul, li, text) type alias Person a = { a | name : String , address : String } type alias Employee a = { a | department : String } type alias Cus