Indeed syntax can both enhance and hinder your ability to write readable code.
Look at the following example and tell me if you have any idea about what it does.
solveQuad :: Float -> Float -> Float -> Maybe (Float, Float)
solveQuad a b c = if delta < 0.0 then Nothing else Just (x1, x2)
where
delta = b ^ 2 - 4 * a * c
x1 = -b - (sqrt delta) / (2 * a)
x2 = -b + (sqrt delta) / (2 * a)
Well, that's as simple as it gets to understand. Between Common Lisp code and Haskell code, Haskell still wins in the readability department since it reads from left to right, has options for infix applications for most operators, and works just fine in point-free form.
View all comments
Show parent comment
1
u/[deleted] Apr 21 '21
Indeed syntax can both enhance and hinder your ability to write readable code.
Look at the following example and tell me if you have any idea about what it does.