packages feed

regexchar 0.9.0.13 → 0.9.0.14

raw patch · 23 files changed

+561/−522 lines, 23 filesdep +data-defaultdep ~regexdotdep ~toolshedPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: data-default

Dependency ranges changed: regexdot, toolshed

API changes (from Hackage documentation)

- RegExChar.MetaChar: deconstruct :: MetaChar -> Meta Char
+ RegExChar.ExtendedRegExChar: infix 4 /~
+ RegExChar.MetaChar: [deconstruct] :: MetaChar -> Meta Char
+ RegExChar.RegExOptsChar: infix 4 =~
- RegExChar.MetaChar: MkMetaChar :: (Meta Char) -> MetaChar
+ RegExChar.MetaChar: MkMetaChar :: Meta Char -> MetaChar

Files

+ .ghci view
@@ -0,0 +1,1 @@+:set -isrc-lib:src-exe:src-test:dist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
README.markdown view
@@ -1,23 +1,32 @@-# **RegExChar**.+# **RegExChar** -This is **RegExChar**, a regex-engine built from the polymorphic regex-engine 'RegExDot' as a proof of concept.+[![Hackage](https://img.shields.io/hackage/v/regexchar.svg)](https://hackage.haskell.org/package/regexchar) [![Build Status](https://travis-ci.org/functionalley/RegExChar.svg?branch=master)](https://travis-ci.org/functionalley/RegExChar) +This is "**RegExChar**", a regex-engine built from the polymorphic regex-engine "**RegExDot**" as a proof of concept.+ ## Installation  It can be built and installed using [Cabal](https://www.haskell.org/cabal/users-guide/installing-packages.html).  ## Documentation--*	The directory **man/** contains the documentation.-*	More information about this application can be found at [RegExChar](http://functionalley.eu/RegExChar/regExChar.html).+* The directory "**man/**" contains the documentation.+* More information about this application can be found at [RegExChar](http://functionalley.eu/RegExChar/regExChar.html).  ## License -For information on copying and distributing this package, see the file **LICENSE** in this directory.+For information on copying and distributing this package, see the file "**LICENSE**" in this directory.  ## Bug-reporting -Bug-reports should be emailed to <regexchar *at* functionalley *dot* eu>.+Bug-reports should be emailed to <regexchar@functionalley.eu>.++## Testing++The test-suite can be run using:++    cabal configure --enable-tests;+    cabal build;+    cabal test --show-details=always;  ## Author 
changelog.Debian view
@@ -4,17 +4,17 @@  regexchar (0.9.0.7-1) experimental; urgency=low -  * Uploaded to <http://hackage.haskell.org/packages/hackage.html>.+  * Uploaded to <http://hackage.haskell.org/package/regexchar>.  regexchar (0.9.0.8-1) experimental; urgency=low    * - -- Alistair Ward <regexchar at functionalley dot eu>  Wed, 12 Jan 2011 00:00:00 +0000+ -- Alistair Ward <regexchar@functionalley.eu>  Wed, 12 Jan 2011 00:00:00 +0000  regexchar (0.9.0.10-1) experimental; urgency=low    * - -- Alistair Ward <regexchar at functionalley dot eu>  Sat, 06 May 2012 00:00:00 +0000+ -- Alistair Ward <regexchar@functionalley.eu>  Sat, 06 May 2012 00:00:00 +0000 
changelog.markdown view
@@ -1,77 +1,102 @@-# 2010-11-18 Dr. Alistair Ward <regexchar at functionalley dot eu>+# 2010-11-18 Dr. Alistair Ward <regexchar@functionalley.eu>  ## 0.9.0.0-	* First version of the package.+* First version of the package.+ ## 0.9.0.1-	* Reacted to major-number changes in the packages **ToolShed-0.10.0.0** & **RegExDot-0.10.0.0**.-	* Created **src/RegExChar/** (& then modified module-names accordingly) & **data/** sub-directories.-	* Pacified **hlint**.-	* Added a makefile.-	* Qualified identifiers used in error-messages.+* Reacted to major-number changes in the packages "**ToolShed-0.10.0.0**" & "**RegExDot-0.10.0.0**".+* Created **src/RegExChar/** (& then modified module-names accordingly), & sub-directory "**data/**".+* Pacified **hlint**.+* Qualified identifiers used in error-messages.+ ## 0.9.0.2-	* Ported to ghc-7.0.1:-		Replaced the deprecated module **Test.QuickCheck.Batch**, & labelled properties.-	* Added the cabal-flag **threaded**, to account for the requirement to link with the threaded runtime when using a threaded version of the library package **RegExDot**.+* Ported to ghc-7.0.1:+	+ Replaced the deprecated module "**Test.QuickCheck.Batch**", & labelled properties.+* Added the cabal-flag "**threaded**", to account for the requirement to link with the threaded runtime when using a threaded version of the library package "**RegExDot**".+ ## 0.9.0.3-	* Parallelised processing where **grecce** is requested to read multiple input-data files.-	* Extracted matching-operation from the **Main** module, into new module **Grecce.Grep**.-	* Migrated modules required only by the executable **grecce**, from the directory **RegExChar** into the new directory **Grecce**.-	* Replaced use of @threaded@-flag in source-code, with CABAL CPP-macro.-	* Added *.spec*-file.+* Parallelised processing where executable "**grecce**" is requested to read multiple input-data files.+* Extracted matching-operation from the module "**Main**", into new module "**Grecce.Grep**".+* Migrated modules required only by the executable "**grecce**", from the directory "**RegExChar**" into the new directory "**Grecce**".+* Replaced use of @threaded@-flag in source-code, with Cabal CPP-macro.+* Added *.spec*-file.++ ## 0.9.0.4-	* Added default values of command-line flags, to usage-message.-	* Reacted to migration of **RegExDot.Options** to **ToolShed.Options**.-	* Used new **ToolShed.Package** module.+* Added default values of command-line flags, to usage-message.+* Reacted to migration of **RegExDot.Options** to **ToolShed.Options**.+* Used new module "**ToolShed.Package**".+ ## 0.9.0.5-	* Fixed negated reference to unparenthesised CPP-macro **MIN_VERSION**.-	* Protected reference in **Grecce/QC/QuickChecks.hs**, to `Test.QuickCheck.verboseCheck`, using CPP-statement.+* Fixed negated reference to unparenthesised CPP-macro "**MIN_VERSION**".+* Protected reference in module "**Grecce/QC/QuickChecks**", to `Test.QuickCheck.verboseCheck`, using CPP-statement.+ ## 0.9.0.6-	* Amended RPM *.spec*-file, to install under **/usr**, rather than **/usr/local**.-	* Renamed package from **RegExChar** to **regexchar**, for compatibility with Debian's *.deb*-format.-	* Added directory-structure required to build *.deb*-package.+* Amended RPM *.spec*-file, to install under directory "**/usr**", rather than "**/usr/local**".+* Renamed package from "**RegExChar**" to "**regexchar**", for compatibility with Debian's *.deb*-format.+* Added directory-structure required to build *.deb*-package.+ ## 0.9.0.7-	* Redefined man-page to be an **extra-source-file** in the *.cabal*-file & the *.spec*-file.-	* Added manually controlled **llvm** flag to the *.cabal*-file.-	* Replaced references to the module **ToolShed.Package** with **Distribution.Package**.-	* Changed identifier for type-parameters, to better reflect its role.-	* Removed dependency on archaic module **ToolShed.Arithmetic**.-	* Reacted to the creation of module **ToolShed.Defaultable**.-	* Uploaded to [Hackage](http://hackage.haskell.org/packages/hackage.html).+* Redefined man-page to be an "**extra-source-file**" in the *.cabal*-file & the *.spec*-file.+* Added manually controlled flag "**llvm**" to the *.cabal*-file.+* Replaced references to the module "**ToolShed.Package**" with "**Distribution.Package**".+* Changed identifier for type-parameters, to better reflect its role.+* Removed dependency on archaic module "**ToolShed.Arithmetic**".+* Reacted to the creation of module "**ToolShed.Defaultable**".+* Uploaded to [Hackage](http://hackage.haskell.org/package/regexchar).+ ## 0.9.0.8-	* Amended the *.cabal*-file to more correctly specify dependency on package **toolshed**.-	* Used new module **ToolShed.Pair** from package toolshed-0.12.0.0.-	* Relocated modules **Grecce.Assert**, **Grecce.Performance** and **Grecce.QC**, into new layer **Test**, in module-hierarchy.-	* Guarded **eager-blackholing** flag in the *cabal*-file.+* Amended the *.cabal*-file to more correctly specify dependency on package "**toolshed**".+* Used new module "**ToolShed.Pair**" from package toolshed-0.12.0.0.+* Relocated modules "**Grecce.Assert**", "**Grecce.Performance**" and "**Grecce.QC**", into new layer "**Test**", in module-hierarchy.+* Guarded flag "**eager-blackholing**" in the *cabal*-file.+ ## 0.9.0.9-	* Recoded **RegExChar.RegExOptsChar** to the interface `Data.Array.IArray.IArray`, rather than the data-type `Data.Array.Array`.-	* Replaced `(+ 1)` and `(- 1)` with the faster calls `succ` and `pred`, in **RegExChar.RegExOptsChar**, **Grecce.Test.Performance.ExtendedRegExTestsPositive** and **Grecce.Grep**.-	* Used `Paths_regexchar.version` in **Main**, rather than hard-coding it.-	* Reacted to new module-hierarchy and addition of method `ToolShed.SelfValidate.getErrors`, in **toolshed-0.13.0.0**, and used it to improved error-reporting in @instance Read RegExChar.ExtendedRegExChar.ExtendedRegExChar@.-	* Replaced use of `Control.Monad` in **RegExChar.MetaChar** and **RegExChar.ExtendedRegExChar**, with `Control.Applicative`.-	* Replaced `System` with `System.Environment` and `System.Exit`.-	* Removed dependency on **haskell98**.+* Recoded module "**RegExChar.RegExOptsChar**" to the interface `Data.Array.IArray.IArray`, rather than the data-type `Data.Array.Array`.+* Replaced `(+ 1)` and `(- 1)` with the faster calls `succ` and `pred`, in modules "**RegExChar.RegExOptsChar**", "**Grecce.Test.Performance.ExtendedRegExTestsPositive**" and "**Grecce.Grep**".+* Used `Paths_regexchar.version` in **Main**, rather than hard-coding it.+* Reacted to new module-hierarchy and addition of method `ToolShed.SelfValidate.getErrors`, in package "**toolshed-0.13.0.0**", and used it to improved error-reporting in @instance Read RegExChar.ExtendedRegExChar.ExtendedRegExChar@.+* Replaced use of `Control.Monad` in **RegExChar.MetaChar** and **RegExChar.ExtendedRegExChar**, with `Control.Applicative`.+* Replaced `System` with `System.Environment` and `System.Exit`.+* Removed dependency on **haskell98**.+ ## 0.9.0.10-	* Fully qualified symbols imported from package **regexdot**.-	* Used new constant `RegExDot.Anchor.unanchored`.-	* Added details to any failure to parse the command-line arguments.-	* Used new test-modules from **toolshed-0.14.0.0**.+* Fully qualified symbols imported from package "**regexdot**".+* Used new constant `RegExDot.Anchor.unanchored`.+* Added details to any failure to parse the command-line arguments.+* Used new test-modules from package "**toolshed-0.14.0.0**".+ ## 0.9.0.11-	* Refactored **Grecce.Test.QC.QuickChecks**.-	* Replaced calls to `error` from inside the IO-monad, with `Control.Monad.fail`.-	* Trapped command-line arguments to which garbage has been appended.-	* Added files to build *.deb* to the *.cabal*-file.-	* Tested with **haskell-platform-2013.2.0.0**.-	* Replaced preprocessor-directives with **build-depends** constraints in the *.cabal*-file.+* Refactored module "**Grecce.Test.QC.QuickChecks**".+* Replaced calls to `error` from inside the IO-monad, with `Control.Monad.fail`.+* Trapped command-line arguments to which garbage has been appended.+* Added files to build *.deb* to the *.cabal*-file.+* Tested with **haskell-platform-2013.2.0.0**.+* Replaced preprocessor-directives with **build-depends** constraints in the *.cabal*-file.+ ## 0.9.0.12-	* Either replaced instances of `(<$>)` with `fmap` to avoid ambiguity between **Control.Applicative** & **Prelude** which (from **base-4.8**) also exports this symbol, or hid the symbol when importing the **Prelude**..+* Either replaced instances of `(<$>)` with `fmap` to avoid ambiguity between modules "**Control.Applicative**" & "**Prelude**" which (from package "**base-4.8**") also exports this symbol, or hid the symbol when importing the module "**Prelude**".+ ## 0.9.0.13-	* Added the compiler to the output returned for the command-line option **version**.-	* Changed flag **threaded** in the *.cabal*-file to **manual**.-	* Added **Default-language**-specification to the *.cabal*-file.-	* Added file **README.markdown**.-	* Converted this file to markdown-format.-	* Replaced `System.Exit.exitWith System.Exit.ExitSuccess` with `System.Exit.exitSuccess`.-	* Moved the entry-point to the test-suite from **Main.hs** to **Test.hs**, both to integrate with **cabal** & to minimise the dependencies of the executable.-	* Partitioned the source-files into **src-lib**, **src-exe**, & **src-test** directories, & referenced them individually from the *.cabal*-file to avoid repeated compilation.-	* Used **CPP** to control the import of symbols from **Control.Applicative**.+* Added the compiler to the output returned for the command-line option "**version**".+* Changed flag "**threaded**" in the *.cabal*-file to **manual**.+* Added "**Default-language**"-specification to the *.cabal*-file.+* Added file "**README.markdown**".+* Converted this file to markdown-format.+* Replaced `System.Exit.exitWith System.Exit.ExitSuccess` with `System.Exit.exitSuccess`.+* Moved the entry-point to the test-suite from module "**Main.hs**" to "**Test.hs**", both to integrate with **cabal** & to minimise the dependencies of the executable.+* Partitioned the source-files into directories "**src-lib**", "**src-exe**", & "**src-test**", & referenced them individually from the *.cabal*-file to avoid repeated compilation.+* Used **CPP** to control the import of symbols from **Control.Applicative**. +## 0.9.0.14+* Corrected the markdown-syntax in this file.+* Reverted to calling "**error**" rather than "**Control.Monad.fail**", since the **String**-argument for the latter is discarded in **Monad**-implementations other than **IO**.+* Uploaded to [GitHub](https://github.com/functionalley/RegExChar.git).+* Simplified file **src-test/Main.hs**.+* Added **prop_read** to modules; **Grecce.Test.QC.{RepeatableMetaChar,ExtendedRegExChar}**.+* Replaced calls to **error** with **[]**, in implementation of **Read**, in module **RegExChar.ExtendedRegExChar**.+* Added file **.travis.yml** to control testing by <https://docs.travis-ci.com>.+* Added file **.ghci**.+* Replaced use of module **ToolShed.Defaultable** with **Data.Default**.+* Reimplemented **RegExChar.MetaChar.deconstruct**, **QuickCheck.ExtendedRegExChar.deconstruct**, **QuickCheck.RepeatableMetaChar.deconstruct** using record-syntax.+* Tested with **ghc-8.0.1**.
@@ -1,5 +1,5 @@ Author:-	Dr. Alistair Ward <regexchar at functionalley dot eu>.+	Dr. Alistair Ward <regexchar@functionalley.eu>.  Copyright: 	Copyright (C) 2010-2011 Dr. Alistair Ward. All Rights Reserved.
debian/DEBIAN/control view
@@ -1,11 +1,11 @@ Package:	regexchar-Version:	0.9.0.13-1+Version:	0.9.0.14-1 Section:	text Priority:	optional Architecture:	amd64 Depends:	libc6 Installed-size:	3222-Maintainer:	Dr. Alistair Ward <regexchar at functionalley dot eu>+Maintainer:	Dr. Alistair Ward <regexchar@functionalley.eu> Provides: Homepage:	http://functionalley.eu/RegExChar/regExChar.html Description:	POSIX extended regular-expression engine.
man/man1/grecce.1 view
@@ -178,7 +178,7 @@ Written by Dr. Alistair Ward. .SH BUGS .SS "REPORTING BUGS"-Report bugs to <\fBgrecce\fR \fIat\fR \fBfunctionalley\fR \fIdot\fR \fBeu\fR>.+Report bugs to <\fBgrecce@functionalley.eu\fR>. .SS Known Bugs There is no support for either \fIBack-references\fR or \fICase-insensitivity\fR. .PP@@ -195,7 +195,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see \fB<http://www.gnu.org/licenses/>\fR. .SH "SEE ALSO" .IP \(bu-Home-page: \fBhttp://functionalley.eu/RegExChar/regExChar\fR+Home-page: \fBhttp://functionalley.eu/RegExChar/regExChar.html\fR+.IP \(bu+.B http://hackage.haskell.org/package/regexchar+.IP \(bu+.B https://github.com/functionalley/RegExChar .IP \(bu Source-documentation is generated by "\fBHaddock\fR", & is available in the distribution. .IP \(bu
regexchar.cabal view
@@ -14,7 +14,7 @@ -- along with RegExChar.  If not, see <http://www.gnu.org/licenses/>.  Name:		regexchar-Version:	0.9.0.13+Version:	0.9.0.14 Cabal-version:	>= 1.10 Copyright:	(C) 2010-2015 Dr. Alistair Ward License:	GPL@@ -25,10 +25,10 @@ Build-type:	Simple Description:	Provides a POSIX, extended regex-engine, specialised from the underlying /polymorphic/ package /regexdot/, to merely process the traditional character-lists. Category:	Regex, Text-Tested-with:	GHC == 6.10, GHC == 6.12, GHC == 7.0, GHC == 7.4, GHC == 7.6, GHC == 7.8, GHC == 7.10+Tested-with:	GHC == 7.4, GHC == 7.6, GHC == 7.8, GHC == 7.10.1, GHC == 8.0.1 Homepage:	http://functionalley.eu/RegExChar/regExChar.html-Maintainer:	mailto <colon> regexchar <at> functionalley <dot> eu-Bug-reports:	mailto <colon> regexchar <at> functionalley <dot> eu+Maintainer:	mailto:regexchar@functionalley.eu+Bug-reports:	mailto:regexchar@functionalley.eu  -- These files can be read by the application from 'Paths_weekdaze.datadir'. Data-files:@@ -36,6 +36,7 @@  -- None of these files are needed at run-time. Extra-source-files:+    .ghci     changelog.Debian     changelog.markdown     copyright@@ -44,6 +45,10 @@     README.markdown     regexchar.spec +source-repository head+    type:	git+    location:	https://github.com/functionalley/RegExChar+ -- Enable using: 'cabal configure -f llvm'. flag llvm     Description:	Whether the 'llvm' compiler-backend has been installed and is required for code-generation.@@ -57,8 +62,7 @@  Library     Default-language:	Haskell2010-    GHC-options:	-Wall -O2 -fno-warn-tabs-    GHC-prof-options:	-prof -auto-all -caf-all+    GHC-options:	-O2 -Wall -fno-warn-tabs     Hs-source-dirs:	src-lib      Exposed-modules:@@ -70,26 +74,31 @@         array,         base == 4.*,         containers,+        data-default,         parsec == 3.*,         regex-base,-        regexdot >= 0.11.1.0,-        toolshed >= 0.16+        regexdot >= 0.12,+        toolshed >= 0.17      if impl(ghc >= 7.4.1)-        GHC-prof-options:	-prof -fprof-auto -fprof-cafs+        GHC-prof-options:	-fprof-auto -fprof-cafs     else-        GHC-prof-options:	-prof -auto-all -caf-all+        GHC-prof-options:	-auto-all -caf-all      if impl(ghc >= 7.0) && flag(llvm)         GHC-options:	-fllvm  Executable grecce     Default-language:	Haskell2010-    GHC-options:	-Wall -O2 -fno-warn-tabs-    GHC-prof-options:	-prof -auto-all -caf-all+    GHC-options:	-O2 -Wall -fno-warn-tabs     Hs-source-dirs:	src-exe     Main-is:		Main.hs +    if impl(ghc >= 7.4.1)+        GHC-prof-options:	-fprof-auto -fprof-cafs+    else+        GHC-prof-options:	-auto-all -caf-all+ -- Required for 'cabal sdist'.     Other-modules:         Grecce.CommandOptions@@ -103,12 +112,13 @@     Build-depends:         base == 4.*,         Cabal >= 1.10,+        data-default,         parallel >= 3.0,         regexchar,         regex-base,         regex-posix,-        regexdot >= 0.11.1.0,-        toolshed >= 0.16+        regexdot >= 0.12,+        toolshed >= 0.17      if flag(threaded)         GHC-options:	-threaded@@ -119,7 +129,7 @@         if flag(llvm)             GHC-options:	-fllvm -Test-Suite quickCheck+Test-Suite test     Default-language:	Haskell2010     GHC-options:	-Wall -fno-warn-tabs     Hs-source-dirs:	src-test@@ -128,14 +138,14 @@  -- Required for 'cabal sdist'.     Other-modules:-        Grecce.Test.QC.ExtendedRegExChar-        Grecce.Test.QC.MetaChar-        Grecce.Test.QC.RepeatableMetaChar+        Grecce.Test.QuickCheck.ExtendedRegExChar+        Grecce.Test.QuickCheck.MetaChar+        Grecce.Test.QuickCheck.RepeatableMetaChar      Build-depends:         base == 4.*,         QuickCheck >= 2.4,         regexchar,-        regexdot >= 0.11.1.0,-        toolshed >= 0.16+        regexdot >= 0.12,+        toolshed >= 0.17 
regexchar.spec view
@@ -22,7 +22,7 @@  Summary:	A re-implementation of egrep, using a specialisation of a polymorphic regex-engine Name:		regexchar-Version:	0.9.0.13+Version:	0.9.0.14 Release:	1 License:	GPLv3 # From '/usr/share/doc/packages/rpm/GROUPS'.@@ -36,7 +36,7 @@ Provides a POSIX extended regex-engine, specialised from an underlying polymorphic engine "regexdot", to process merely character-lists, as is typically required.  %prep-# NB: CWD has changed to %_builddir+# N.B.: CWD has changed to %_builddir echo 'package="%package", prefix="%prefix", _builddir="%_builddir", buildroot="%buildroot"' (cd $OLDPWD && cabal sdist) && tar -zxf $OLDPWD/dist/%tarBall	# Make a source-distribution & unpack it into the build-directory. cd '%package/' && cabal configure --user --prefix='%prefix' --datadir='%_datadir' --datasubdir='' --docdir='%_docdir'	# Tell cabal to use the user's personal package-database, to generate an appropriate "Paths" module, & where to place the documentation.@@ -64,6 +64,6 @@ %attr(0644, root, root)	%doc	%_mandir/man1/grecce.1.gz  %changelog-* Wed May 09 2012	Alistair Ward	<regexchar at functionalley dot eu>	0.9.0.10-1+* Wed May 09 2012	Alistair Ward	<regexchar@functionalley.eu>	0.9.0.10-1 First cut. 
src-exe/Grecce/CommandOptions.hs view
@@ -1,5 +1,5 @@ {--	Copyright (C) 2010 Dr. Alistair Ward+	Copyright (C) 2010-2015 Dr. Alistair Ward  	This program is free software: you can redistribute it and/or modify 	it under the terms of the GNU General Public License as published by@@ -45,10 +45,10 @@ 	setVerbose ) where +import qualified	Data.Default import qualified	RegExChar.ExtendedRegExChar	as ExtendedRegExChar import qualified	RegExDot.CompilationOptions import qualified	RegExDot.ExecutionOptions-import qualified	ToolShed.Defaultable import qualified	ToolShed.Options  -- | The set of command-line options; based on those provided by /egrep/.@@ -67,8 +67,8 @@ -- | An arbitrary function which transforms the supplied 'RegExDot.ExecutionOptions.ExecutionOptions'. type Transformer	= CommandOptions -> CommandOptions -instance ToolShed.Defaultable.Defaultable CommandOptions	where-	defaultValue	= ToolShed.Options.blankValue {+instance Data.Default.Default CommandOptions	where+	def = ToolShed.Options.blankValue { 		countMatches		= False, 		extendedRegExChar	= Nothing, 		invertMatch		= False,@@ -76,8 +76,8 @@ 		listFilesWithMatches	= False, 		listFilesWithoutMatch	= False, 		verbose			= False,-		compilationOptions	= ToolShed.Defaultable.defaultValue,-		executionOptions	= ToolShed.Defaultable.defaultValue+		compilationOptions	= Data.Default.def,+		executionOptions	= Data.Default.def 	}  instance ToolShed.Options.Options CommandOptions	where
src-exe/Grecce/Test/Performance/ExtendedRegEx.hs view
@@ -53,6 +53,7 @@  import qualified	Control.Arrow import			Control.Arrow((&&&))+import qualified	Data.Default import qualified	Data.Maybe import qualified	Grecce.Test.Performance.ExtendedRegExTest		as Test.Performance.ExtendedRegExTest import qualified	Grecce.Test.Performance.ExtendedRegExTestsNegative	as Test.Performance.ExtendedRegExTestsNegative@@ -62,10 +63,9 @@ import qualified	RegExDot.RegEx import qualified	RegExDot.RegExOpts import qualified	Text.Regex.Posix-import qualified	ToolShed.Defaultable import qualified	ToolShed.System.TimePure -#if !MIN_VERSION_base(4,8,0)+#if !defined(MIN_VERSION_base) || !MIN_VERSION_base(4,8,0) import	Control.Applicative((<$>), (<*>)) #endif @@ -102,7 +102,7 @@ 			( 				\extendedRegEx -> ( 					RegExDot.RegEx./~ RegExDot.RegExOpts.MkRegExOpts {	-- CAVEAT: <http://hackage.haskell.org/trac/haskell-prime/wiki/QualifiedOperators>.-						RegExDot.RegExOpts.compilationOptions	= ToolShed.Defaultable.defaultValue,+						RegExDot.RegExOpts.compilationOptions	= Data.Default.def, 						RegExDot.RegExOpts.executionOptions	= executionOptions, 						RegExDot.RegExOpts.regEx		= extendedRegEx 					}@@ -136,7 +136,7 @@ 				\extendedRegEx -> let 					regExOpts :: RegExDot.RegExOpts.RegExOpts (RegExDot.RegEx.ExtendedRegEx Char) 					regExOpts	= RegExDot.RegExOpts.MkRegExOpts {-						RegExDot.RegExOpts.compilationOptions	= ToolShed.Defaultable.defaultValue,+						RegExDot.RegExOpts.compilationOptions	= Data.Default.def, 						RegExDot.RegExOpts.executionOptions	= executionOptions, 						RegExDot.RegExOpts.regEx		= extendedRegEx 					} -- Similar to 'RegexLike.makeRegexOpts', but without the requirement to read the regex.
src-exe/Grecce/Test/Performance/ExtendedRegExTestsPositive.hs view
@@ -321,7 +321,7 @@ {- | 	* The sum of the sequence descending from the specified integer; @n + (n - 1) + (n - 2) + ... + 2 + 1 + 0@. -	* <http://en.wikipedia.org/wiki/Triangular_number>.+	* <https://en.wikipedia.org/wiki/Triangular_number>.  	* <http://mathworld.wolfram.com/TriangularNumber.html>. -}
src-exe/Main.hs view
@@ -30,6 +30,7 @@  module Main(main) where +import qualified	Data.Default import qualified	Data.List import qualified	Data.Version import qualified	Distribution.Package@@ -50,7 +51,6 @@ import qualified	System.Info import qualified	System.IO import qualified	System.IO.Error-import qualified	ToolShed.Defaultable  -- | Used to thread user-defined command-line options, though the list of functions which implement them. type CommandLineAction	= CommandOptions.CommandOptions -> IO CommandOptions.CommandOptions	-- Supplied as the type-argument to 'G.OptDescr'.@@ -83,13 +83,13 @@ 		optDescrList	= [ --				 String	[String]					(G.ArgDescr CommandLineAction)							String 			G.Option "?"	["help"]					(G.NoArg $ const printUsage)							"Output:\tdisplay this help-text & then exit.",-			G.Option ""	["verbose"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setVerbose)			("Output:\tsee how the input data was captured by the RegEx; default '" ++ show (CommandOptions.verbose ToolShed.Defaultable.defaultValue) ++ "'. CAVEAT: to be effective, it should precede other options."),+			G.Option ""	["verbose"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setVerbose)			("Output:\tsee how the input data was captured by the RegEx; default '" ++ show (CommandOptions.verbose Data.Default.def) ++ "'. CAVEAT: to be effective, it should precede other options."), 			G.Option ""	["version"]					(G.NoArg $ const printVersion)							"Output:\tprint version-information & then exit.",-			G.Option "c"	["count"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setCountMatches)		("Output:\tprint only a count of matching lines per file; default '" ++ show (CommandOptions.countMatches ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option "l"	["files-with-matches"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setListFilesWithMatches)	("Output:\tlist names of files containing at least one match; default '" ++ show (CommandOptions.listFilesWithMatches ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option "L"	["files-without-match"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setListFilesWithoutMatch)	("Output:\tlist names of files not containing any matches; default '" ++ show (CommandOptions.listFilesWithoutMatch ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option "n"	["number"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setPrependLineNumbers)	("Output:\tprepend the line-number of the input, to the output; default '" ++ show (CommandOptions.prependLineNumbers ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option "v"	["invert-match"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setInvertMatch)		("Output:\tselect non-matching lines; default '" ++ show (CommandOptions.invertMatch ToolShed.Defaultable.defaultValue) ++ "'."),+			G.Option "c"	["count"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setCountMatches)		("Output:\tprint only a count of matching lines per file; default '" ++ show (CommandOptions.countMatches Data.Default.def) ++ "'."),+			G.Option "l"	["files-with-matches"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setListFilesWithMatches)	("Output:\tlist names of files containing at least one match; default '" ++ show (CommandOptions.listFilesWithMatches Data.Default.def) ++ "'."),+			G.Option "L"	["files-without-match"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setListFilesWithoutMatch)	("Output:\tlist names of files not containing any matches; default '" ++ show (CommandOptions.listFilesWithoutMatch Data.Default.def) ++ "'."),+			G.Option "n"	["number"]					(G.NoArg $ return {-to IO-monad-} . CommandOptions.setPrependLineNumbers)	("Output:\tprepend the line-number of the input, to the output; default '" ++ show (CommandOptions.prependLineNumbers Data.Default.def) ++ "'."),+			G.Option "v"	["invert-match"]				(G.NoArg $ return {-to IO-monad-} . CommandOptions.setInvertMatch)		("Output:\tselect non-matching lines; default '" ++ show (CommandOptions.invertMatch Data.Default.def) ++ "'."), 			G.Option ""	["printCurrentSettings"]			(G.NoArg printCurrentSettings)							"Output:\tdisplay the currently defined options & then exit.", 			G.Option "e"	["regex"]					(setExtendedRegExChar `G.ReqArg` "<regex>")					"Input:\tdefine the regex.", 			G.Option "f"	["file"]					(readExtendedRegExCharFromFile `G.ReqArg` "<file-name>")			"Input:\tread the regex from file.",@@ -100,25 +100,25 @@ 					minBound :: Test.Performance.ExtendedRegExTestsNegative.TestName .. maxBound 				] ++ " or Right " ++ show [ 					minBound :: Test.Performance.ExtendedRegExTestsPositive.TestName .. maxBound-				] ++ "). NB: specify this option last."+				] ++ "). N.B.: specify this option last." 			),-			G.Option ""	["assert"]					(assertFromFile `G.ReqArg` "<file-name>")					"Test:\trun the assertions, defined in the specified file, & then exit. NB: specify this option last.",-			G.Option ""	["assertPosix"]					(assertPosixFromFile `G.ReqArg` "<file-name>")					"Test:\trun the assertions, defined in the specified file, against Text.Regex.Posix, & then exit. NB: specify this option last.",-			G.Option ""	["abortTrialRepetitionsOnInherentFailure"]	(setExecutionOption abortTrialRepetitionsOnInherentFailure `G.ReqArg` "Bool")	("Performance:\tif an alternative can't match, irrespective of the subsequent concatenation, then terminate futile trial repetitions; default '" ++ show (RegExDot.ExecutionOptions.abortTrialRepetitionsOnInherentFailure ToolShed.Defaultable.defaultValue) ++ "'."),---			G.Option ""	["abortTrialRepetitionsOnZeroConsumption"]	(setExecutionOption abortTrialRepetitionsOnZeroConsumption `G.ReqArg` "Bool")	("Performance:\tcheck for zero data-consumption by the n-th repetition of an alternative, before considering (n + 1); default '" ++ show (RegExDot.ExecutionOptions.abortTrialRepetitionsOnZeroConsumption ToolShed.Defaultable.defaultValue) ++ "'."),---			G.Option ""	["bypassInputDataForLiberalConsumer"]		(setExecutionOption bypassInputDataForLiberalConsumer `G.ReqArg` "Bool")	("Performance:\tbypass reading of the unconsumed input data, if the remaining RegEx can consume a sufficient quantity of anything; default '" ++ show (RegExDot.ExecutionOptions.bypassInputDataForLiberalConsumer ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["catchIncompatibleAnchors"]			(setExecutionOption catchIncompatibleAnchors `G.ReqArg` "Bool")			("Performance:\tavoid futile trial solutions, involving repetitions of anchored alternatives, which must consume data; default '" ++ show (RegExDot.ExecutionOptions.catchIncompatibleAnchors ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["checkExistenceOfInelasticTail"]		(setExecutionOption checkExistenceOfInelasticTail `G.ReqArg` "Bool")		("Performance:\tif the regex ends in one or more Meta-data, whose repetition-range is precisely defined, check that this sequence exists at the end of the input data; default '" ++ show (RegExDot.ExecutionOptions.checkExistenceOfInelasticTail ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["checkForUnconsumableData"]			(setExecutionOption checkForUnconsumableData `G.ReqArg` "Bool")			("Performance:\tcheck whether there's no possibility of consuming some of the input data; default '" ++ show (RegExDot.ExecutionOptions.checkForUnconsumableData ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["moderateGreed"]				(setExecutionOption moderateGreed `G.ReqArg` "Bool")				("Performance:\tgreedily consume data, only up to the limit beyond which, future requirements would be compromised; default '" ++ show (RegExDot.ExecutionOptions.moderateGreed ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["permitReorderingOfAlternatives"]		(setExecutionOption permitReorderingOfAlternatives `G.ReqArg` "Bool")		("Performance:\tpermit alternatives to be re-ordered, in an attempt to process the cheapest first; default '" ++ show (RegExDot.ExecutionOptions.permitReorderingOfAlternatives ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["preferAlternativesWhichFeedTheGreedy"]	(setExecutionOption preferAlternativesWhichFeedTheGreedy `G.ReqArg` "Bool")	("Preference:\tprefer solutions in which the choice of alternatives directs data from non-greedy to greedy consumers; default '" ++ show (RegExDot.ExecutionOptions.preferAlternativesWhichFeedTheGreedy ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["preferAlternativesWhichMimickUnrolling"]	(setExecutionOption preferAlternativesWhichMimickUnrolling `G.ReqArg` "Bool")	("Preference:\tprefer solutions in which the choice of alternatives consumes data like the unrolled repeatable group; default '" ++ show (RegExDot.ExecutionOptions.preferAlternativesWhichMimickUnrolling ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["preferFewerRepeatedAlternatives"]		(setExecutionOption preferFewerRepeatedAlternatives `G.ReqArg` "Bool")		("Preference:\tprefer solutions employing fewer repetitions of alternatives, to discourage the capture of null lists; default '" ++ show (RegExDot.ExecutionOptions.preferFewerRepeatedAlternatives ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["unrollRepeatedSingletonAlternative"]		(setExecutionOption unrollRepeatedSingletonAlternative `G.ReqArg` "Bool")	("Performance:\tunroll repetitions of singleton alternatives; this doesn't affect the result; default '" ++ show (RegExDot.ExecutionOptions.unrollRepeatedSingletonAlternative ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["useFirstMatchAmongAlternatives"]		(setExecutionOption useFirstMatchAmongAlternatives `G.ReqArg` "Bool")		("Performance:\trather than performing an exhaustive search for the optimal choice amongst alternatives, merely select the first that matches; conform to Perl rather than Posix; default '" ++ show (RegExDot.ExecutionOptions.useFirstMatchAmongAlternatives ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["validateMinConsumptionOfAlternatives"]	(setExecutionOption validateMinConsumptionOfAlternatives `G.ReqArg` "Bool")	("Performance:\twhen the number of repetitions of a group of alternatives is precisely specified, check the availability of the resulting minimum data-requirement; default '" ++ show (RegExDot.ExecutionOptions.validateMinConsumptionOfAlternatives ToolShed.Defaultable.defaultValue) ++ "'."),-			G.Option ""	["complyStrictlyWithPosix"]			(setCompilationOption complyStrictlyWithPosix `G.ReqArg` "Bool")		("Output:\tdefine the offset of captured data, corresponding to a sub-expression which matched zero times, as the artificial value -1 specified by Posix; currently only affects results of 'assert'; default '" ++ show (RegExDot.CompilationOptions.complyStrictlyWithPosix ToolShed.Defaultable.defaultValue) ++ "'.")+			G.Option ""	["assert"]					(assertFromFile `G.ReqArg` "<file-name>")					"Test:\trun the assertions, defined in the specified file, & then exit. N.B.: specify this option last.",+			G.Option ""	["assertPosix"]					(assertPosixFromFile `G.ReqArg` "<file-name>")					"Test:\trun the assertions, defined in the specified file, against Text.Regex.Posix, & then exit. N.B.: specify this option last.",+			G.Option ""	["abortTrialRepetitionsOnInherentFailure"]	(setExecutionOption abortTrialRepetitionsOnInherentFailure `G.ReqArg` "Bool")	("Performance:\tif an alternative can't match, irrespective of the subsequent concatenation, then terminate futile trial repetitions; default '" ++ show (RegExDot.ExecutionOptions.abortTrialRepetitionsOnInherentFailure Data.Default.def) ++ "'."),+--			G.Option ""	["abortTrialRepetitionsOnZeroConsumption"]	(setExecutionOption abortTrialRepetitionsOnZeroConsumption `G.ReqArg` "Bool")	("Performance:\tcheck for zero data-consumption by the n-th repetition of an alternative, before considering (n + 1); default '" ++ show (RegExDot.ExecutionOptions.abortTrialRepetitionsOnZeroConsumption Data.Default.def) ++ "'."),+--			G.Option ""	["bypassInputDataForLiberalConsumer"]		(setExecutionOption bypassInputDataForLiberalConsumer `G.ReqArg` "Bool")	("Performance:\tbypass reading of the unconsumed input data, if the remaining RegEx can consume a sufficient quantity of anything; default '" ++ show (RegExDot.ExecutionOptions.bypassInputDataForLiberalConsumer Data.Default.def) ++ "'."),+			G.Option ""	["catchIncompatibleAnchors"]			(setExecutionOption catchIncompatibleAnchors `G.ReqArg` "Bool")			("Performance:\tavoid futile trial solutions, involving repetitions of anchored alternatives, which must consume data; default '" ++ show (RegExDot.ExecutionOptions.catchIncompatibleAnchors Data.Default.def) ++ "'."),+			G.Option ""	["checkExistenceOfInelasticTail"]		(setExecutionOption checkExistenceOfInelasticTail `G.ReqArg` "Bool")		("Performance:\tif the regex ends in one or more Meta-data, whose repetition-range is precisely defined, check that this sequence exists at the end of the input data; default '" ++ show (RegExDot.ExecutionOptions.checkExistenceOfInelasticTail Data.Default.def) ++ "'."),+			G.Option ""	["checkForUnconsumableData"]			(setExecutionOption checkForUnconsumableData `G.ReqArg` "Bool")			("Performance:\tcheck whether there's no possibility of consuming some of the input data; default '" ++ show (RegExDot.ExecutionOptions.checkForUnconsumableData Data.Default.def) ++ "'."),+			G.Option ""	["moderateGreed"]				(setExecutionOption moderateGreed `G.ReqArg` "Bool")				("Performance:\tgreedily consume data, only up to the limit beyond which, future requirements would be compromised; default '" ++ show (RegExDot.ExecutionOptions.moderateGreed Data.Default.def) ++ "'."),+			G.Option ""	["permitReorderingOfAlternatives"]		(setExecutionOption permitReorderingOfAlternatives `G.ReqArg` "Bool")		("Performance:\tpermit alternatives to be re-ordered, in an attempt to process the cheapest first; default '" ++ show (RegExDot.ExecutionOptions.permitReorderingOfAlternatives Data.Default.def) ++ "'."),+			G.Option ""	["preferAlternativesWhichFeedTheGreedy"]	(setExecutionOption preferAlternativesWhichFeedTheGreedy `G.ReqArg` "Bool")	("Preference:\tprefer solutions in which the choice of alternatives directs data from non-greedy to greedy consumers; default '" ++ show (RegExDot.ExecutionOptions.preferAlternativesWhichFeedTheGreedy Data.Default.def) ++ "'."),+			G.Option ""	["preferAlternativesWhichMimickUnrolling"]	(setExecutionOption preferAlternativesWhichMimickUnrolling `G.ReqArg` "Bool")	("Preference:\tprefer solutions in which the choice of alternatives consumes data like the unrolled repeatable group; default '" ++ show (RegExDot.ExecutionOptions.preferAlternativesWhichMimickUnrolling Data.Default.def) ++ "'."),+			G.Option ""	["preferFewerRepeatedAlternatives"]		(setExecutionOption preferFewerRepeatedAlternatives `G.ReqArg` "Bool")		("Preference:\tprefer solutions employing fewer repetitions of alternatives, to discourage the capture of null lists; default '" ++ show (RegExDot.ExecutionOptions.preferFewerRepeatedAlternatives Data.Default.def) ++ "'."),+			G.Option ""	["unrollRepeatedSingletonAlternative"]		(setExecutionOption unrollRepeatedSingletonAlternative `G.ReqArg` "Bool")	("Performance:\tunroll repetitions of singleton alternatives; this doesn't affect the result; default '" ++ show (RegExDot.ExecutionOptions.unrollRepeatedSingletonAlternative Data.Default.def) ++ "'."),+			G.Option ""	["useFirstMatchAmongAlternatives"]		(setExecutionOption useFirstMatchAmongAlternatives `G.ReqArg` "Bool")		("Performance:\trather than performing an exhaustive search for the optimal choice amongst alternatives, merely select the first that matches; conform to Perl rather than Posix; default '" ++ show (RegExDot.ExecutionOptions.useFirstMatchAmongAlternatives Data.Default.def) ++ "'."),+			G.Option ""	["validateMinConsumptionOfAlternatives"]	(setExecutionOption validateMinConsumptionOfAlternatives `G.ReqArg` "Bool")	("Performance:\twhen the number of repetitions of a group of alternatives is precisely specified, check the availability of the resulting minimum data-requirement; default '" ++ show (RegExDot.ExecutionOptions.validateMinConsumptionOfAlternatives Data.Default.def) ++ "'."),+			G.Option ""	["complyStrictlyWithPosix"]			(setCompilationOption complyStrictlyWithPosix `G.ReqArg` "Bool")		("Output:\tdefine the offset of captured data, corresponding to a sub-expression which matched zero times, as the artificial value -1 specified by Posix; currently only affects results of 'assert'; default '" ++ show (RegExDot.CompilationOptions.complyStrictlyWithPosix Data.Default.def) ++ "'.") 		 ] where 			printVersion, printUsage :: IO CommandOptions.CommandOptions @@ -168,7 +168,7 @@ 						System.Exit.exitWith $ System.Exit.ExitFailure 2  			setExtendedRegExChar s commandOptions	= case CommandOptions.extendedRegExChar commandOptions of-				Just extendedRegExChar	-> fail $ "The regex has already been defined as /" ++ show extendedRegExChar ++ "/"+				Just extendedRegExChar	-> error $ "The regex has already been defined as /" ++ show extendedRegExChar ++ "/." 				_			-> return {-to IO-monad-} commandOptions { CommandOptions.extendedRegExChar = Just $ readCommandArg s }  			abortTrialRepetitionsOnInherentFailure, {-abortTrialRepetitionsOnZeroConsumption, bypassInputDataForLiberalConsumer,-} catchIncompatibleAnchors, checkExistenceOfInelasticTail, checkForUnconsumableData, moderateGreed, permitReorderingOfAlternatives, preferAlternativesWhichFeedTheGreedy, preferAlternativesWhichMimickUnrolling, preferFewerRepeatedAlternatives, unrollRepeatedSingletonAlternative, useFirstMatchAmongAlternatives, validateMinConsumptionOfAlternatives :: CommandOptions.ExecutionOptionsMutator@@ -201,7 +201,7 @@ --	G.getOpt :: G.ArgOrder CommandLineAction -> [G.OptDescr Action] -> [String] -> ([Action], [String], [String]) 	case G.getOpt G.RequireOrder optDescrList args of 		(commandLineActions, nonOptions, [])	-> do-			commandOptions	<- Data.List.foldl' (>>=) (return {-to IO-monad-} ToolShed.Defaultable.defaultValue) commandLineActions	-- Sequentially transform the 'CommandOptions', using 'CommandLineAction's corresponding to the specified command-line flags.+			commandOptions	<- Data.List.foldl' (>>=) (return {-to IO-monad-} Data.Default.def) commandLineActions	-- Sequentially transform the 'CommandOptions', using 'CommandLineAction's corresponding to the specified command-line flags.  			Grep.grep commandOptions nonOptions	-- Perform the requested match, against the list of input-data files. 		(_, _, errors)	-> System.IO.Error.ioError . System.IO.Error.userError $ concat errors ++ usageMessage	-- Throw.
src-lib/RegExChar/ExtendedRegExChar.hs view
@@ -47,7 +47,7 @@ import qualified	ToolShed.Data.Pair import qualified	ToolShed.SelfValidate -#if !MIN_VERSION_base(4,8,0)+#if !defined(MIN_VERSION_base) || !MIN_VERSION_base(4,8,0) import	Control.Applicative((<$>), (<*>)) #endif @@ -142,12 +142,8 @@ 								return {-to ParsecT-monad-} [] 							 ] -		in (-			error . ("readsPrec RegExChar.ExtendedRegExChar:\tparse-error; " ++) . show	-- Failure to parse.-		) `either` (-			\pair@(extendedRegExChar, _)	-> if ToolShed.SelfValidate.isValid extendedRegExChar-				then [pair]-				else error $ ToolShed.SelfValidate.getFirstError extendedRegExChar	-- Parsed OK, but invalid.+		in const [] `either` (+			\pair@(extendedRegExChar, _)	-> [pair | ToolShed.SelfValidate.isValid extendedRegExChar] 		) $ Parsec.parse ( 			(,) <$> extendedRegExCharParser <*> Parsec.getInput 		) "ExtendedRegExChar" s@@ -160,7 +156,7 @@ 			RegExDot.RegEx.concatenation	= concatenation', 			RegExDot.RegEx.sternAnchor	= maybeSternAnchor 		}-	} = RegExDot.RegEx.showsMaybeAnchor maybeBowAnchor . foldl (.) (showString "") (+	} = RegExDot.RegEx.showsMaybeAnchor maybeBowAnchor . foldl (.) id ( 		( 			let 				showAlternatives :: RegExDot.RegEx.Alternatives Char -> [ShowS]@@ -168,7 +164,7 @@ 			in if hasNonCapturingTopLevelAlternatives' 				then map ( 					\repeatablePattern	-> case RegExDot.Repeatable.base repeatablePattern of-						RegExDot.RegEx.CaptureGroup alternatives	-> foldr (.) (showString "") $ showAlternatives alternatives+						RegExDot.RegEx.CaptureGroup alternatives	-> foldr (.) id $ showAlternatives alternatives 						_						-> error $ "Show RegExChar.ExtendedRegExChar: unexpected " ++ show repeatablePattern 				) 				else map (
src-lib/RegExChar/MetaChar.hs view
@@ -50,15 +50,16 @@ --	AssociationList, --	Dictionary, -- ** Type-synonyms-	MetaChar(..),+	MetaChar(+		MkMetaChar,+		deconstruct+	), -- * Constants --	bracketExpressionRangeToken, --	posixCharacterClassDelimiters, -- * Functions --	implementPerlShortcut,-	metaCharParser,--- ** Accessors (Deconstructors)-	deconstruct+	metaCharParser ) where  import			Control.Arrow((***))@@ -76,7 +77,7 @@ import qualified	ToolShed.Data.Pair import qualified	ToolShed.SelfValidate -#if !MIN_VERSION_base(4,8,0)+#if !defined(MIN_VERSION_base) || !MIN_VERSION_base(4,8,0) import	Control.Applicative((<$>), (<*>)) #endif @@ -106,11 +107,9 @@ 		_			-> RegExDot.Meta.Literal c  -- | A specialised instance, encapsulated to permit tailored instance-declarations.-newtype MetaChar	= MkMetaChar (RegExDot.Meta.Meta Char)	deriving Eq---- | Accessor.-deconstruct :: MetaChar -> RegExDot.Meta.Meta Char-deconstruct (MkMetaChar metaChar)	= metaChar+newtype MetaChar	= MkMetaChar {+	deconstruct	:: RegExDot.Meta.Meta Char+} deriving Eq  instance ToolShed.SelfValidate.SelfValidator MetaChar	where 	getErrors	= ToolShed.SelfValidate.getErrors . deconstruct@@ -204,7 +203,7 @@  instance Read MetaChar	where 	readsPrec _	= (-		(fail . ("readsPrec RegExChar.MetaChar:\tparse-error; " ++) . show) `either` return+		(error . showString "RegExChar.MetaChar.readsPrec:\tparse-error; " . show) `either` return 	 ) . Parsec.parse ( 		(,) <$> metaCharParser <*> Parsec.getInput 	 ) "MetaChar"
src-lib/RegExChar/RegExOptsChar.hs view
@@ -50,6 +50,7 @@ ) where  import qualified	Data.Array.IArray+import qualified	Data.Default import qualified	RegExChar.ExtendedRegExChar	as ExtendedRegExChar import qualified	RegExDot.CompilationOptions import qualified	RegExDot.ConsumptionBounds@@ -63,7 +64,6 @@ import qualified	Text.Regex.Base.RegexLike	as RegexLike import			Text.Regex.Base.Context()	-- Instance-declarations. import qualified	ToolShed.Data.List-import qualified	ToolShed.Defaultable import qualified	ToolShed.Options  infix 4 =~	-- Same as (==).@@ -82,8 +82,8 @@ instance RegexLike.RegexOptions RegExOptsChar RegExDot.CompilationOptions.CompilationOptions RegExDot.ExecutionOptions.ExecutionOptions	where 	blankCompOpt	= ToolShed.Options.blankValue 	blankExecOpt	= ToolShed.Options.blankValue-	defaultCompOpt	= ToolShed.Defaultable.defaultValue-	defaultExecOpt	= ToolShed.Defaultable.defaultValue+	defaultCompOpt	= Data.Default.def+	defaultExecOpt	= Data.Default.def 	setExecOpts e r	= r { RegExDot.RegExOpts.executionOptions = e } 	getExecOpts	= RegExDot.RegExOpts.executionOptions 
− src-test/Grecce/Test/QC/ExtendedRegExChar.hs
@@ -1,192 +0,0 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}-{--	Copyright (C) 2010-2015 Dr. Alistair Ward--	This program is free software: you can redistribute it and/or modify-	it under the terms of the GNU General Public License as published by-	the Free Software Foundation, either version 3 of the License, or-	(at your option) any later version.--	This program is distributed in the hope that it will be useful,-	but WITHOUT ANY WARRANTY; without even the implied warranty of-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the-	GNU General Public License for more details.--	You should have received a copy of the GNU General Public License-	along with this program.  If not, see <http://www.gnu.org/licenses/>.--}-{- |- [@AUTHOR@]	Dr. Alistair Ward-- [@DESCRIPTION@]	Implements 'Test.QuickCheck.Arbitrary' & defines tests based on it.--}--module Grecce.Test.QC.ExtendedRegExChar(--- * Constants-	results,--- * Types--- ** Data-types---	AlternativesChar(..),---	PatternChar(..),---	RepeatablePatternChar(..),--- * Functions--- ** Accessors---	deconstructAlternativesChar,---	deconstructPatternChar,---	deconstructRepeatablePatternChar-) where--import qualified	Data.Maybe-import			Grecce.Test.QC.MetaChar()-import qualified	RegExChar.ExtendedRegExChar	as ExtendedRegExChar	-- CAVEAT: beware of the similar name.-import qualified	RegExChar.MetaChar		as MetaChar-import qualified	RegExDot.Anchor-import qualified	RegExDot.BracketExpressionMember-import qualified	RegExDot.Consumer-import qualified	RegExDot.ConsumptionBounds-import qualified	RegExDot.ConsumptionProfile-import			RegExDot.DSL((-:), (?:), (+:), (<~>))-import qualified	RegExDot.Meta-import qualified	RegExDot.RegEx-import			RegExDot.RegEx((+~))-import qualified	RegExDot.RegExOpts-import qualified	RegExDot.Repeatable-import qualified	RegExDot.Result-import qualified	Test.QuickCheck-import			Test.QuickCheck((==>))-import qualified	ToolShed.SelfValidate-import qualified	ToolShed.Test.ReversibleIO---- | A specialised instance, required to instantiate 'Test.QuickCheck.Arbitrary'.-newtype AlternativesChar	= MkAlternativesChar (RegExDot.RegEx.Alternatives Char) deriving (Eq, Read, Show)---- | Accessor.-deconstructAlternativesChar :: AlternativesChar -> RegExDot.RegEx.Alternatives Char-deconstructAlternativesChar (MkAlternativesChar a)	= a--instance ToolShed.SelfValidate.SelfValidator AlternativesChar where-	getErrors	= ToolShed.SelfValidate.getErrors . deconstructAlternativesChar--instance RegExDot.Consumer.Consumer AlternativesChar where-	consumptionProfile	= RegExDot.Consumer.consumptionProfile . deconstructAlternativesChar-	starHeight		= RegExDot.Consumer.starHeight . deconstructAlternativesChar--instance Test.QuickCheck.Arbitrary AlternativesChar	where-	arbitrary	= (MkAlternativesChar . RegExDot.RegEx.MkAlternatives . map ExtendedRegExChar.extendedRegEx) `fmap` (-		Test.QuickCheck.elements [1, 2]	>>= Test.QuickCheck.vector {-[ExtendedRegExChar]-}-	 ) -- TODO: permit zero alternatives.---- | A specialised instance, required to instantiate 'Test.QuickCheck.Arbitrary'.-newtype PatternChar	= MkPatternChar (RegExDot.RegEx.Pattern Char) deriving (Eq, Read, Show)---- | Accessor.-deconstructPatternChar :: PatternChar -> RegExDot.RegEx.Pattern Char-deconstructPatternChar (MkPatternChar pattern)	= pattern--instance ToolShed.SelfValidate.SelfValidator PatternChar	where-	getErrors	= ToolShed.SelfValidate.getErrors . deconstructPatternChar--instance RegExDot.Consumer.Consumer PatternChar	where-	consumptionProfile	= RegExDot.Consumer.consumptionProfile . deconstructPatternChar-	starHeight		= RegExDot.Consumer.starHeight . deconstructPatternChar--instance Test.QuickCheck.Arbitrary PatternChar	where-	arbitrary	= MkPatternChar `fmap` Test.QuickCheck.frequency [-		(4,	(RegExDot.RegEx.Require . MetaChar.deconstruct) `fmap` Test.QuickCheck.arbitrary {-MetaChar-}),-		(1,	(RegExDot.RegEx.CaptureGroup . deconstructAlternativesChar) `fmap` Test.QuickCheck.arbitrary {-AlternativesChar-})-	 ] -- CAVEAT: may recurse forever if 'RegExDot.RegEx.CaptureGroup / RegExDot.RegEx.Require' is too high.---- | A specialised instance, required to instantiate 'Test.QuickCheck.Arbitrary'.-newtype RepeatablePatternChar	= MkRepeatablePatternChar (RegExDot.Repeatable.Repeatable PatternChar)	deriving (Eq, Read, Show)---- | Accessor.-deconstructRepeatablePatternChar :: RepeatablePatternChar -> RegExDot.Repeatable.Repeatable PatternChar-deconstructRepeatablePatternChar (MkRepeatablePatternChar repeatable)	= repeatable--instance ToolShed.SelfValidate.SelfValidator RepeatablePatternChar	where-	getErrors	= ToolShed.SelfValidate.getErrors . deconstructRepeatablePatternChar--instance RegExDot.Consumer.Consumer RepeatablePatternChar	where-	consumptionProfile	= RegExDot.Consumer.consumptionProfile . deconstructRepeatablePatternChar-	starHeight		= RegExDot.Consumer.starHeight . deconstructRepeatablePatternChar--instance Test.QuickCheck.Arbitrary RepeatablePatternChar	where-	arbitrary	= do-		patternChar	<- Test.QuickCheck.arbitrary-		fewest		<- Test.QuickCheck.elements [0 .. 9]	-- Could be more, but this is an adequate test.-		most		<- Test.QuickCheck.oneof [return {-to Gen-monad-} Nothing, Just `fmap` Test.QuickCheck.elements [max fewest 1 .. 9]]-		isGreedy	<- Test.QuickCheck.arbitrary {-Bool-}--		let-			repetitionBounds :: RegExDot.Repeatable.RepetitionBounds-			repetitionBounds	= (fewest, most)--		return {-to Gen-monad-} $ MkRepeatablePatternChar RegExDot.Repeatable.MkRepeatable {-			RegExDot.Repeatable.base		= patternChar,-			RegExDot.Repeatable.repetitionBounds	= repetitionBounds,-			RegExDot.Repeatable.isGreedy		= RegExDot.Repeatable.hasPreciseBounds repetitionBounds || isGreedy	-- Only specify non-greedy where space exists.-		}--instance Test.QuickCheck.Arbitrary ExtendedRegExChar.ExtendedRegExChar	where-	arbitrary	= do-		hasBowAnchor	<- Test.QuickCheck.arbitrary {-Bool-}-		concatenation	<- map (fmap deconstructPatternChar {-replace base-} . deconstructRepeatablePatternChar {-RegExDot.Repeatable.Repeatable PatternChar-}) `fmap` Test.QuickCheck.vector 2 {-[RepeatablePatternChar]-}-		hasSternAnchor	<- Test.QuickCheck.arbitrary {-Bool-}--		return {-to Gen-monad-} $ ExtendedRegExChar.MkExtendedRegExChar False RegExDot.RegEx.MkExtendedRegEx {-			RegExDot.RegEx.bowAnchor	= if hasBowAnchor then Just RegExDot.Anchor.Bow else Nothing,-			RegExDot.RegEx.concatenation	= concatenation,-			RegExDot.RegEx.sternAnchor	= if hasSternAnchor then Just RegExDot.Anchor.Stern else Nothing-		}---- | The constant test-results for this data-type.-results :: IO [Test.QuickCheck.Result]-results	= sequence [-	Test.QuickCheck.quickCheckResult prop_consumptionProfile,-	Test.QuickCheck.quickCheckResult prop_consumptionProfile2,-	Test.QuickCheck.quickCheckResult prop_io,-	Test.QuickCheck.quickCheckResult prop_io',-	Test.QuickCheck.quickCheckResult prop_isValid,-	Test.QuickCheck.quickCheckResult prop_starHeight,-	Test.QuickCheck.quickCheckResult prop_double- ] where-		prop_consumptionProfile, prop_consumptionProfile2, prop_io, prop_io', prop_isValid, prop_starHeight :: ExtendedRegExChar.ExtendedRegExChar -> Test.QuickCheck.Property-		prop_consumptionProfile r	= Test.QuickCheck.label "prop_consumptionProfile" $ Data.Maybe.maybe True (>= minData) maybeMaxData && (-			not b == all (not . RegExDot.Consumer.getHasSpecificRequirement) (RegExDot.RegEx.concatenation $ ExtendedRegExChar.extendedRegEx r)-		 )-			where-				RegExDot.ConsumptionProfile.MkConsumptionProfile {-					RegExDot.ConsumptionProfile.consumptionBounds		= (minData, maybeMaxData),-					RegExDot.ConsumptionProfile.hasSpecificRequirement	= b-				} = RegExDot.Consumer.consumptionProfile r--		prop_consumptionProfile2 r	= RegExDot.RegEx.isDefined (ExtendedRegExChar.extendedRegEx r)	==> Test.QuickCheck.label "prop_consumptionProfile2" $ hasSpecificRequirement || canConsumeAnything	-- There's either; a requirement for at least one specific, or we can consume at least one arbitrary; input datum.-			where-				RegExDot.ConsumptionProfile.MkConsumptionProfile {-					RegExDot.ConsumptionProfile.hasSpecificRequirement	= hasSpecificRequirement,-					RegExDot.ConsumptionProfile.canConsumeAnything		= canConsumeAnything-				} = RegExDot.Consumer.consumptionProfile r--		prop_io			= Test.QuickCheck.label "prop_io" . ToolShed.Test.ReversibleIO.isReversible-		prop_io' r		= Test.QuickCheck.label "prop_io'" $ ToolShed.Test.ReversibleIO.isReversible r'	where r' = ExtendedRegExChar.extendedRegEx r	-- Check "RegExDot.RegEx.ExtendedRegEx Char" too.-		prop_isValid r		= Test.QuickCheck.label "prop_isValid" $ ToolShed.SelfValidate.isValid r-		prop_starHeight r	= Test.QuickCheck.label "prop_starHeight" $ (RegExDot.Consumer.starHeight r == 0) == RegExDot.ConsumptionBounds.isPrecise (RegExDot.Consumer.getConsumptionBounds r)--		prop_double :: Double -> Test.QuickCheck.Property-		prop_double d	= Test.QuickCheck.label "prop_double" $ RegExDot.RegEx.extractDataFromMatchList `fmap` RegExDot.Result.getMatchList result == Just s	where-			s :: String-			s	= show $ d * 1e6	-- Implementation of show, uses exponential notation, when the number is large.--			result :: RegExDot.RegEx.Result Char-			result = s +~ RegExDot.RegExOpts.mkRegEx (-				(Just RegExDot.Anchor.Bow, Just RegExDot.Anchor.Stern) <~> sign ?: digits +: map (-					RegExDot.Repeatable.zeroOrOne . RegExDot.RegEx.captureGroup . map (RegExDot.Anchor.unanchored <~>) . return {-to List-monad-}-				) [-					RegExDot.RegEx.Require (RegExDot.Meta.Literal '.') -: digits +: [],-					RegExDot.RegEx.Require (RegExDot.Meta.AnyOf $ map RegExDot.BracketExpressionMember.Literal "eE") -: sign ?: digits +: []-				]-			 ) where-				sign, digits :: RegExDot.RegEx.Pattern Char-				sign	= RegExDot.RegEx.Require . RegExDot.Meta.AnyOf $ map RegExDot.BracketExpressionMember.Literal "+-"-				digits	= RegExDot.RegEx.Require . RegExDot.Meta.AnyOf $ map RegExDot.BracketExpressionMember.Literal ['0' .. '9']-
− src-test/Grecce/Test/QC/MetaChar.hs
@@ -1,66 +0,0 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}-{--	Copyright (C) 2010-2015 Dr. Alistair Ward--	This program is free software: you can redistribute it and/or modify-	it under the terms of the GNU General Public License as published by-	the Free Software Foundation, either version 3 of the License, or-	(at your option) any later version.--	This program is distributed in the hope that it will be useful,-	but WITHOUT ANY WARRANTY; without even the implied warranty of-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the-	GNU General Public License for more details.--	You should have received a copy of the GNU General Public License-	along with this program.  If not, see <http://www.gnu.org/licenses/>.--}-{- |- [@AUTHOR@]	Dr. Alistair Ward-- [@DESCRIPTION@]	Implements 'Test.QuickCheck.Arbitrary' & defines tests based on it.-- [@TODO@]	Test /Perl-style shortcuts/ & /Posix Character-classes/.--}--module Grecce.Test.QC.MetaChar(--- * Constants-	results,---	testCharacters,--- * Types--- ** Type-synonyms---	Testable-) where--import qualified	Data.List-import qualified	RegExChar.MetaChar	as MetaChar	-- CAVEAT: beware of the similar name.-import qualified	RegExDot.BracketExpression-import qualified	RegExDot.BracketExpressionMember-import qualified	RegExDot.Meta-import qualified	Test.QuickCheck-import qualified	ToolShed.Test.ReversibleIO--testCharacters :: String-testCharacters	= filter (`notElem` [RegExDot.Meta.shortcutToken, RegExDot.BracketExpression.negationToken]) [' ' .. '~']	-- TODO: permit all characters.--instance Test.QuickCheck.Arbitrary MetaChar.MetaChar	where-	arbitrary	= Test.QuickCheck.oneof $ map (fmap MetaChar.MkMetaChar) [-		return {-to Gen-monad-} RegExDot.Meta.Any,-		RegExDot.Meta.Literal `fmap` Test.QuickCheck.elements testCharacters,-		(RegExDot.Meta.AnyOf . map RegExDot.BracketExpressionMember.Literal . Data.List.nub) `fmap` arbitraryCharList 1 16,	-- Test.QuickCheck.vector 16 {-Char-},-		(RegExDot.Meta.NoneOf . map RegExDot.BracketExpressionMember.Literal . Data.List.nub) `fmap` arbitraryCharList 1 4-	 ] where-		arbitraryCharList :: Int -> Int -> Test.QuickCheck.Gen String-		arbitraryCharList i j	= do-			l	<- Test.QuickCheck.arbitrary {-Int-}--			(take (min j $ i `max` l) . Data.List.nub . Data.List.filter (`elem` testCharacters)) `fmap` Test.QuickCheck.vector maxBound {-Char-}--type Testable	= MetaChar.MetaChar -> Test.QuickCheck.Property---- | The constant test-results for this data-type.-results :: IO [Test.QuickCheck.Result]-results = mapM Test.QuickCheck.quickCheckResult [prop_io]	where-	prop_io :: Testable-	prop_io	= Test.QuickCheck.label "prop_io" . ToolShed.Test.ReversibleIO.isReversible-
− src-test/Grecce/Test/QC/RepeatableMetaChar.hs
@@ -1,92 +0,0 @@-{--	Copyright (C) 2010-2015 Dr. Alistair Ward--	This program is free software: you can redistribute it and/or modify-	it under the terms of the GNU General Public License as published by-	the Free Software Foundation, either version 3 of the License, or-	(at your option) any later version.--	This program is distributed in the hope that it will be useful,-	but WITHOUT ANY WARRANTY; without even the implied warranty of-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the-	GNU General Public License for more details.--	You should have received a copy of the GNU General Public License-	along with this program.  If not, see <http://www.gnu.org/licenses/>.--}-{- |- [@AUTHOR@]	Dr. Alistair Ward-- [@DESCRIPTION@]	Implements 'Test.QuickCheck.Arbitrary' & defines tests based on it.--}--module Grecce.Test.QC.RepeatableMetaChar(--- * Constants-	results,--- * Types--- ** Data-types---	RepeatableMetaChar,--- ** Type-synonyms---	Testable,--- * Functions---	deconstruct-) where--import qualified	Data.Maybe-import			Grecce.Test.QC.MetaChar()-import qualified	RegExChar.MetaChar	as MetaChar-import qualified	RegExDot.Consumer-import qualified	RegExDot.ConsumptionBounds-import qualified	RegExDot.ConsumptionProfile-import qualified	RegExDot.Repeatable-import qualified	Test.QuickCheck-import qualified	ToolShed.SelfValidate-import qualified	ToolShed.Test.ReversibleIO---- | A specialised instance, required to instantiate 'Test.QuickCheck.Arbitrary'.-newtype RepeatableMetaChar	= MkRepeatableMetaChar (RegExDot.Repeatable.Repeatable MetaChar.MetaChar)	deriving (Eq, Read, Show)---- | Accessor.-deconstruct :: RepeatableMetaChar -> RegExDot.Repeatable.Repeatable MetaChar.MetaChar-deconstruct (MkRepeatableMetaChar repeatableMetaChar)	= repeatableMetaChar--instance ToolShed.SelfValidate.SelfValidator RepeatableMetaChar	where-	getErrors	= ToolShed.SelfValidate.getErrors . deconstruct--instance RegExDot.Consumer.Consumer RepeatableMetaChar	where-	consumptionProfile	= RegExDot.Consumer.consumptionProfile . deconstruct-	starHeight		= RegExDot.Consumer.starHeight . deconstruct--instance Test.QuickCheck.Arbitrary RepeatableMetaChar	where-	arbitrary	= do-		metaChar	<- Test.QuickCheck.arbitrary-		fewest		<- Test.QuickCheck.elements [0 .. 9]	-- Could be more, but this is an adequate test.-		most		<- Test.QuickCheck.oneof [return Nothing, Just `fmap` Test.QuickCheck.elements [max fewest 1 .. 9]]-		isGreedy	<- Test.QuickCheck.arbitrary--		let-			repetitionBounds :: RegExDot.Repeatable.RepetitionBounds-			repetitionBounds	= (fewest, most)--		return {-to Gen-monad-} . MkRepeatableMetaChar $ RegExDot.Repeatable.MkRepeatable {-			RegExDot.Repeatable.base		= metaChar,-			RegExDot.Repeatable.repetitionBounds	= repetitionBounds,-			RegExDot.Repeatable.isGreedy		= RegExDot.Repeatable.hasPreciseBounds repetitionBounds || isGreedy	-- Only specify 'non-greedy' where space exists.-		}--type Testable	= RepeatableMetaChar -> Test.QuickCheck.Property---- | The constant test-results for this data-type.-results :: IO [Test.QuickCheck.Result]-results	= mapM Test.QuickCheck.quickCheckResult [prop_consumptionProfile, prop_io, prop_isValid, prop_starHeight]	where-	prop_consumptionProfile, prop_io, prop_isValid, prop_starHeight :: Testable-	prop_consumptionProfile r	= Test.QuickCheck.label "prop_consumptionProfile" $ Data.Maybe.maybe True (>= minData) maybeMaxData && b == RegExDot.Consumer.getHasSpecificRequirement (RegExDot.Repeatable.base $ deconstruct r)	where-		RegExDot.ConsumptionProfile.MkConsumptionProfile {-			RegExDot.ConsumptionProfile.consumptionBounds		= (minData, maybeMaxData),-			RegExDot.ConsumptionProfile.hasSpecificRequirement	= b-		} = RegExDot.Consumer.consumptionProfile r--	prop_io (MkRepeatableMetaChar r)		= Test.QuickCheck.label "prop_io" $ ToolShed.Test.ReversibleIO.isReversible r-	prop_isValid r					= Test.QuickCheck.label "prop_isValid" $ ToolShed.SelfValidate.isValid r-	prop_starHeight (MkRepeatableMetaChar r)	= Test.QuickCheck.label "prop_starHeight" $ RegExDot.Consumer.starHeight r == if RegExDot.ConsumptionBounds.isPrecise (RegExDot.Consumer.getConsumptionBounds r) then 0 else 1-
+ src-test/Grecce/Test/QuickCheck/ExtendedRegExChar.hs view
@@ -0,0 +1,185 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-+	Copyright (C) 2010-2015 Dr. Alistair Ward++	This program is free software: you can redistribute it and/or modify+	it under the terms of the GNU General Public License as published by+	the Free Software Foundation, either version 3 of the License, or+	(at your option) any later version.++	This program is distributed in the hope that it will be useful,+	but WITHOUT ANY WARRANTY; without even the implied warranty of+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+	GNU General Public License for more details.++	You should have received a copy of the GNU General Public License+	along with this program.  If not, see <http://www.gnu.org/licenses/>.+-}+{- |+ [@AUTHOR@]	Dr. Alistair Ward++ [@DESCRIPTION@]	Implements 'Test.QuickCheck.Arbitrary' & defines tests based on it.+-}++module Grecce.Test.QuickCheck.ExtendedRegExChar(+-- * Constants+	results,+-- * Types+-- ** Data-types+--	AlternativesChar(..),+--	PatternChar(..),+--	RepeatablePatternChar(..)+) where++import qualified	Data.Maybe+import			Grecce.Test.QuickCheck.MetaChar()+import qualified	RegExChar.ExtendedRegExChar	as ExtendedRegExChar	-- CAVEAT: beware of the similar name.+import qualified	RegExChar.MetaChar		as MetaChar+import qualified	RegExDot.Anchor+import qualified	RegExDot.BracketExpressionMember+import qualified	RegExDot.Consumer+import qualified	RegExDot.ConsumptionBounds+import qualified	RegExDot.ConsumptionProfile+import			RegExDot.DSL((-:), (?:), (+:), (<~>))+import qualified	RegExDot.Meta+import qualified	RegExDot.RegEx+import			RegExDot.RegEx((+~))+import qualified	RegExDot.RegExOpts+import qualified	RegExDot.Repeatable+import qualified	RegExDot.Result+import qualified	Test.QuickCheck+import			Test.QuickCheck((==>))+import qualified	ToolShed.SelfValidate+import qualified	ToolShed.Test.ReversibleIO++-- | A specialised instance, required to instantiate 'Test.QuickCheck.Arbitrary'.+newtype AlternativesChar	= MkAlternativesChar {+	deconstructAlternativesChar	:: RegExDot.RegEx.Alternatives Char+} deriving (Eq, Read, Show)++instance ToolShed.SelfValidate.SelfValidator AlternativesChar where+	getErrors	= ToolShed.SelfValidate.getErrors . deconstructAlternativesChar++instance RegExDot.Consumer.Consumer AlternativesChar where+	consumptionProfile	= RegExDot.Consumer.consumptionProfile . deconstructAlternativesChar+	starHeight		= RegExDot.Consumer.starHeight . deconstructAlternativesChar++instance Test.QuickCheck.Arbitrary AlternativesChar	where+	arbitrary	= (MkAlternativesChar . RegExDot.RegEx.MkAlternatives . map ExtendedRegExChar.extendedRegEx) `fmap` (+		Test.QuickCheck.elements [1, 2]	>>= Test.QuickCheck.vector {-[ExtendedRegExChar]-}+	 ) -- TODO: permit zero alternatives.++-- | A specialised instance, required to instantiate 'Test.QuickCheck.Arbitrary'.+newtype PatternChar	= MkPatternChar {+	deconstructPatternChar	:: RegExDot.RegEx.Pattern Char+} deriving (Eq, Read, Show)++instance ToolShed.SelfValidate.SelfValidator PatternChar	where+	getErrors	= ToolShed.SelfValidate.getErrors . deconstructPatternChar++instance RegExDot.Consumer.Consumer PatternChar	where+	consumptionProfile	= RegExDot.Consumer.consumptionProfile . deconstructPatternChar+	starHeight		= RegExDot.Consumer.starHeight . deconstructPatternChar++instance Test.QuickCheck.Arbitrary PatternChar	where+	arbitrary	= MkPatternChar `fmap` Test.QuickCheck.frequency [+		(4,	(RegExDot.RegEx.Require . MetaChar.deconstruct) `fmap` Test.QuickCheck.arbitrary {-MetaChar-}),+		(1,	(RegExDot.RegEx.CaptureGroup . deconstructAlternativesChar) `fmap` Test.QuickCheck.arbitrary {-AlternativesChar-})+	 ] -- CAVEAT: may recurse forever if 'RegExDot.RegEx.CaptureGroup / RegExDot.RegEx.Require' is too high.++-- | A specialised instance, required to instantiate 'Test.QuickCheck.Arbitrary'.+newtype RepeatablePatternChar	= MkRepeatablePatternChar {+	deconstructRepeatablePatternChar	:: RegExDot.Repeatable.Repeatable PatternChar+} deriving (Eq, Read, Show)++instance ToolShed.SelfValidate.SelfValidator RepeatablePatternChar	where+	getErrors	= ToolShed.SelfValidate.getErrors . deconstructRepeatablePatternChar++instance RegExDot.Consumer.Consumer RepeatablePatternChar	where+	consumptionProfile	= RegExDot.Consumer.consumptionProfile . deconstructRepeatablePatternChar+	starHeight		= RegExDot.Consumer.starHeight . deconstructRepeatablePatternChar++instance Test.QuickCheck.Arbitrary RepeatablePatternChar	where+	arbitrary	= do+		patternChar	<- Test.QuickCheck.arbitrary+		fewest		<- Test.QuickCheck.elements [0 .. 9]	-- Could be more, but this is an adequate test.+		most		<- Test.QuickCheck.oneof [return {-to Gen-monad-} Nothing, Just `fmap` Test.QuickCheck.elements [max fewest 1 .. 9]]+		isGreedy	<- Test.QuickCheck.arbitrary {-Bool-}++		let+			repetitionBounds :: RegExDot.Repeatable.RepetitionBounds+			repetitionBounds	= (fewest, most)++		return {-to Gen-monad-} $ MkRepeatablePatternChar RegExDot.Repeatable.MkRepeatable {+			RegExDot.Repeatable.base		= patternChar,+			RegExDot.Repeatable.repetitionBounds	= repetitionBounds,+			RegExDot.Repeatable.isGreedy		= RegExDot.Repeatable.hasPreciseBounds repetitionBounds || isGreedy	-- Only specify non-greedy where space exists.+		}++instance Test.QuickCheck.Arbitrary ExtendedRegExChar.ExtendedRegExChar	where+	arbitrary	= do+		hasBowAnchor	<- Test.QuickCheck.arbitrary {-Bool-}+		concatenation	<- map (fmap deconstructPatternChar {-replace base-} . deconstructRepeatablePatternChar {-RegExDot.Repeatable.Repeatable PatternChar-}) `fmap` Test.QuickCheck.vector 2 {-[RepeatablePatternChar]-}+		hasSternAnchor	<- Test.QuickCheck.arbitrary {-Bool-}++		return {-to Gen-monad-} $ ExtendedRegExChar.MkExtendedRegExChar False RegExDot.RegEx.MkExtendedRegEx {+			RegExDot.RegEx.bowAnchor	= if hasBowAnchor then Just RegExDot.Anchor.Bow else Nothing,+			RegExDot.RegEx.concatenation	= concatenation,+			RegExDot.RegEx.sternAnchor	= if hasSternAnchor then Just RegExDot.Anchor.Stern else Nothing+		}++-- | The constant test-results for this data-type.+results :: IO [Test.QuickCheck.Result]+results	= sequence [+	Test.QuickCheck.quickCheckResult prop_consumptionProfile,+	Test.QuickCheck.quickCheckResult prop_consumptionProfile2,+	Test.QuickCheck.quickCheckResult prop_io,+	Test.QuickCheck.quickCheckResult prop_io',+	Test.QuickCheck.quickCheckResult prop_isValid,+	Test.QuickCheck.quickCheckResult prop_starHeight,+	Test.QuickCheck.quickCheckResult prop_double,+	Test.QuickCheck.quickCheckResult prop_read+ ] where+	prop_consumptionProfile, prop_consumptionProfile2, prop_io, prop_io', prop_isValid, prop_starHeight :: ExtendedRegExChar.ExtendedRegExChar -> Test.QuickCheck.Property+	prop_consumptionProfile r	= Test.QuickCheck.label "prop_consumptionProfile" $ Data.Maybe.maybe True (>= minData) maybeMaxData && (+		not b == all (not . RegExDot.Consumer.getHasSpecificRequirement) (RegExDot.RegEx.concatenation $ ExtendedRegExChar.extendedRegEx r)+	 ) where+		RegExDot.ConsumptionProfile.MkConsumptionProfile {+			RegExDot.ConsumptionProfile.consumptionBounds		= (minData, maybeMaxData),+			RegExDot.ConsumptionProfile.hasSpecificRequirement	= b+		} = RegExDot.Consumer.consumptionProfile r++	prop_consumptionProfile2 r	= RegExDot.RegEx.isDefined (ExtendedRegExChar.extendedRegEx r)	==> Test.QuickCheck.label "prop_consumptionProfile2" $ hasSpecificRequirement || canConsumeAnything	where	-- There's either; a requirement for at least one specific, or we can consume at least one arbitrary; input datum.+		RegExDot.ConsumptionProfile.MkConsumptionProfile {+			RegExDot.ConsumptionProfile.hasSpecificRequirement	= hasSpecificRequirement,+			RegExDot.ConsumptionProfile.canConsumeAnything		= canConsumeAnything+		} = RegExDot.Consumer.consumptionProfile r++	prop_io			= Test.QuickCheck.label "prop_io" . ToolShed.Test.ReversibleIO.isReversible+	prop_io' r		= Test.QuickCheck.label "prop_io'" $ ToolShed.Test.ReversibleIO.isReversible r'	where r' = ExtendedRegExChar.extendedRegEx r	-- Check "RegExDot.RegEx.ExtendedRegEx Char" too.+	prop_isValid r		= Test.QuickCheck.label "prop_isValid" $ ToolShed.SelfValidate.isValid r+	prop_starHeight r	= Test.QuickCheck.label "prop_starHeight" $ (RegExDot.Consumer.starHeight r == 0) == RegExDot.ConsumptionBounds.isPrecise (RegExDot.Consumer.getConsumptionBounds r)++	prop_double :: Double -> Test.QuickCheck.Property+	prop_double d	= Test.QuickCheck.label "prop_double" $ RegExDot.RegEx.extractDataFromMatchList `fmap` RegExDot.Result.getMatchList result == Just s	where+		s :: String+		s	= show $ d * 1e6	-- Implementation of show, uses exponential notation, when the number is large.++		result :: RegExDot.RegEx.Result Char+		result = s +~ RegExDot.RegExOpts.mkRegEx (+			(Just RegExDot.Anchor.Bow, Just RegExDot.Anchor.Stern) <~> sign ?: digits +: map (+				RegExDot.Repeatable.zeroOrOne . RegExDot.RegEx.captureGroup . map (RegExDot.Anchor.unanchored <~>) . return {-to List-monad-}+			) [+				RegExDot.RegEx.Require (RegExDot.Meta.Literal '.') -: digits +: [],+				RegExDot.RegEx.Require (RegExDot.Meta.AnyOf $ map RegExDot.BracketExpressionMember.Literal "eE") -: sign ?: digits +: []+			]+		 ) where+			sign, digits :: RegExDot.RegEx.Pattern Char+			sign	= RegExDot.RegEx.Require . RegExDot.Meta.AnyOf $ map RegExDot.BracketExpressionMember.Literal "+-"+			digits	= RegExDot.RegEx.Require . RegExDot.Meta.AnyOf $ map RegExDot.BracketExpressionMember.Literal ['0' .. '9']++	prop_read :: String -> Test.QuickCheck.Property+	prop_read garbage	= Test.QuickCheck.label "prop_read" $ case (reads garbage :: [(ExtendedRegExChar.ExtendedRegExChar, String)]) of+		[_]	-> True+		_	-> True	-- Unless the read-implementation throws an exception.+
+ src-test/Grecce/Test/QuickCheck/MetaChar.hs view
@@ -0,0 +1,66 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-+	Copyright (C) 2010-2015 Dr. Alistair Ward++	This program is free software: you can redistribute it and/or modify+	it under the terms of the GNU General Public License as published by+	the Free Software Foundation, either version 3 of the License, or+	(at your option) any later version.++	This program is distributed in the hope that it will be useful,+	but WITHOUT ANY WARRANTY; without even the implied warranty of+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+	GNU General Public License for more details.++	You should have received a copy of the GNU General Public License+	along with this program.  If not, see <http://www.gnu.org/licenses/>.+-}+{- |+ [@AUTHOR@]	Dr. Alistair Ward++ [@DESCRIPTION@]	Implements 'Test.QuickCheck.Arbitrary' & defines tests based on it.++ [@TODO@]	Test /Perl-style shortcuts/ & /Posix Character-classes/.+-}++module Grecce.Test.QuickCheck.MetaChar(+-- * Constants+	results,+--	testCharacters,+-- * Types+-- ** Type-synonyms+--	Testable+) where++import qualified	Data.List+import qualified	RegExChar.MetaChar	as MetaChar	-- CAVEAT: beware of the similar name.+import qualified	RegExDot.BracketExpression+import qualified	RegExDot.BracketExpressionMember+import qualified	RegExDot.Meta+import qualified	Test.QuickCheck+import qualified	ToolShed.Test.ReversibleIO++testCharacters :: String+testCharacters	= filter (`notElem` [RegExDot.Meta.shortcutToken, RegExDot.BracketExpression.negationToken]) [' ' .. '~']	-- TODO: permit all characters.++instance Test.QuickCheck.Arbitrary MetaChar.MetaChar	where+	arbitrary	= Test.QuickCheck.oneof $ map (fmap MetaChar.MkMetaChar) [+		return {-to Gen-monad-} RegExDot.Meta.Any,+		RegExDot.Meta.Literal `fmap` Test.QuickCheck.elements testCharacters,+		(RegExDot.Meta.AnyOf . map RegExDot.BracketExpressionMember.Literal . Data.List.nub) `fmap` arbitraryCharList 1 16,	-- Test.QuickCheck.vector 16 {-Char-},+		(RegExDot.Meta.NoneOf . map RegExDot.BracketExpressionMember.Literal . Data.List.nub) `fmap` arbitraryCharList 1 4+	 ] where+		arbitraryCharList :: Int -> Int -> Test.QuickCheck.Gen String+		arbitraryCharList i j	= do+			l	<- Test.QuickCheck.arbitrary {-Int-}++			(take (min j $ i `max` l) . Data.List.nub . Data.List.filter (`elem` testCharacters)) `fmap` Test.QuickCheck.vector maxBound {-Char-}++type Testable	= MetaChar.MetaChar -> Test.QuickCheck.Property++-- | The constant test-results for this data-type.+results :: IO [Test.QuickCheck.Result]+results = mapM Test.QuickCheck.quickCheckResult [prop_io]	where+	prop_io :: Testable+	prop_io	= Test.QuickCheck.label "prop_io" . ToolShed.Test.ReversibleIO.isReversible+
+ src-test/Grecce/Test/QuickCheck/RepeatableMetaChar.hs view
@@ -0,0 +1,99 @@+{-+	Copyright (C) 2010-2015 Dr. Alistair Ward++	This program is free software: you can redistribute it and/or modify+	it under the terms of the GNU General Public License as published by+	the Free Software Foundation, either version 3 of the License, or+	(at your option) any later version.++	This program is distributed in the hope that it will be useful,+	but WITHOUT ANY WARRANTY; without even the implied warranty of+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+	GNU General Public License for more details.++	You should have received a copy of the GNU General Public License+	along with this program.  If not, see <http://www.gnu.org/licenses/>.+-}+{- |+ [@AUTHOR@]	Dr. Alistair Ward++ [@DESCRIPTION@]	Implements 'Test.QuickCheck.Arbitrary' & defines tests based on it.+-}++module Grecce.Test.QuickCheck.RepeatableMetaChar(+-- * Constants+	results,+-- * Types+-- ** Data-types+--	RepeatableMetaChar(..),+-- ** Type-synonyms+--	Testable+) where++import qualified	Data.Maybe+import			Grecce.Test.QuickCheck.MetaChar()+import qualified	RegExChar.MetaChar	as MetaChar+import qualified	RegExDot.Consumer+import qualified	RegExDot.ConsumptionBounds+import qualified	RegExDot.ConsumptionProfile+import qualified	RegExDot.Repeatable+import qualified	Test.QuickCheck+import qualified	ToolShed.SelfValidate+import qualified	ToolShed.Test.ReversibleIO++-- | A specialised instance, required to instantiate 'Test.QuickCheck.Arbitrary'.+newtype RepeatableMetaChar	= MkRepeatableMetaChar {+	deconstruct	:: RegExDot.Repeatable.Repeatable MetaChar.MetaChar+} deriving (Eq, Read, Show)++instance ToolShed.SelfValidate.SelfValidator RepeatableMetaChar	where+	getErrors	= ToolShed.SelfValidate.getErrors . deconstruct++instance RegExDot.Consumer.Consumer RepeatableMetaChar	where+	consumptionProfile	= RegExDot.Consumer.consumptionProfile . deconstruct+	starHeight		= RegExDot.Consumer.starHeight . deconstruct++instance Test.QuickCheck.Arbitrary RepeatableMetaChar	where+	arbitrary	= do+		metaChar	<- Test.QuickCheck.arbitrary+		fewest		<- Test.QuickCheck.elements [0 .. 9]	-- Could be more, but this is an adequate test.+		most		<- Test.QuickCheck.oneof [return Nothing, Just `fmap` Test.QuickCheck.elements [max fewest 1 .. 9]]+		isGreedy	<- Test.QuickCheck.arbitrary++		let+			repetitionBounds :: RegExDot.Repeatable.RepetitionBounds+			repetitionBounds	= (fewest, most)++		return {-to Gen-monad-} . MkRepeatableMetaChar $ RegExDot.Repeatable.MkRepeatable {+			RegExDot.Repeatable.base		= metaChar,+			RegExDot.Repeatable.repetitionBounds	= repetitionBounds,+			RegExDot.Repeatable.isGreedy		= RegExDot.Repeatable.hasPreciseBounds repetitionBounds || isGreedy	-- Only specify 'non-greedy' where space exists.+		}++type Testable	= RepeatableMetaChar -> Test.QuickCheck.Property++-- | The constant test-results for this data-type.+results :: IO [Test.QuickCheck.Result]+results	= sequence [+	Test.QuickCheck.quickCheckResult prop_consumptionProfile,+	Test.QuickCheck.quickCheckResult prop_io,+	Test.QuickCheck.quickCheckResult prop_isValid,+	Test.QuickCheck.quickCheckResult prop_starHeight,+	Test.QuickCheck.quickCheckResult prop_read+ ] where+	prop_consumptionProfile, prop_io, prop_isValid, prop_starHeight :: Testable+	prop_consumptionProfile r	= Test.QuickCheck.label "prop_consumptionProfile" $ Data.Maybe.maybe True (>= minData) maybeMaxData && b == RegExDot.Consumer.getHasSpecificRequirement (RegExDot.Repeatable.base $ deconstruct r)	where+		RegExDot.ConsumptionProfile.MkConsumptionProfile {+			RegExDot.ConsumptionProfile.consumptionBounds		= (minData, maybeMaxData),+			RegExDot.ConsumptionProfile.hasSpecificRequirement	= b+		} = RegExDot.Consumer.consumptionProfile r++	prop_io (MkRepeatableMetaChar r)		= Test.QuickCheck.label "prop_io" $ ToolShed.Test.ReversibleIO.isReversible r+	prop_isValid r					= Test.QuickCheck.label "prop_isValid" $ ToolShed.SelfValidate.isValid r+	prop_starHeight (MkRepeatableMetaChar r)	= Test.QuickCheck.label "prop_starHeight" $ RegExDot.Consumer.starHeight r == if RegExDot.ConsumptionBounds.isPrecise (RegExDot.Consumer.getConsumptionBounds r) then 0 else 1++	prop_read :: String -> Test.QuickCheck.Property+	prop_read garbage	= Test.QuickCheck.label "prop_read" $ case (reads garbage :: [(RepeatableMetaChar, String)]) of+		[_]	-> True+		_	-> True	-- Unless the read-implementation throws an exception.+
src-test/Main.hs view
@@ -22,25 +22,20 @@  module Main(main) where -import			Control.Arrow((***)) import qualified	Control.Monad-import qualified	Grecce.Test.QC.ExtendedRegExChar	as Test.QC.ExtendedRegExChar-import qualified	Grecce.Test.QC.MetaChar			as Test.QC.MetaChar-import qualified	Grecce.Test.QC.RepeatableMetaChar	as Test.QC.RepeatableMetaChar+import qualified	Grecce.Test.QuickCheck.ExtendedRegExChar	as Test.QuickCheck.ExtendedRegExChar+import qualified	Grecce.Test.QuickCheck.MetaChar			as Test.QuickCheck.MetaChar+import qualified	Grecce.Test.QuickCheck.RepeatableMetaChar	as Test.QuickCheck.RepeatableMetaChar import qualified	System.Exit import qualified	ToolShed.Test.QuickCheck.Result  -- | Entry-point. main :: IO () main	= mapM_ (-	snd {-exit-status-} . (-		putStrLn . (++ ":") *** (-			>>= (`Control.Monad.unless` System.Exit.exitFailure) . all ToolShed.Test.QuickCheck.Result.isSuccessful-		)-	)+	(`Control.Monad.unless` System.Exit.exitFailure) . all ToolShed.Test.QuickCheck.Result.isSuccessful =<<  ) [-	("MetaChar",		Test.QC.MetaChar.results),-	("RepeatableMetaChar",	Test.QC.RepeatableMetaChar.results),-	("ExtendedRegExChar",	Test.QC.ExtendedRegExChar.results)+	Test.QuickCheck.MetaChar.results,+	Test.QuickCheck.RepeatableMetaChar.results,+	Test.QuickCheck.ExtendedRegExChar.results  ]