[commit: packages/filepath] master: Put "Valid x =>" constraint on joinDrive QuickCheck property (7420444)

git at git.haskell.org git at git.haskell.org
Thu Mar 19 11:35:47 UTC 2015


Repository : ssh://git@git.haskell.org/filepath

On branch  : master
Link       : http://git.haskell.org/packages/filepath.git/commitdiff/7420444bb461968a5da58f6a5b8707b0a7efeb4e

>---------------------------------------------------------------

commit 7420444bb461968a5da58f6a5b8707b0a7efeb4e
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Tue Oct 28 19:57:32 2014 +0100

    Put "Valid x =>" constraint on joinDrive QuickCheck property
    
    Counterexample:
    
        $ let x = "\\\\?\\D:file"
        $ splitDrive x
        ("\\\\?\\D:","file")
        $ uncurry joinDrive (splitDrive x)
        "\\\\?\\D:\\file"
    
    The "problem" is that the current implementation of splitDrive can sometimes
    return invalid drives, such as in the above example. However, if it wouldn't
    do so, it would make the implementation of isValid and makeValid more
    difficult.
    
    My guideline is currently as follows: splitDrive makes the rough cut of what
    is and what isn't a drive, isValid and makeValid finish the job, all other
    functions assume drives and paths are valid.
    
    This is also the reason joinDrive (=combineAlways) should not be changed to
    not insert the extra slash, solely to handle an invalid path.


>---------------------------------------------------------------

7420444bb461968a5da58f6a5b8707b0a7efeb4e
 System/FilePath/Internal.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs
index e3fa7cb..8f2c51b 100644
--- a/System/FilePath/Internal.hs
+++ b/System/FilePath/Internal.hs
@@ -377,7 +377,7 @@ readDriveShareName name = addSlash a b
 
 -- | Join a drive and the rest of the path.
 --
--- >          uncurry joinDrive (splitDrive x) == x
+-- > Valid x => uncurry joinDrive (splitDrive x) == x
 -- > Windows: joinDrive "C:" "foo" == "C:foo"
 -- > Windows: joinDrive "C:\\" "bar" == "C:\\bar"
 -- > Windows: joinDrive "\\\\share" "foo" == "\\\\share\\foo"



More information about the ghc-commits mailing list