On 8/23/06, <b class="gmail_sendername">Brian Hulley</b> &lt;<a href="mailto:brianh@metamilk.com">brianh@metamilk.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi -<br>Disregarding my last proposal which involved the use of {} in types, I am<br>wondering if anyone would agree with me that it would be a good idea to use<br>{} instead of () when writing out the context ie:<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;foo :: (Num a, Bar a) =&gt; a -&gt; a<br><br>would become:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;foo :: {Num a, Bar a} =&gt; a -&gt; a<br><br>and the same for every other situation in the language where a context<br>appears.<br><br>My reasons are twofold:
<br><br>1) The context is supposed to be understood (afaiu) as a *set* of<br>constraints not a *tuple* of constraints (ie what relevance does the<br>ordering implied by the tuple notation have here?), so the using of set<br>
braces seems mathematically more appropriate</blockquote><div><br>I just started programming in Haskell again recently and I cannot even think of a case where any kind of brackets should be necessary. In the report [1], it clearly shows that a context is always followed by &quot;=&gt;.&quot;&nbsp; Are the parantheses just used to reduce lookahead requirements for parsers? If so, perhaps the parentheses should be made optional to make them easier to read for people. Plus, then there would not be any tuple vs. set confusion.
<br><br>BTW, at least GHC allows duplicates in the context, like [&nbsp; foo :: (Num a, Num a) =&gt; a -&gt; a&nbsp; ], so I don't know if calling it a &quot;set&quot; is really appropriate either.<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2) It would allow an editor to give the correct fontification for an<br>incomplete type expression. At the moment, if you'd just typed:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;foo :: (Bar<br><br>the editor would have no way of knowing if &quot;Bar&quot; is a classcon or a tycon,
<br>whereas with:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;foo :: {Bar<br><br>the opening brace immediately informs the editor that the following text<br>should be parsed as a context and so it could fontify Bar appropriately.</blockquote><div><br>What about [&nbsp;&nbsp; foo :: Bar&nbsp; ] when typing [&nbsp;&nbsp; foo :: Bar a =&gt; a -&gt; a&nbsp;&nbsp; ]? It would be a mistake to require the grouping symbols even when there is only one element in the context. I think that the editor has to be know enough about the program to distinguish classes and type constructors without any grouping symbol requirement.
<br></div><br>- Brian<br><br></div>