[darcs-users] darcs patch: Avoid patently unnecessary consing.

Eric Kow kowey at darcs.net
Sun May 17 09:32:39 UTC 2009


On Sun, May 17, 2009 at 17:35:55 +1000, Trent W.Buck wrote:
> I'm pretty sure I've created such a patch before, so I guess it was
> rejected.  I don't remember WHY, so let's do it again! :-)

Huh.
 
> Sun May 17 16:54:38 EST 2009  Trent W. Buck <trentbuck at gmail.com>
>   * Avoid patently unnecessary consing.
>   Thanks hlint!

All look good to me, applied, thanks!
I've removed context below for the interested...
It's just replacing sequence_ . map with mapM_,
sequence . zipWith f xs with zipWithM_ f xs and
mapM with mapM_ when we don't consume the result.

Avoid patently unnecessary consing.
-----------------------------------
> -  sequence_ $ map (annotate_markedup opts pinfo old_pis) mk
> +  mapM_ (annotate_markedup opts pinfo old_pis) mk

> -      sequence_ $ zipWith (move_file_or_dir work) moved movetargets
> +      zipWithM_ (move_file_or_dir work) moved movetargets

> -  mapM (show_motd opts) repodirs
> +  mapM_ (show_motd opts) repodirs

> -                               (sequence_ $ map rm_recursive conts)
> +                               mapM_ rm_recursive conts

> -    mapM (delete_line (fn2fp f) line) old
> -    mapM (insert_line (fn2fp f) line) (reverse new)
> +    mapM_ (delete_line (fn2fp f) line) old
> +    mapM_ (insert_line (fn2fp f) line) (reverse new)

> -    mapM (delete_line (fn2fp f) 1) (linesPS o)
> +    mapM_ (delete_line (fn2fp f) 1) (linesPS o)

> -    mapM (insert_line (fn2fp f) 1) (reverse $ linesPS n)
> +    mapM_ (insert_line (fn2fp f) 1) (reverse $ linesPS n)

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090517/a378befa/attachment.pgp>


More information about the darcs-users mailing list