AnonymousSums data con syntax
mail at joachim-breitner.de
Mon Sep 7 20:21:14 UTC 2015
Am Montag, den 07.09.2015, 19:25 +0000 schrieb Simon Peyton Jones:
> > Are we okay with stealing some operator sections for this? E.G. (x
> > > > ). I think the boxed sums larger than 2 choices are all technically overlapping with sections.
> I hadn't thought of that. I suppose that in distfix notation we
> could require spaces
> (x | |)
> since vertical bar by itself isn't an operator. But then (_||) x
> might feel more compact.
> Also a section (x ||) isn't valid in a pattern, so we would not need
> to require spaces there.
> But my gut feel is: yes, with AnonymousSums we should just steal the
> syntax. It won't hurt existing code (since it won't use
> AnonymousSums), and if you *are* using AnonymousSums then the distfix
> notation is probably more valuable than the sections for an operator
> you probably aren't using.
I wonder if this syntax for constructors is really that great. Yes, you
there is similarly with the type constructor (which is nice), but for
the data constructor, do we really want an unary encoding and have our
users count bars?
I believe the user (and also us, having to read core) would be better
served by some syntax that involves plain numbers.
Given that of is already a keyword, how about something involving "3
of 4"? For example
(Put# True in 3 of 5) :: (# a | b | Bool | d | e #)
case sum of
(Put# x in 1 of 3) -> ...
(Put# x in 2 of 3) -> ...
(Put# x in 3 of 3) -> ...
(If "as" were a keyword, (Put# x as 2 of 3) would sound even better.)
I don’t find this particular choice very great, but something with
numbers rather than ASCII art seems to make more sense here. Is there
something even better?
Joachim “nomeata” Breitner
mail at joachim-breitner.de • http://www.joachim-breitner.de/
Jabber: nomeata at joachim-breitner.de • GPG-Key: 0xF0FBF51F
Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: This is a digitally signed message part
More information about the ghc-devs