
Libraries-List, browsing through the sources of Data.List I discovered "select", which is only used for the implementation of partition and not exported. Can someone explain, why the irrefutable pattern "~" is used? Both components are used in both branches. select :: (a -> Bool) -> a -> ([a], [a]) -> ([a], [a]) select p x ~(ts,fs) | p x = (x:ts,fs) | otherwise = (ts, x:fs) Why is it not just in where-clause? Doesn't "INLINE partition" work then? Cheers Christian

On Thursday 26 February 2009 5:36:05 am Christian Maeder wrote:
Libraries-List,
browsing through the sources of Data.List I discovered "select", which is only used for the implementation of partition and not exported.
Can someone explain, why the irrefutable pattern "~" is used? Both components are used in both branches.
To see the difference, go into ghci, and define select without the irrefutable pattern. Then run the following: foldr (select even) ([],[]) [1..]

Dan Doel wrote:
On Thursday 26 February 2009 5:36:05 am Christian Maeder wrote:
Libraries-List,
browsing through the sources of Data.List I discovered "select", which is only used for the implementation of partition and not exported.
Can someone explain, why the irrefutable pattern "~" is used? Both components are used in both branches.
To see the difference, go into ghci, and define select without the irrefutable pattern. Then run the following:
foldr (select even) ([],[]) [1..]
Cool! Thanks, Christian
participants (2)
-
Christian Maeder
-
Dan Doel