[GHC] #11671: Allow labels starting with uppercase with OverloadedLabels
GHC
ghc-devs at haskell.org
Fri Mar 4 10:50:40 UTC 2016
#11671: Allow labels starting with uppercase with OverloadedLabels
-------------------------------------+-------------------------------------
Reporter: inaki | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1-rc1
(Parser) |
Resolution: | Keywords: ORF
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by inaki):
Just to elaborate on my motivation for asking this: in bindings to C
libraries (say gtk), due to the requirement of uniqueness of identifiers,
one ends up with rather long identifiers for constants, which are
typically represented by different constructors for a certain sum type.
See for example:
https://hackage.haskell.org/package/gtk-0.14.2/docs/Graphics-UI-Gtk-
General-Enums.html#t:TreeViewColumnSizing
It would be much more convenient to be able to say
{{{#!hs
treeViewColumnSetSizing tvc #Fixed
}}}
rather than the current, much more verbose
{{{#!hs
treeViewColumnSetSizing tvc TreeViewColumnFixed
}}}
The former is just as typesafe, but much more pleasant to read and use, I
think, and here it is fairly natural to expect the overloaded label to
start with uppercase. It can just as easily be made to work with
lowercase, but I think that from the point of view of the user of the
library the version starting with uppercase is more natural.
(As a side remark: the above is still unnecessarily verbose, with further
use of OverloadedLabels we can shorten it to
{{{#!hs
set tvc [#sizing := #Fixed]
}}}
which is close to Python levels of convenience, while being perfectly type
safe. This already works well in the haskell-gi autogenerated bindings for
gtk, only that I need to replace `#Fixed` -> `#fixed` due to the parser
limitation.)
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11671#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list