Proposal: adding 'tailDropWhile' to Data.List

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Wed Sep 28 11:55:49 CEST 2011


On 28 September 2011 19:44, Kazu Yamamoto <kazu at iij.ad.jp> wrote:
> I didn't propose to add 'chop'. I proposed to add 'tailDropWhile'.

I understood that you wanting to be able to define `chop' was the
motivation behind this proposal.

> For real use, you are right. But to teach list programming to
> beginners, I think this is necessary. For instance, I would explain
> how to process String without regular expressions.

I still argue that this is a bad idea.  To an extent, functional
programmers tend to focus too much on lists as the be-all and end-all
of data structures.  Whilst lists are great at what they do and
generally serve as a good "intermediary" data structure (e.g.
converting a Map k a to a Seq (k,a) ), we should not be abusing them
to do _everything_.

In my opinion, teaching students to do a large amount of "fiddling"
with the ends of lists is getting them used to bad habits.  If you
_really_ need to do a lot of stuff at the end of a list-like data
structure, use a Seq or something.

If you still want to use this to teach students (maybe because you're
building them up to "but in general you shouldn't do this") then
provide this function for their use elsewhere (either as something to
copy/paste, or an auxiliary library for your class).  But I don't
think it belongs in Data.List.

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com



More information about the Libraries mailing list