Tomas Andersson
A mathematician, programmer, and general ubergeek currently looking for work.
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals, Chapter 2 of 13
Oct 08, 2009 at 3:22 PMWell, I did say it was a nonsensical example.
And you are of course correct that the pointfree version is better and is what I would write as well in actual code, but I was just trying to show the use of the $ operator specifically in that example.
C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals, Chapter 2 of 13
Oct 08, 2009 at 1:21 PMRegarding the $-operator:
I've never heard any Haskell programmer say that the $-operator is used to save letters, because as Erik says, you only save at most one. The purpose is to avoid having expressions that end with a huge mountain of parenthesises. Compare the two following, slightly nonsensical, snippets.
Notice how the second version reads alot more similar to when you write pipes in Unix or when you chain together method calls in an OO language.
Did you even notice that there was one end parenthesis to much in the first version?
So the $ is not about saving characters, it's about clarity. But I agree that there is a general tendency among Haskellers to be overly clever (read: obscure) to write shorter code.