This post originated from an RSS feed registered with Java Buzz
by Elliotte Rusty Harold.
Original Post: Data Constructors and Readability
Feed Title: Mokka mit Schlag
Feed URL: http://www.elharo.com/blog/feed/atom/?
Feed Description: Ranting and Raving
I think I’ve put my finger one one reason I’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’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 Char constructor above. It also doesn’t help that they have the same naming convention (mixed camel case, initial uppercase letter).
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’s logically superfluous.
I suspect a language that retained Haskell’s semantics, but completely replaced the syntax with something more usable, legible, and familiar would have a much greater chance of success.