parseerror-eq (empty) → 0.1.0.0
raw patch · 5 files changed
+124/−0 lines, 5 filesdep +basedep +hspecdep +parsecsetup-changed
Dependencies added: base, hspec, parsec
Files
- LICENSE +20/−0
- Setup.hs +2/−0
- parseerror-eq.cabal +61/−0
- spec/Spec.hs +1/−0
- src/Text/ParseErrorEq.hs +40/−0
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2015 Justin Leitgeb++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++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 OR COPYRIGHT HOLDERS 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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ parseerror-eq.cabal view
@@ -0,0 +1,61 @@+name: parseerror-eq+version: 0.1.0.0+synopsis: Adds and Eq instance for Parsec's ParseError if needed+description:+ .+ A library to help with compatibility against Parsec versions. Adds an+ instance of `Eq` to the `ParseError` data type, if it's missing from the+ version of Parsec that you're compiling against.+ .+ To test Parsec's parsing, it's very useful to have an Eq instance for+ ParseError. This is included in Parsec versions >= 3.1.9, but you need+ to define it yourself in previous versions.+ .+ This simple library conditionally adds an Eq instance for ParseError+ only if the Parsec version being used is < 3.1.9. To use it, just add+ parseerror-eq to your cabal dependencies, and in the module where you want+ to compare ParseErrors,+ .+ > import Text.ParseErrorEq ()+ .+ The ParseError Eq instance will be imported if it is necessary, otherwise+ the ParseErrorEq module is empty, so nothing will happen. This ensures that+ your code that needs the ParseError Eq instance will work regardless of the+ Parsec version that it is compiled against.+ .+homepage: https://github.com/stackbuilders/parseerror-eq+license: MIT+license-file: LICENSE+author: Justin Leitgeb+maintainer: justin@stackbuilders.com+copyright: 2015 Stack Builders Inc.+category: Text+build-type: Simple+cabal-version: >=1.10+bug-reports: https://github.com/stackbuilders/parseerror-eq/issues++library+ exposed-modules: Text.ParseErrorEq+ build-depends: base >=4.5 && <4.8+ , parsec++ hs-source-dirs: src+ default-language: Haskell2010+ ghc-options: -Wall+ default-extensions: CPP++test-suite parseerror-eq-test+ type: exitcode-stdio-1.0+ hs-source-dirs: spec, src+ main-is: Spec.hs+ build-depends: base >=4.5 && <4.8+ , parsec+ , hspec++ default-language: Haskell2010+ ghc-options: -Wall+ default-extensions: CPP++source-repository head+ type: git+ location: git@github.com:stackbuilders/parseerror-eq.git
+ spec/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
+ src/Text/ParseErrorEq.hs view
@@ -0,0 +1,40 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}++{-|+Module : Text.ParseErrorEq+Description : Adds an Eq instance for Parsec's ParseError type if needed+Copyright : (c) Stack Builders Inc., 2015+License : GPL-3+Maintainer : justin@stackbuilders.com+Stability : experimental+Portability : POSIX++This module adds an Eq instance for Parsec's ParseError type if it's+needed. Import by using (since this module only provides instances):++> import Text.ParseErrorEq ()++For reference, Parsec 3.1.9 adds the Eq instance, in the commit here:++https://github.com/aslatter/parsec/commit/3fb40aaa683fd90f3f0dd9f3c32c6ba707fb24b1+-}+module Text.ParseErrorEq where++#if MIN_VERSION_parsec(3,1,9)++-- ParseError Eq instance already defined in Parsec, not necessary to add.++#else++import Text.Parsec.Error (ParseError)+import Text.ParserCombinators.Parsec.Error+ (errorPos, errorMessages, messageString)++-- This implementation of Eq for ParseError is the same as the one+-- added in Parsec in the above commit.+instance Eq ParseError where+ l == r+ = errorPos l == errorPos r && messageStrs l == messageStrs r+ where messageStrs = map messageString . errorMessages++#endif