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:
|
showsPrec i (PatternSet s scc sce sec) = |
|
let (special,normal) = maybe ("","") ((partition (`elem` "]-")) . Set.toAscList) s |
|
charSpec = (if ']' `elem` special then (']':) else id) (byRange normal) |
|
scc' = maybe "" ((concatMap show) . Set.toList) scc |
|
sce' = maybe "" ((concatMap show) . Set.toList) sce |
|
sec' = maybe "" ((concatMap show) . Set.toList) sec |
|
in shows charSpec |
|
. showsPrec i scc' . showsPrec i sce' . showsPrec i sec' |
Better docs for(fixed in 1.3.2), fixPatternmoduleshowPatternto round-trip.It is claimed that
showPatternround-trips, but does not:It uses
Show PatternSetwhich adds"coming from empty components ofPatternSet:regex-tdfa/lib/Text/Regex/TDFA/Pattern.hs
Lines 102 to 109 in c5b8f54