Going back to the original question, why couldn't you use a list of records
instead of a union type? Every time I dealt with states, I ended up needing
more than just the name and ended up putting it in a database, which more
naturally maps to a record.
type alias UsState =
{ name : String
, code : String
, licenseFormat : String
}
With the usage you describe so far, records seem a better fit. Unions are
more valuable when you need to structure to code against rather than data.
You could still pick out specific states for special rules using something
like:
states
|> List.filter (\state -> state.code == "AL")
|> List.head
HTH
--
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.