[darcs-users] darcs patch: Add comments in Darcs.Patch.Check (and 1 more)

Eric Kow kowey at darcs.net
Sat Mar 28 14:07:44 UTC 2009


On Sat, Mar 28, 2009 at 00:40:43 +0100, Reinier Lamers wrote:
> Sat Mar 28 00:15:07 CET 2009  Reinier Lamers <tux_rocker at reinier.de>
>   * Add comments in Darcs.Patch.Check
> 
> Sat Mar 28 00:16:02 CET 2009  Reinier Lamers <tux_rocker at reinier.de>
>   * Refactor PatchCheck monad to be defined with Control.Monad.State.State

Looks good to me.  Applied, thanks!

Add comments in Darcs.Patch.Check
---------------------------------
:-)

With David's warnings about the dangers of code comments being a
liability, I hope that our push for more haddocks is a good thing.  I
still think it does, if we think of it as API-writing.  Not trying to
say what the functions do, but what they're for, and what gotchas to
look out for.

By the way, perhaps the comment for is_valid to be refactored to
remove the double-negative?  (is not inconsistent => is consistent?)

Refactor PatchCheck monad to be defined with Control.Monad.State.State
----------------------------------------------------------------------
> +-- | Returns a given value if the repository state is inconsistent, and performs
> +--   a given action otherwise.
> +handle_inconsistent :: a            -- ^ The value to return if the state is inconsistent
> +                   -> PatchCheck a -- ^ The action to perform otherwise
> +                   -> PatchCheck a
> +handle_inconsistent v a = do state <- get
> +                             case state of
> +                               Inconsistent -> return v
> +                               _            -> a

This patch has two refactors in one, one which redefines the PatchCheck
monad in terms of Control.Monad.State.State (which seems eminently
sensible), and also one on the frequently occurring actions that pattern
match on the KnownState value returned by the last action.  I suspect
these could have been done separately, but I could be wrong and it's not
a big deal at all.

> hunk ./src/Darcs/Patch/Check.hs 146
> -file_empty :: String -> PatchCheck Bool
> +-- | Checks if a file is empty
> +file_empty :: String          -- ^ Name of the file to check

Should this be FilePath?

-- 
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: 197 bytes
Desc: Digital signature
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090328/67e2f42a/attachment.pgp>


More information about the darcs-users mailing list