[darcs-users] darcs patch: code clarification (and 1 more)

Eric Kow kowey at darcs.net
Mon Oct 27 11:53:44 UTC 2008


Hi!

More Haskell comments.  Again, it may be useful for somebody else to
look into the actual logic behind the code...

resolve issue1117: warn if file does not exist in whatsnew
----------------------------------------------------------
> -    when (areFileArgs files) $
> -         putStrLn $ "What's new in "++unwords (map show files)++":\n"
> +    when (areFileArgs files)
> +      (do warn_if_bogus  (slurp_recorded_and_unrecorded repository) files
> +          putStrLn $ "What's new in "++unwords (map show files)++":\n")

You can get rid of the parens if you use the ($) operator

    when (areFileArgs files) $ 
       do warn_if_bogus  (slurp_recorded_and_unrecorded repository) files
          putStrLn $ "What's new in "++unwords (map show files)++":\n"

> +warn_if_bogus :: IO (Slurpy,Slurpy) -> [SubPath] -> IO()

Maybe instead of taking IO (Slurpy, Slurpy), you could take
(Slurpy, Slurpy) instead?

> +                        when (not $ or [(slurp_has fp rec),(slurp_has fp pend)])

And maybe this would be simpler as

  when (not (slurp_has fp rec || slurp_has fp pend)) $
    putStrLn $ "WARNING: File '"++file++"' not in repository!"

> +                else do putStrLn $ "WARNING: File '"++file++"' does not exist!"

If you want, you can get rid of the 'do' statement here (do is useful
when you have more than one IO action to run).


> +       warn_if_bogus slurps fs
> +    where fp =  toFilePath f
> +          file = encode_white fp

-- 
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: 189 bytes
Desc: Digital signature
Url : http://lists.osuosl.org/pipermail/darcs-users/attachments/20081027/2b1b8660/attachment.pgp 


More information about the darcs-users mailing list