[Haskell-cafe] where to put handy functions?

Chad Scherrer chad.scherrer at gmail.com
Thu Aug 9 17:29:50 EDT 2007

Is there process for submitting functions for consideration for
inclusion into future versions of the standard libraries? For example,
I'd like to see this in Data.List:

extract :: [Int] -> [a] -> [a]
extract = f 0
    f _ _ [] = []
    f _ [] _ = []
    f k nss@(n:ns) (x:xs) = if n == k then x:f (k+1) ns xs
                            else f (k+1) nss xs

This behaves roughly as
extract ns xs == map (xs !!) ns

except that it's a lot more efficient, and it still works if ns or xs
(but not both) are infinite. Oh, and "ns" are required to be ordered
and non-negative.

I'm guessing there are a lot of similarly simple handy functions, and
I'm wondering if there's anything in place to avoid (1) reinventing
the wheel, and (2) name clashes. Someone else may have written
"extract" as well, meaning one of us wasted our time. And chances are,
if they did, it has a different name, leading to forced qualified

Finally, even if no one else is using it, it would be good to settle
on reasonable names for things more easily. Is there a better name for
this function? Is there a reason not to call it "extract"?


Chad Scherrer

"Time flies like an arrow; fruit flies like a banana" -- Groucho Marx

More information about the Haskell-Cafe mailing list