RFC: qualified vs unqualified names in defining instance methods

Iavor Diatchki iavor.diatchki at gmail.com
Sat Apr 26 16:20:35 EDT 2008


Hello,

On Fri, Apr 25, 2008 at 3:00 PM, Simon Marlow <marlowsd at gmail.com> wrote:
> ...
>  It would be slightly strange if record construction required the
> unqualified name, but record update required the qualified name, when the
> field name is only in scope qualified.  So that indicates that we should
> allow either form in record construction (and instance declaration), i.e.
> Claus's suggestion + DisambiguateRecordFields.

My preference would be to disallow qualified names in: (i) the method
names of instances, (ii) record construction (C { l = e }), (iii)
record patterns (C { l = p }).  I think that this is consistent, and
it easy easy to see what the labels refer to: in the case of
instances, the method belongs to the class in question (which can be
qualified), and in the case of records the label belongs to the
specified constructor (which can also be qualified).

As Simon points out, record updates still require qualified names but
I don't think that there is an inconsistency there because I think of
record updates as the application of a (oddly named) function, just
like record selection is the application of a (normally named)
function.  Therefore, it makes sense that we may have to use qualified
names to disambiguate which function we are referring to.

-Iavor


More information about the Haskell-prime mailing list