[darcs-users] darcs patch: do not use concatenation in src/Context.hs

Florent Becker florent.becker at ens-lyon.org
Thu Jan 8 14:35:28 UTC 2009


Trent W. Buck wrote:

> Eric Kow <kowey at darcs.net> writes:
> 
>> Content-Description: A darcs patch for your repository!
>>> +  putStrLn $ varname ++ " =\"" ++ concatMap escape ls ++ "\""
>>> +    where
>>> +      escape '\n' = "\\n\\\n\\"
>>> +      escape '"'  = "\\\""
>>> +      escape '\\' = "\\\\"
>>> +      escape c = [c]
>>
>> All those backslashes confuse me, although I (think I) get the idea
>> that you're trying to doubly-protect them, once for this code and once
>> for the generated code.
> 
> Would (show) or (show . show) help here?

I don't think so, the problem is to get the character/string escaped, but
not surrounded by quotes. The best way would be to paste String's show
instance, but i don't know where to look for it inside ghc's source. It's
weird that there's no such library function, maybe i've not been looking
hard enough.

Florent.



More information about the darcs-users mailing list