Short question:

What is the best way to create relationships between my types so it is easy 
to access data present in both types?

Long question:

Suppose I have the following types:

type alias Person =
  { name : String
  , address : String
  , personType : PersonType 
  }

type alias Employee =
  { department : String }

type alias Customer =
  { itemsPurchased : Int }

type PersonType = EmployeeType Employee | CustomerType Customer

Then I think it's not straight forward to write a function that retrieves 
me the department and name for an employee:

nameAndDepartment : Person -> (String, String)

It seems to me this function would be a Maybe (String, String) and return 
Nothing if the Person is not an Employee. But in that case, I am relying on 
the runtime to type check things for me, which tells me there is probably a 
better way to structure this.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to