darcs-2.18.2: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

Darcs.Patch.TokenReplace

Synopsis

- tryTokReplace :: String -> ByteString -> ByteString -> ByteString -> Maybe ByteString
- forceTokReplace :: String -> ByteString -> ByteString -> ByteString -> ByteString
- annotateReplace :: String -> ByteString -> ByteString -> ByteString -> Bool
- breakToTokens :: ByteString -> [ByteString]
- defaultToks :: String

# Documentation

tryTokReplace :: String -> ByteString -> ByteString -> ByteString -> Maybe ByteString #

`tryTokReplace tokChars old new input` tries to find the token `old` and replace it with the token `new` everywhere in the `input`, returning `Just` the modified `input`, unless the token `new` is already in the `input` in which case `Nothing` is returned. A token is a sequence of bytes that match the class defined by `tokChars`. This function is supposed to work efficiently with large `input`s i.e. whole files.

forceTokReplace :: String -> ByteString -> ByteString -> ByteString -> ByteString #

`forceTokReplace tokChars old new input` replaces all occurrences of the `old` token with the `new` one, throughout the `input`.

annotateReplace :: String -> ByteString -> ByteString -> ByteString -> Bool #

Check if a token replace operation touches the given line.

breakToTokens :: ByteString -> [ByteString] #

Break a `Bytestring` into tokens, according to `defaultToks`, discarding non-tokens.

defaultToks :: String #