[Haskell-cafe] where to put handy functions?

Stefan O'Rear stefanor at cox.net
Thu Aug 9 17:37:04 EDT 2007


On Thu, Aug 09, 2007 at 02:29:50PM -0700, Chad Scherrer wrote:
> 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
>     where
>     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
> imports.
> 
> 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"?

http://www.haskell.org/haskellwiki/Library_submissions

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070809/0ba62694/attachment.bin


More information about the Haskell-Cafe mailing list