About the middle of last month I posted a suggestion about extending the
notation for Haskell datatype definitions to allow the definition of
selector functions. As a reminder, one of the examples that I gave was:
data Date = Date (day::Int) (month::Int) (year::Int)
There were a couple of responses on the list and I had quite a few more by
personal email so I thought it might be worth posting a brief summary.
First of all, as a couple of people kindly mentioned in their replies, this
idea is not new and has been used a number of times in the past in other
languages (e.g. OPAL, FL, RAISE, ...). I should have been a little more
careful to mention that all I was suggesting was that the same thing might
be useful in Haskell.
Second, several of the people who replied are currently using Haskell for
real programming projects and commented that this extension would be very
useful in their work. However ...
Third, agreeing with my comments in the original posting, there were also
some suggestions that a proper system of records (in Standard ML terminology)
or named associations (in Ada speak) would be preferable, not only solving the
position independent selection problem, but also supporting position
independent construction. This certainly seems attractive, but is a long-term
option, requiring more substantial changes to the language.
Thanks to everybody who replied to my original message. I hope this summary
will be of interest.
All the best,
Mark