Suggestion for Standard Prelude.
To replace such standard prelude functions as min,minimum,sort etc.
with their "function-argument" variants.
For example:
data Compare = LT | GT | EQ
sort :: (a -> a -> Compare) -> [a] -> [a]
-- cp xs
cp x y -> LT if x is less than y,
GT greater,
EQ otherwise (suppose we have not Eq !).
Probably, some other functions need similar generalization.
--------------------------------------------------------------------
Argumentation.
1.
Prelude already enjoys such a functions as break p xs, filter p xs
etc.
Why should we leave this style ? It may lead to complications only
if we introduce too many of such p -s.
2.
"function-argument" variants look more flexy and general than the
formats like
(Ord a) => [a] -> [a]
- because if we have Ord a, then we may always call
sort cp xs where cp x y | x<y = LT
| x>y = GT
| otherwise = EQ
( or simply, sort compare xs
- for Haskell-1.3. - if I recall the right name `compare'
)
and obtain what we had in the old version.
The inverse inclusion does not hold:
we cannot supply the same type a with many Ord instances,
whereas we may call sort with many different cp -s on the
same xs :: [a].
Am I missing something ?
------------------------------------------------------------------
Further, what I fear the most is that the suggestion would be
accepted, and these new versions join the old ones !
For really, the prelude contains to many functions.
Serge D.Mechveliani
[EMAIL PROTECTED]