Proposal (Trac ticket #3671): Add takeRec, genericTakeRec and spanRec to Data.List

Yitzchak Gale gale at
Wed Nov 18 17:42:17 EST 2009

Philip K.F. Hölzenspies wrote:
>> After defining these for the umpeenth time, I would like to add the
>> functions takeRec, genericTakeRec and spanRec to Data.List, as per

Ian Lynagh wrote:
> I have also defined your "takeRec" a number of times in the past, but I
> have called it something like "splitAts".

I've been using it for years, under the name "groupsOf" - which is also
consistent with Data.List naming conventions, and a bit less confusing
than "splitAts" in my opinion. Another reason I don't use splitAts is that
I don't use splitAt in its definition anymore; I've come to prefer

groupsOf n = takeWhile (not . null) . map (take n) . iterate (drop n)

In fact, I use this function so much that I put it in my dot-ghci so
it will always
be at my fingertips. I am very much in favor of adding it to Data.List.


More information about the Libraries mailing list