Re: Drastic Prelude changes imminent

Ah yes. That is, strictly speaking not code.
I suppose it could count as breakage also, but I think it is far less
likely to cause confusion though as they're clearly asking about
implementation and getting an answer that its changed.
On Tue, Feb 3, 2015 at 2:41 PM, Erik Hesselink
On Tue, Feb 3, 2015 at 8:32 PM, davean
wrote: On Tue, Feb 3, 2015 at 2:20 PM, Erik Hesselink
wrote: 2. Breakage of existing tutorials/documentation
I was just wondering which of these you were alluding to. Turns out it's all of them :) I'm surprised you mention breakage of code, since in my experience most of the breakage in GHC 7.10 I've seen in my own packages and the Stackage builds is due to other factors: the Applicative/Monad changes, time 1.5, etc. It would be interesting (but time consuming) to gather some statistics on this. The breakage of tutorials is unfortunate, yes.
So how bad is the breakage of tutorial code really? Looking around almost all of it has a full top level type which makes it still work. I've only looked for a few minutes but my first impression is that not much breaks with this. Is this just a theory or have people actually determined that tutorial code breaks?
(Actually, I've found plenty of broken tutorial code, but it wasn't due to anything in prelude. Our standard library churn seems much worse on tutorials I've looked at then this seems to be.)
I think the 'breakage' is mostly used as mentioning things that work on lists, while they now work on Foldable/Traversables. For example, LYAH mentions "length takes a list and returns its length, obviously.", which isn't true anymore in the strictest sense, it takes any Foldable. However, you could argue that this text is just specialization, and that it's still true. There seem to be no things that are generalized in the section about types, and soon after type classes are already introduced. Real World Haskell is slightly more "broken", for example, it lists:
ghci> :type null null :: [a] -> Bool
Which isn't true anymore, it would now give "Foldable t => t a -> Bool".
Regards,
Erik
P.S. You didn't send your message to haskell-cafe. Feel free to forward it including this reply if you want.

On 2015-02-03 at 20:51:04 +0100, davean wrote: [...]
I think the 'breakage' is mostly used as mentioning things that work on lists, while they now work on Foldable/Traversables. For example, LYAH mentions "length takes a list and returns its length, obviously.", which isn't true anymore in the strictest sense, it takes any Foldable. However, you could argue that this text is just specialization, and that it's still true. There seem to be no things that are generalized in the section about types, and soon after type classes are already introduced. Real World Haskell is slightly more "broken", for example, it lists:
ghci> :type null null :: [a] -> Bool
Which isn't true anymore, it would now give "Foldable t => t a -> Bool".
That's not worse than what RWH already does for the 'Monad m =>' generalisations: | Tip: These functions actually work for more than just I/O; they work for | any Monad. For now, wherever you see "M", just think "IO". Also, | functions that end with an underscore typically discard their | result. 2 comments So such tutorials already do lie a little bit for the sake of easing beginners in and then eventually rip the bandaids off. We shouldn't assume beginners are that dumb they can't make that leap... On a related matter, beginner books like the very popular LYAH or also the more recent "Beginning Haskell" do introduce and actually recommend the Foldable/Traversable abstraction with words like | Because there are so many data structures that work nicely with folds, | the Foldable type class was introduced. Much like Functor is for | things that can be mapped over, Foldable is for things that can be | folded up! or | As you saw in the previous chapter, lots of different algorithms can be | expressed using folds. The module Data.Foldable includes most of them, | like maximum or elem. One easy way to make your functions more general | is hiding the functions with those names from the Prelude and importing | the ones using Foldable. ...and go on to promote their use with the words | But now that you know about them, you should aim for the largest | degree of abstraction that you can achieve. So, generalisations such as Foldable/Traversable are in fact taught (and recommended) to beginners via books, and I'd even go as far as saying that those in teaching positions who withold that knowledge from their students are doing them a disservice. So, Foldable/Traversable is not going away. Its use is rather going to increase the more newcomers read those books, so we should rather embrace it to avoid sending mixed signals to newcomers... Cheers, hvr
participants (2)
-
davean
-
Herbert Valerio Riedel