[darcs-devel] Expanding Slurpy

David Roundy droundy at darcs.net
Sat Apr 30 06:29:16 PDT 2005


On Fri, Apr 29, 2005 at 04:43:27PM +0200, Juliusz Chroboczek wrote:
> David, Ian,
> 
> In SlurpDirectory.lhs, you say:
> 
> data Slurpy = SlurpDir FileName (Maybe (IO ())) [Slurpy]
>             | SlurpFile FileName Bool (EpochTime,FileOffset) FileContents
> 
> Would it be okay with you if I changed the Slurpy type in the
> following ways:
> 
>  - replace the mtime field in SlurpFile, which is currently of type
>    EpochTime, to be a Maybe Epochtime, and add a Maybe Epochtime field
>    to SlurpDir;

Currently we have an undefined_time, which is equal to -1, and an
undefined_size, which is also equal to -1.  I believe the code, when
checking for equality, assumes that undefined_time /= undefined_time and
undefined_size /= undefined_size.  You could either use those (which are a
tad ugly, but compact) or switch to a Maybe type.

As long as you're changing things (hash below), if you keep the EpochTime
and FileOffset as they are, it might be a good idea to mark them as
strict.  It'll save a bit of memory and a bit of time.  Probably not much
of either, but I like strict fields (when they really are inherently
strict, as I believe is the case here).

>  - add a field ``hash'' of type Maybe String to both of those.

I think I'd prefer if were called githash (and I'm thinking this would be a
good opportunity to switch to using named fields).  Thus we could (in
principle) also have a monotone_hash, which at least for directories would
probably be different...

> The net effect would be
> 
> data Slurpy = SlurpDir FileName 
>                        (Maybe EpochTime, Maybe String)
>                        (Maybe (IO ())) [Slurpy]
>             | SlurpFile FileName Bool 
>                         (Maybe EpochTime, FileOffset, Maybe String)
>                         FileContents

Perhaps we could consider a data type for that tuple? (As long as we're at
it...)

data FileMetaData = FMD {mod_time :: Maybe EpochTime,
                         file_length :: !FileOffset,
                         git_hash :: Maybe String}

I'm not sure I care for tuples as fields in data types.  Of course, this
one is my fault, but I've done a lot of things that I don't care for.
-- 
David Roundy
http://www.darcs.net




More information about the darcs-devel mailing list