[Hackage] #115: showFilePath/showToken dodgy characters

Hackage trac at galois.com
Wed Jan 30 10:47:05 EST 2008

#115: showFilePath/showToken dodgy characters
  Reporter:  igloo          |        Owner:        
      Type:  defect         |       Status:  new   
  Priority:  normal         |    Milestone:        
 Component:  Cabal library  |      Version:  1.1.6 
  Severity:  normal         |   Resolution:        
  Keywords:                 |   Difficulty:  normal
Ghcversion:  6.6            |     Platform:  Linux 
Comment (by duncan):

 Actually I think this is ok.

 So `showFilePath` and `parseFilePathQ` are the two inverses that are used
 by many fields.

 parseFilePathQ = parseTokenQ

 parseTokenQ = parseReadS <++ munch1 (\x -> not (isSpace x) && x /= ',')

 `parseReadS` is a parser that uses `Read`, which for a `String` of course
 means parsing an ordinary Haskell string in quotes with escapes etc.

 The alternative then, if it is not surrounded in quotes, is a token is a
 bunch of characters that is not a space or ','. " and \ would be
 interpreted as it, eg `foo"bar\"baz` would all be one token. So
 correspondingly, the only characters that would cause a problem when
 pretty printing are spaces and ',', in which case we should use the
 standard `show` for `String`.

 So for example this means that '\' in Windows paths does not need to be
 escaped unless you use `"C:\\Foo\Bar"` in Haskell string syntax.

Ticket URL: <http://hackage.haskell.org/trac/hackage/ticket/115#comment:1>
Hackage <http://haskell.org/cabal/>
Hackage: Cabal and related projects

More information about the cabal-devel mailing list