{"id":1002094,"date":"2009-02-05T11:23:18","date_gmt":"2009-02-05T16:23:18","guid":{"rendered":"http:\/\/www.elharo.com\/blog\/?p=1002094"},"modified":"2009-02-05T15:35:28","modified_gmt":"2009-02-05T20:35:28","slug":"data-constructors-and-readability","status":"publish","type":"post","link":"https:\/\/www.elharo.com\/blog\/software-development\/haskell\/2009\/02\/05\/data-constructors-and-readability\/","title":{"rendered":"Data Constructors and Readability"},"content":{"rendered":"<p>I think I&#8217;ve put my finger on one reason I&#8217;m finding Haskell hard to read. Consider this algebraic data type definition from <cite>Real World Haskell<\/cite>:<\/p>\n<pre>data Doc = Empty\r\n         | Char Char\r\n         | Text String\r\n         | Line\r\n         | Concat Doc Doc\r\n         | Union Doc Doc\r\n         deriving (Show, Eq)<\/pre>\n<p>There&#8217;s no distinction between the value constructor and the components of the type. This is especially critical when the constructor and the components have the same name as in the <code>Char<\/code> constructor above. It also doesn&#8217;t help that they have the same naming convention (mixed camel case, initial uppercase letter). <\/p>\n<p>A Java class with multiple factory methods or multiple constructors would be much more verbose, but much more readable. Humans need redundancy, even if it&#8217;s logically superfluous.<\/p>\n<p>I suspect a language that retained Haskell&#8217;s semantics, but completely replaced the syntax with something more usable, legible, and familiar would have a much greater chance of success. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I think I&#8217;ve put my finger on one reason I&#8217;m finding Haskell hard to read. Consider this algebraic data type definition from Real World Haskell: data Doc = Empty | Char Char | Text String | Line | Concat Doc Doc | Union Doc Doc deriving (Show, Eq) There&#8217;s no distinction between the value constructor [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74],"tags":[],"class_list":["post-1002094","post","type-post","status-publish","format-standard","hentry","category-haskell"],"_links":{"self":[{"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/posts\/1002094","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/comments?post=1002094"}],"version-history":[{"count":3,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/posts\/1002094\/revisions"}],"predecessor-version":[{"id":1002097,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/posts\/1002094\/revisions\/1002097"}],"wp:attachment":[{"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/media?parent=1002094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/categories?post=1002094"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/tags?post=1002094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}