[darcs-users] darcs patch: change is_file to return false on dround... (and 1 more)

Jason Dagit dagit at codersbase.com
Sat Sep 13 14:56:20 UTC 2008


On Sat, Sep 13, 2008 at 3:52 AM, David Roundy <droundy at darcs.net> wrote:
> On Fri, Sep 12, 2008 at 06:58:12PM -0700, Jason Dagit wrote:
>> On Fri, Sep 12, 2008 at 10:38 AM, David Roundy <droundy at darcs.net> wrote:
>> > Here's a fix for a bug that shows up when you try
>> >
>> > darcs put remote.server:
>> >
>> > And then a refactor to get rid of those Regexes.
>>
>> Personal style preference here:
>> +is_url :: String -> Bool
>> +is_url (':':'/':'/':_) = True
>> +is_url (_:x) = is_url x
>> +is_url "" = False
>>
>> The first case is a little hard for me to read just due to all the
>> quotes and colons.
>>
>> is_url :: String -> Bool
>> is_url "" = False
>> is_url s = "://" `isPrefixOf` s || is_url (tail s)
>
> It's a bit awkward to read, but I  don't think it's too hard,  and I
> prefer to avoid (when possible) using standard library functions that I
> don't  know when they've been added.  It would be nice if that were
> documented (is it?).

Right, I could have said, is_url = isInfixOf "://", but that was added
recent-ish.  On the other hand, isPrefixOf seems to be in H98 prelude:
http://www.haskell.org/onlinereport/list.html

FWIW, it looks like isInfixOf was added almost exactly 2 years ago if
the date of this email is accurate, but in general it would be nice if
the standard docs said what stable version of GHC a function first
shipped with:
http://osdir.com/ml/lang.haskell.libraries/2006-09/msg00012.html

> things will go crazy.  The simple rule is that if it contains a colon in
> any position but the second character, it's not a file.  We could  indeed
> extend  this rule to say that paths beginning with a colon might  also be
> files, but I don't see a  huge  demand for that.

Okay.  It was just a random thought, but it's probably not a big deal.

Thanks,
Jason


More information about the darcs-users mailing list