[Haskell-cafe] Language complexity & beginners

Michael Orlitzky michael at orlitzky.com
Tue Feb 9 13:26:13 UTC 2016

On 02/09/2016 06:27 AM, Kosyrev Serge wrote:
> Case in point (only slightly contrived) -- which one is easier to
> visually parse to you:
>   foo (thInt $ fromIntegral $ c2hsValueInt cexp) (thInt $ fromIntegral $ c2hsValueInt cexp)
>   foo (thInt (fromIntegral (c2hsValueInt cexp))) (thInt (fromIntegral (c2hsValueInt cexp)))
> Me, I get a blood pressure spike roughy here ---^

let th_exp = (thInt . fromIntegral . c2hsValueInt) cexp
foo th_exp th_exp

The parentheses are a warning sign, and using "$" above only lets you
make it look cleaner without fixing the problem. It has hidden the fact
that you're computing f(g(h(x))) twice, and there's a better way to do that.

More information about the Haskell-Cafe mailing list