regex-tdfa icon indicating copy to clipboard operation
regex-tdfa copied to clipboard

Fix `showPattern` to round-trip

Open andreasabel opened this issue 3 years ago • 0 comments

~~Better docs for Pattern module~~ (fixed in 1.3.2), fix showPattern to round-trip.

It is claimed that showPattern round-trips, but does not:

>>> getAllTextMatches ("a \" \\" =~ "[a]") :: [String]
["a"]

>>> let parse = either (error . show) fst . parseRegex
>>> let pp' = showPattern . parse
>>> getAllTextMatches ("a \" \\" =~ pp' "[a]") :: [String]
["a","\""]

It uses Show PatternSet which adds " coming from empty components of PatternSet: https://github.com/haskell-hvr/regex-tdfa/blob/c5b8f544b091b2033afe61a9d5dd3987a6f8d21d/lib/Text/Regex/TDFA/Pattern.hs#L102-L109

andreasabel avatar Jul 18 '22 16:07 andreasabel