back

by dmit·11y ago·view on hn ↗
One issue is making the learning curve even steeper. Compare the <=7.8 signature of a simple function (which itself is not obvious to beginners) to the 7.10 one:

  find :: (a -> Bool) -> [a] -> Maybe a
  find :: Foldable t => (a -> Bool) -> t a -> Maybe a
The obvious beginner question looking at this code is "what's `t a`?", and now you have to explain type classes to someone who just wanted to find an element in a list.

There's a list of arguments against FTP compiled on the Haskell wiki: https://ghc.haskell.org/trac/ghc/wiki/Prelude710/List

3 comments
Yes that seems like it would be much steeper for complete beginners. It might actually make things easier for people coming from other languages - you get to learn typeclasses by comparing foldable with similar familiar concepts from other languages (iterable / enumerable) without getting special syntax as part of the "understanding" package (do notation / overloaded literals).
Interesting, I have never used Haskell, only read tutorials and articles about it, but I don't get why the Foldable version should be harder for a beginner.

Instead of explaining that [a] is a List of a's, and then explaining what a list is, you explain that t is a container that is foldable which contains a's.

Does he really need to know the exact details of what a typeclass is?

For one, "fold" is a foreign concept to people who were introduced to programming using an average imperative language. I understand that it's easier to comprehend if you mentally translate `Foldable t => t a` to `Iterable<T>`, but even Iterable is a lossy analogy. I'm not sure any mainstream language has a type that is equivalent to Haskell's Foldable.

I'm guessing you have experience with languages that have generic types. The issue with the new Haskell prelude is that not only do you have to grok generic typing in order to write the most basic of Hello World introductory programs, you also have to be able to make sense of the Haddock docs. And that now requires knowledge of the type class syntax as well as basic understanding of generic programming. Whereas previously you could have softened the blow by teaching the special case of "[a] means a collection of a" first, and ramping up to more precise definitions later.

Overall, I'm supportive of the FTP initiative. But I can't shake the thought that the vast majority of people who voted for FTP have long passed the point where they can fully understand the downsides of the change for others.

Yes, it's easier to explain haskell with lists but having nice type signatures just hide reality and that's bad.

If someone want to compute lists, it could use a spreadsheet program. It's just better!