Hacker News new | ask | show | jobs
by Throwaway23459 1285 days ago
Has it got currying? Partially applied functions passed around in folds and traverses are horribly difficult to read for beginners. Example: an Advent of Code solution posted in r/haskell for Day 10 this year, tell me how long it takes you to understand the function cycleStrengths.

   signalStrength cycle x = cycle \* x

   cycleGaps = [19, 40, 40, 40, 40, 40]

   cycleStrengths = foldr a (const []) cycleGaps . (\x -> (1, x))
     where
       a n r (i, xs) = signalStrength m y : r (m, ys)
         where
           m = i + n
           ys@(y : _) = drop n xs
From: https://www.reddit.com/r/haskell/comments/zhjg8m/advent_of_c...

Personally I love this headscratching stuff, but I would not ever dream of subjecting it upon a beginner programmer.

1 comments

That kind of code is sometimes easier to write than read… you build it up incrementally. On the other hand it’s easy to refactor this to make it readable. Is Haskell supposed to be an easy language for beginners? Is Verse? Not every language should be.
> [Paraphrasing] Is Verse supposed to be an easy language for beginners ?

Yes! Well that was the point of my comment. Maybe you have a different interpretation of 'Learnable as a first language' from the article, which is fine, not interested in arguing about that.

I guess that part of my comment could have benefited from reading the article, which I have done now. Oops.