pcre-heavy 0.2.2 → 0.2.3
raw patch · 5 files changed
+76/−21 lines, 5 filesdep ~Globdep ~doctestPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: Glob, doctest
API changes (from Hackage documentation)
- Text.Regex.PCRE.Heavy: instance [overlap ok] Lift PCREOption
- Text.Regex.PCRE.Heavy: instance [overlap ok] Stringable a => RegexReplacement ([a] -> a)
- Text.Regex.PCRE.Heavy: instance [overlap ok] Stringable a => RegexReplacement (a -> [a] -> a)
- Text.Regex.PCRE.Heavy: instance [overlap ok] Stringable a => RegexReplacement (a -> a)
- Text.Regex.PCRE.Heavy: instance [overlap ok] Stringable a => RegexReplacement a
+ Text.Regex.PCRE.Heavy: instance Data.Stringable.Stringable a => Text.Regex.PCRE.Heavy.RegexReplacement ([a] -> a)
+ Text.Regex.PCRE.Heavy: instance Data.Stringable.Stringable a => Text.Regex.PCRE.Heavy.RegexReplacement (a -> [a] -> a)
+ Text.Regex.PCRE.Heavy: instance Data.Stringable.Stringable a => Text.Regex.PCRE.Heavy.RegexReplacement (a -> a)
+ Text.Regex.PCRE.Heavy: instance Data.Stringable.Stringable a => Text.Regex.PCRE.Heavy.RegexReplacement a
+ Text.Regex.PCRE.Heavy: instance Language.Haskell.TH.Syntax.Lift Text.Regex.PCRE.Light.Base.PCREOption
- Text.Regex.PCRE.Heavy: scan :: Stringable a => Regex -> a -> [(a, [a])]
+ Text.Regex.PCRE.Heavy: scan :: (Stringable a) => Regex -> a -> [(a, [a])]
- Text.Regex.PCRE.Heavy: scanO :: Stringable a => Regex -> [PCREExecOption] -> a -> [(a, [a])]
+ Text.Regex.PCRE.Heavy: scanO :: (Stringable a) => Regex -> [PCREExecOption] -> a -> [(a, [a])]
- Text.Regex.PCRE.Heavy: scanRanges :: Stringable a => Regex -> a -> [((Int, Int), [(Int, Int)])]
+ Text.Regex.PCRE.Heavy: scanRanges :: (Stringable a) => Regex -> a -> [((Int, Int), [(Int, Int)])]
Files
- COPYING +0/−6
- README.md +25/−3
- UNLICENSE +24/−0
- library/Text/Regex/PCRE/Heavy.hs +20/−6
- pcre-heavy.cabal +7/−6
− COPYING
@@ -1,6 +0,0 @@-Copyright (c) 2015 Greg V <greg@unrelenting.technology>--Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.--THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
README.md view
@@ -1,4 +1,4 @@-# pcre-heavy [](https://hackage.haskell.org/package/pcre-heavy) [](https://tldrlegal.com/license/-isc-license)+# pcre-heavy [](https://hackage.haskell.org/package/pcre-heavy) [](https://travis-ci.org/myfreeweb/pcre-heavy) [](http://unlicense.org) *Finally!* A Haskell regular expressions library that does not suck. @@ -99,7 +99,29 @@ `utf8` is passed by default in the `re` QuasiQuoter. +## Development++Use [stack] to build. +Use ghci to run tests quickly with `:test` (see the `.ghci` file).++``bash+$ stack build++$ stack test && rm tests.tix++$ stack ghci --ghc-options="-fno-hpc"+``++[stack]: https://github.com/commercialhaskell/stack++## Contributing++Please feel free to submit pull requests!+Bugfixes and simple non-breaking improvements will be accepted without any questions :-)++By participating in this project you agree to follow the [Contributor Code of Conduct](http://contributor-covenant.org/version/1/2/0/).+ ## License -Copyright 2015 Greg V <greg@unrelenting.technology> -Available under the ISC license, see the `COPYING` file+This is free and unencumbered software released into the public domain. +For more information, please refer to the `UNLICENSE` file or [unlicense.org](http://unlicense.org).
+ UNLICENSE view
@@ -0,0 +1,24 @@+This is free and unencumbered software released into the public domain.++Anyone is free to copy, modify, publish, use, compile, sell, or+distribute this software, either in source code form or as a compiled+binary, for any purpose, commercial or non-commercial, and by any+means.++In jurisdictions that recognize copyright laws, the author or authors+of this software dedicate any and all copyright interest in the+software to the public domain. We make this dedication for the benefit+of the public at large and to the detriment of our heirs and+successors. We intend this dedication to be an overt act of+relinquishment in perpetuity of all present and future rights to this+software under copyright law.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.++For more information, please refer to <http://unlicense.org/>
library/Text/Regex/PCRE/Heavy.hs view
@@ -1,9 +1,9 @@ {-# OPTIONS_GHC -fno-warn-orphans -fno-warn-unused-binds #-}-{-# LANGUAGE UndecidableInstances, OverlappingInstances #-}+{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE FlexibleInstances, BangPatterns #-} {-# LANGUAGE TemplateHaskell, QuasiQuotes #-} {-# LANGUAGE ForeignFunctionInterface #-}-{-# LANGUAGE UnicodeSyntax #-}+{-# LANGUAGE UnicodeSyntax, CPP #-} -- | A usable regular expressions library on top of pcre-light. module Text.Regex.PCRE.Heavy (@@ -34,12 +34,14 @@ , rawSub ) where +#if __GLASGOW_HASKELL__ < 709+import Control.Applicative ((<$>))+#endif import Language.Haskell.TH hiding (match) import Language.Haskell.TH.Quote import Language.Haskell.TH.Syntax import qualified Text.Regex.PCRE.Light as PCRE import Text.Regex.PCRE.Light.Base-import Control.Applicative ((<$>)) import Data.Maybe (isJust, fromMaybe) import Data.List (unfoldr, mapAccumL) import Data.Stringable@@ -47,6 +49,7 @@ import qualified Data.ByteString.Internal as BS import System.IO.Unsafe (unsafePerformIO) import Foreign+import Debug.Trace substr ∷ BS.ByteString → (Int, Int) → BS.ByteString substr s (f, t) = BS.take (t - f) . BS.drop f $ s@@ -143,7 +146,7 @@ class RegexReplacement a where performReplacement ∷ BS.ByteString → [BS.ByteString] → a → BS.ByteString -instance Stringable a ⇒ RegexReplacement a where+instance {-# OVERLAPPABLE #-} Stringable a ⇒ RegexReplacement a where performReplacement _ _ to = toByteString to instance Stringable a ⇒ RegexReplacement (a → [a] → a) where@@ -159,9 +162,10 @@ rawSub r t s offset opts = case rawMatch r s offset opts of Just ((begin, end):groups) →+ let replacement = performReplacement (substr s (begin, end)) (map (substr s) groups) t in Just (BS.concat [ substr s (0, begin)- , performReplacement (substr s (begin, end)) (map (substr s) groups) t- , substr s (end, BS.length s)], end)+ , replacement+ , substr s (end, BS.length s)], begin + BS.length replacement) _ → Nothing -- | Replaces the first occurence of a given regex.@@ -172,6 +176,9 @@ -- >>> sub [re|a|] "b" "c" :: String -- "c" --+-- >>> sub [re|bad|] "xxxbad" "this is bad, right?"+-- "this is xxxbad, right?"+-- -- You can use functions! -- A function of Stringable gets the full match. -- A function of [Stringable] gets the groups.@@ -195,6 +202,13 @@ -- -- >>> gsub [re||] "" "Hello, world" :: String -- "Hello, world"+--+-- https://github.com/myfreeweb/pcre-heavy/issues/2+-- >>> gsub [re|good|] "bad" "goodgoodgood"+-- "badbadbad"+--+-- >>> gsub [re|bad|] "xxxbad" "this is bad, right? bad"+-- "this is xxxbad, right? xxxbad" gsub ∷ (Stringable a, RegexReplacement r) ⇒ Regex → r → a → a gsub r t s = gsubO r [] t s
pcre-heavy.cabal view
@@ -1,5 +1,5 @@ name: pcre-heavy-version: 0.2.2+version: 0.2.3 synopsis: A regexp library on top of pcre-light you can actually use. description: A regular expressions library that does not suck.@@ -16,14 +16,14 @@ author: Greg V copyright: 2015 Greg V <greg@unrelenting.technology> maintainer: greg@unrelenting.technology-license: OtherLicense-license-file: COPYING+license: PublicDomain+license-file: UNLICENSE build-type: Simple cabal-version: >= 1.18 extra-source-files: README.md tested-with:- GHC == 7.8.3+ GHC == 7.10.2 source-repository head type: git@@ -46,9 +46,10 @@ test-suite examples build-depends: base >= 4.0.0.0 && < 5- , Glob == 0.*- , doctest == 0.*+ , Glob+ , doctest default-language: Haskell2010+ ghc-options: -threaded hs-source-dirs: test-suite main-is: DocTest.hs type: exitcode-stdio-1.0