<div dir="ltr"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Aug 8, 2015 at 4:39 PM, Alexey Muranov <span dir="ltr"><<a href="mailto:alexey.muranov@gmail.com" target="_blank">alexey.muranov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
i would like to suggest an idea for modifying the basic data/newtype syntax in Haskell: replace the equality sign `=` with `::=`.<br>
<br>
When i started learning Haskell, the most confusing part of the syntax for me was the equality sign in `data` definition.  I could not even guess what the `data` definition meant without reading a chapter or two about types in Haskell, and i think it was partially due to the equality sign.  I still find this notation inconsistent with other uses of the equality sign in Haskell and in general.<br>
<br>
For example, in<br>
<br>
    type Name = String<br>
    data Date = Date Int Int Int<br>
    data Anniversary = Birthday Name Date | Wedding Name Name Date<br>
<br>
the second line is particularly disorienting IMO because on two sides of the equality, `Date` denotes different things.<br>
<br>
As far as i understand, in all contexts except those of `data` and `newtype` definitions, the equality sign in Haskell denotes the actual equality for all purposes: if a line<br>
<br>
    foo x y = bar y x<br>
<br>
is present in a program, `foo a b` and `bar b a` can be used more or less interchangeably elsewhere in the program.  Similarly, if the line<br>
<br>
    type Name = String<br>
<br>
is present, `Name` can be used as `String`.  Clearly, the equality in<br>
<br>
    data Date = Date Int Int Int<br>
<br>
does not have such property.<br>
<br>
I think that if `::=` was used instead of `=` in `data` and `newtype` definitions, this would suggest  to a newcomer that the syntax of the two sides might be different, and would helpfully remind of the Backus–Naur Form for syntax rules.  I think that a newcomer to Haskell, like myself, would have had a better chance of guessing the meaning of<br>
<br>
    type Name = String<br>
    data Date ::= Date Int Int Int<br>
    data Anniversary ::= Birthday Name Date | Wedding Name Name Date<br>
<br>
IMO this would make the program easier to read in general and the difference between `type` and `newtype` more clear.  Maybe the can even make the use of keywords redundant, by allowing to write simply<br>
<br>
    Name = String<br>
    Date ::= Date Int Int Int<br>
    Anniversary ::= Birthday Name Date | Wedding Name Name Date<br>
<br>
What do you think?<br></blockquote></div><br><br></div><div class="gmail_extra">I taught functional programming (with gofer) some decades ago.<br></div><div class="gmail_extra">I found some of your points (and some more) slowed down students sufficiently that making small changes in gofer was worth the effort<br></div><div class="gmail_extra">My changes are described here <a href="http://www.the-magus.in/Publications/notation.pdf" target="_blank">http://www.the-magus.in/Publications/notation.pdf</a><br></div><div class="gmail_extra">The appendix at end summarises the changes.<br><div class="gmail_extra"><br></div><div class="gmail_extra">Note
 that the ctype keyword (concrete-type) as replacement for 'data' 
predates GADT by about a decade though I came to it from a pedagogy not a
 generality angle<br clear="all"></div><div class="gmail_extra"><br></div><br>If someone wants to try it, this modified gofer is at <a href="https://github.com/rusimody/gofer" target="_blank">https://github.com/rusimody/gofer</a><br></div><div class="gmail_extra"></div><br></div>Note: I am really not entering the debate that Haskell should be changed<br><div><br><div class="gmail_extra">Regards<br></div><div class="gmail_extra">Rusi<br></div><div class="gmail_extra"><br>-- <br><div><div dir="ltr"><div><div dir="ltr"><div><a href="http://www.the-magus.in" target="_blank">http://www.the-magus.in</a><br><a href="http://blog.languager.org" target="_blank">http://blog.languager.org</a><br><br></div></div></div></div></div>
</div></div></div>