Folks

The recent discussion has highlighted three things that I
propose to treat as 'Haskell 98 typos'.  Even if you have 
not been reading the dicussion, please read this, since
I have my H98 editor's hat on, and I propose some minor
changes to the published H98.  

Simon


Partition
~~~~~~~~~
First, partition is defined in the List library:

 partition p xs = foldr select ([],[]) xs
                 where
                   selet x (ts,fs) | p x = (x:ts,fs)
                                    | otherwise = (ts,x:fs)

Several people have pointed out that this is not equivalent
to the "standard" definition

  partition p xs = (filter p xs, filter (not . p) xs)

because the current H98 defn is strict in the spine of
the argument list.

I do not know how this change came about, but it seems entirely
wrong to me.  The "standard" (lazier) defn should be the one in the H98
report.  

PROPOSAL: use the filter/filter defn of partition 

Take and drop
~~~~~~~~~~~~~
Jan Kort points out that

a) (take n xs) and (drop n xs) are defined for n > length xs
   In that case they do something reasonable and useful
        (take gives back xs, drop gives the empy list)

b) They are both also defined if the list is empty, regardless of
   the value of n

c) But iff the list is non-empty, they fail for n < 0.


This seems bizarre.  I can see three alternatives:

(A) Make them defined for any n.  If n < 0, do something reasonable:
        take:   give empty list
        drop:   give whole list

(B) Make them defined for n > length xs, but fail for n < 0.

(C) Status quo


PROPOSAL: Use alternative (A)


splitAt
~~~~~~~
splitAt has the same inconsistency as take, drop.  
Indeed, splitAt would be better defined thus

        splitAt n xs = (take n xs, drop n xs)

PROPOSAL: use the take/drop defn of splitAt

Reply via email to