4 ms·
FTP (The Foldable/Traversable proposal in prelude) is a change done to the core library of GHC 7.10. It brings the Foldable and Traversable typeclass to Prelude
by psibi 11y ago
FTP (The Foldable/Traversable proposal in prelude) is a change done to the core library of GHC 7.10. It brings the Foldable and Traversable typeclass to Prelude and makes the existing function of Prelude more polymorphic. Like the type signature of the function "and" changes from [Bool] -> Bool to Foldable t => t Bool -> Bool. People in the Haskell community have divided opinions about this. You can see more details here[0].
[0] https://wiki.haskell.org/Foldable_Traversable_In_Prelude https://wiki.haskell.org/Foldable_Traversable_In_Prelude
- dagw 11y agoI understand what is changing, but not the controversy. As a very casual Haskell user it all seems reasonable enough. What are the strong arguments against? What happened in 7.9-7.10 that made Haskell 'worse' in this persons opinion.
- thoughtpolice 11y agoTwo very clear problems are that it introduces more complexity up front for beginners (because now to understand `length` you need to understand the concept of type classes) and the change had the possibility to break some extant code, due to it changing some type inference properties. In practice, I think #2 was a fairly uncommon case, and the fixes were trivial and backwards compatible, so the cost was deemed pretty acceptable. #1 is a point of debate, because 'beginner' needs context (perhaps experienced programmers that are Haskell beginners would get over it quickly, but non-programmers would be substantially more confused, etc). Unfortunately I don't think we have a lot of truly empirical evidence on #1.
- HelloNurse 11y agoMy empirical evidence is against #1: up-front productive learning beats permanent uncertainty. - I can fold a list, but what about other types? Which of the similarly or identically named functions dispersed among a bewildering number of library modules is the right one? Are they any different? - I can fold a Foldable? What is it? Let's find a tutorial about Foldable. Ooh, nice! That takes care of folding anything that can be folded! If I'm not folding a list I only need to find where the relevant Foldable instance is (very easy) or to write one myself (reasonably easy).
- dmit 11y agoOne 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 https://ghc.haskell.org/trac/ghc/wiki/Prelude710/List
- spion 11y agoYes 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).
- grp 11y agoYes, 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!
- BlackMonday 11y agoInteresting, 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?
- dmit 11y agoFor 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.
- tinco 11y agoA few years ago when I was still learning Haskell and typeclasses I was a bit surprised to learn that Haskell had this fancy typeclass feature but prelude hardly made use of it. I had been using Haskell for over a year already and didn't understand one of its best features because it wasn't exposed to me. A bit disgruntled I asked in the IRC channel about this and they explained to me that this was actually intentional. It was at that time thought that by keeping prelude simple (pure FP 101 style) it was more accessible to new programmers. Apparently that mindset was reconsidered recently. So the big downside is that now if you teach Haskell and want to use Prelude, you'll be forced to almost immediately teach typeclasses. In my opinion that's not a bad thing at all. Typeclasses put Haskell (and FP in general) right in league with big feature languages like C# and Java. All big features of Haskell are implemented using typeclasses (such as the reputable IO monad). Not teaching that as a fundamental feature right at the beginning only makes the next hurdle of the more category theory heavy advanced features of Haskell that much higher.
- dmit 11y agoThe other side of the coin is that the majority of newcomers will simply abandon the language if they can't figure out how to use the basic prelude functions within 30 minutes. Every hurdle (installing GHC, figuring out cabal vs stack, trying to decipher the signature of `maximum`) turns people away, potentially forever.
- avmich 11y agoInteresting, I saw the opposite effect. If a language is "just another XYZ" and can be learned quickly, people will play with it, then may be shelf it - as it usually doesn't offer new power. However, if it's "tricky", some people will become genuinely interested - and will put efforts to see if it adds abilities to their toolset.