anagrep 0.1.0.0 → 0.1.0.1
raw patch · 4 files changed
+74/−3 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Text.Regex.Anagram.Bits: instance Text.Regex.Anagram.Bits.FindBits GHC.Natural.Natural
+ Text.Regex.Anagram.Bits: ($dmfindBits) :: (FindBits b, FiniteBits b) => b -> [Int]
+ Text.Regex.Anagram.Bits: instance Text.Regex.Anagram.Bits.FindBits GHC.Num.Natural.Natural
- Text.Regex.Anagram.Bits: findBits :: (FindBits b, FiniteBits b) => b -> [Int]
+ Text.Regex.Anagram.Bits: findBits :: FindBits b => b -> [Int]
Files
- README +37/−0
- Text/Regex/Anagram/Types.hs +4/−0
- anagrep.cabal +3/−2
- src/anagrep.hs +30/−1
+ README view
@@ -0,0 +1,37 @@+A Haskell library for matching permutations of regular expressions: http://hackage.haskell.org/package/anagrep++And a command-line interface, useful for puzzle solving (e.g., which English word has one 'p', one 'q', and four vowels?):++Usage: anagrep REGEXP [FILE]...+Print lines in each FILE (or stdin) for which some permutation (anagram)+matches the given REGEXP. REGEXP is a restricted regular expression that can+contain the following patterns:+ Character matches+ x single literal character+ [aein-z] character set (any listed character)+ [^a-mou] negated character set (any character not listed)+ . any single character+ \x escape single literal character (no special meanings)+ Repeat modifiers - may only be applied to characters (above)+ {N,M} repeat character N-M times+ {N,} repeat character at least N times+ {N} equivalent to {N,N}+ ? equivalent to {0,1}+ * equivalent to {0,}+ + equivalent to {1,}+ Combination+ XY concatenation matches pattern X and Y in either order+ X|Y alternation matches pattern X or Y+ (X) grouping (only useful for alternation - note that successive+ grouped alternations involve a cross-product expansion and may+ be slow)+Other regular expression features are not currently supported. Matching is+always done on entire lines (like grep -x).++Example: anagrep 'pq[aeiou]{4}' /usr/share/dict/words+ > opaque++Flags:+ -b treat input as raw byte sequence (uses locale encoding by default)+ -i ignore case distinctions in patterns and data+
Text/Regex/Anagram/Types.hs view
@@ -136,9 +136,13 @@ , patStar = foldCase patStar } +instance NFData a => NFData (RL a) where+ rnf = rnf1 instance NFData1 RL where liftRnf f (RL a _) = f a +instance (NFData1 f, NFData a) => NFData (RLEof f a) where+ rnf = rnf1 instance NFData1 f => NFData1 (RLEof f) where liftRnf f (RLE l) = liftRnf (liftRnf f) l
anagrep.cabal view
@@ -1,10 +1,10 @@ cabal-version: >=1.10 name: anagrep-version: 0.1.0.0+version: 0.1.0.1 synopsis: Find strings with permutations (anagrams) that match a regular expression description: Given a regular expression, determine if it matches any permutation of a given string. For example, @"lt[aeiou]*"@ would match all strings with one \'l\', one \'t\', and vowels (like \"elate\", \"tail\", \"tl\", etc.).- Regular expression parsing is based on <//hackage.haskell.org/package/regex-tdfa regex-tdfa> and generally follows those semantics, but not all regular expression features are supported. For example, repeat modifiers cannot be applied to groups (such as "(abc)*").+ Regular expression parsing is based on <//hackage.haskell.org/package/regex-tdfa regex-tdfa> and generally follows those semantics, but not all regular expression features are supported. For example, repeat modifiers cannot be applied to groups (such as @"(abc)*"@). The goal is for matching to be fairly efficient in most cases, given that this problem is NP-complete. license: BSD3 author: Dylan Simon@@ -12,6 +12,7 @@ copyright: 2020, Dylan Simon category: Text build-type: Simple+extra-source-files: README source-repository head type: git
src/anagrep.hs view
@@ -37,7 +37,36 @@ exitFailure (_, _, e) -> do mapM_ (hPutStrLn stderr) e- hPutStrLn stderr $ Opt.usageInfo ("Usage: " ++ prog ++ " REGEXP [FILE]...\nPrint lines in each FILE (or stdin) for which some permuatation (anagram) matches the given REGEXP.") options+ hPutStrLn stderr $ Opt.usageInfo ("Usage: " ++ prog ++ " REGEXP [FILE]...\n\+\Print lines in each FILE (or stdin) for which some permutation (anagram)\n\+\matches the given REGEXP. REGEXP is a restricted regular expression that can\n\+\contain the following patterns:\n\+\ Character matches\n\+\ x single literal character\n\+\ [aein-z] character set (any listed character)\n\+\ [^a-mou] negated character set (any character not listed)\n\+\ . any single character\n\+\ \\x escape single literal character (no special meanings)\n\+\ Repeat modifiers - may only be applied to characters (above)\n\+\ {N,M} repeat character N-M times\n\+\ {N,} repeat character at least N times\n\+\ {N} equivalent to {N,N}\n\+\ ? equivalent to {0,1}\n\+\ * equivalent to {0,}\n\+\ + equivalent to {1,}\n\+\ Combination\n\+\ XY concatenation matches pattern X and Y in either order\n\+\ X|Y alternation matches pattern X or Y\n\+\ (X) grouping (only useful for alternation - note that successive\n\+\ grouped alternations involve a cross-product expansion and may\n\+\ be slow)\n\+\Other regular expression features are not currently supported. Matching is\n\+\always done on entire lines (like grep -x).\n\+\\n\+\Example: " ++ prog ++ " 'pq[aeiou]{4,}' /usr/share/dict/words\n\+\ > opaque\n\+\\n\+\Flags:") options exitFailure let ci :: FoldCase a => a -> a ci