git.iko.soy/typeable/inflections-hs
on 1d68232 help sign in
.travis.yml+3−8
since splitsnapshots
unifiedsplit
@@ -9,14 +9,12 @@ cache:
9
9
10matrix:
10matrix:
11 include:
11 include:
12+ - env: CABALVER=1.24 GHCVER=7.8.4
13+ addons: {apt: {packages: [cabal-install-1.24,ghc-7.8.4,],sources: [hvr-ghc]}}
12 - env: CABALVER=1.24 GHCVER=7.10.3
14 - env: CABALVER=1.24 GHCVER=7.10.3
13 addons: {apt: {packages: [cabal-install-1.24,ghc-7.10.3],sources: [hvr-ghc]}}
15 addons: {apt: {packages: [cabal-install-1.24,ghc-7.10.3],sources: [hvr-ghc]}}
14 - env: CABALVER=1.24 GHCVER=8.0.2
16 - env: CABALVER=1.24 GHCVER=8.0.2
15 addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2],sources: [hvr-ghc]}}
17 addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2],sources: [hvr-ghc]}}
16− - env: CABALVER=2.2 GHCVER=8.2.2
17− addons: {apt: {packages: [cabal-install-2.2,ghc-8.2.2], sources: [hvr-ghc]}}
18− - env: CABALVER=2.2 GHCVER=8.4.3
19− addons: {apt: {packages: [cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}}
20
18
21before_install:
19before_install:
22 - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
20 - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
@@ -34,10 +32,7 @@ script:
34 esac
32 esac
35 - cabal build
33 - cabal build
36 - cabal sdist
34 - cabal sdist
37− - case "$GHCVER" in
38− "8.4.3") cabal haddock | grep "100%" | wc -l | grep "1" ;;
39− *) cabal haddock | grep "100%" | wc -l | grep "13" ;;
35+ - cabal haddock | grep "100%" | wc -l | grep "13"
40− esac
41
36
42notifications:
37notifications:
43 email: false
38 email: false
CHANGELOG.md−16
@@ -1,19 +1,3 @@
1−## Inflections 0.4.0.6
2−* Support `megaparsec` == 9.0
3−
4−## Inflections 0.4.0.5
5−* Support `megaparsec` == 8.0
6−
7−## Inflections 0.4.0.3
8−* Support `megaparsec` == 7.0*.
9−* **Drop support** for `GHC 7.8.4`.
10−
11−## Inflections 0.4.0.3
12−* Support `exceptions` == 0.10.*
13−
14−## Inflections 0.4.0.2
15−* Support `exceptions` == 0.9.*
16−
17## Inflections 0.4.0.1
1## Inflections 0.4.0.1
18* Support `megaparsec` >= 6.4.0
2* Support `megaparsec` >= 6.4.0
19
3
LICENSE+18−17
@@ -1,21 +1,22 @@
1−MIT License
1+Copyright (c) 2014-2016 Justin Leitgeb
2
2
3−Copyright (c) 2022 Stack Builders Inc.
3+MIT License
4
4
5−Permission is hereby granted, free of charge, to any person obtaining a copy
5+Permission is hereby granted, free of charge, to any person obtaining
6−of this software and associated documentation files (the "Software"), to deal
6+a copy of this software and associated documentation files (the
7−in the Software without restriction, including without limitation the rights
7+"Software"), to deal in the Software without restriction, including
8+without limitation the rights to use, copy, modify, merge, publish,
8−to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+distribute, sublicense, and/or sell copies of the Software, and to
9−copies of the Software, and to permit persons to whom the Software is
10+permit persons to whom the Software is furnished to do so, subject to
10−furnished to do so, subject to the following conditions:
11+the following conditions:
11
12
12−The above copyright notice and this permission notice shall be included in all
13+The above copyright notice and this permission notice shall be
13−copies or substantial portions of the Software.
14+included in all copies or substantial portions of the Software.
14
15
15−THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16−IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17−FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18−AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19−LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20−OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21−SOFTWARE.
README.md+8−11
@@ -49,10 +49,11 @@ If you want to specify a custom default replacement or approximation table for
49the `transliterate` function, you should instead call the `transliterateCustom`
49the `transliterate` function, you should instead call the `transliterateCustom`
50function which accepts a String for replacements and a Map for substitution.
50function which accepts a String for replacements and a Map for substitution.
51
51
52−## Future work
52+## TODO
53
53
54−Ideally, we want to implement other functions found in the Rails
54+I'd like this library to implement other functions found in the Rails
55−inflections library. If you need one of those functions, please submit a pull request!
55+inflections library. If you need one of those functions, please submit a pull
56+request!
56
57
57## Further documentation
58## Further documentation
58
59
@@ -63,14 +64,10 @@ For more information, please see the the
63
64
64Justin Leitgeb <justin@stackbuilders.com>
65Justin Leitgeb <justin@stackbuilders.com>
65
66
66−## License
67−
68−MIT, see [the LICENSE file](LICENSE).
69−
70## Contributing
67## Contributing
71
68
72−Do you want to contribute to this project? Please take a look at our [contributing guideline](/docs/CONTRIBUTING.md) to know how you can help us build it.
69+You may submit pull requests to this repository on GitHub. Tests are appreciated with your contribution.
70+
71+## License
73
72
74−---
73+MIT - see [the LICENSE file](LICENSE).
75−<img src="https://cdn.stackbuilders.com/media/images/Sb-supports.original.png" alt="Stack Builders" width="50%"></img>
76−[Check out our libraries](https://github.com/stackbuilders/) | [Join our team](https://www.stackbuilders.com/join-us/)
Text/Inflections.hs+5−5
@@ -142,7 +142,7 @@ import Prelude hiding (Word)
142--
142--
143-- >>> toUnderscore "FooBarBazz"
143-- >>> toUnderscore "FooBarBazz"
144-- "foo_bar_bazz"
144-- "foo_bar_bazz"
145−toUnderscore :: Text -> Either (ParseErrorBundle Text Void) Text
145+toUnderscore :: Text -> Either (ParseError Char Void) Text
146toUnderscore = fmap underscore . parseCamelCase []
146toUnderscore = fmap underscore . parseCamelCase []
147
147
148-- | Transforms CamelCasedString to snake-cased-string-with-dashes.
148-- | Transforms CamelCasedString to snake-cased-string-with-dashes.
@@ -151,7 +151,7 @@ toUnderscore = fmap underscore . parseCamelCase []
151--
151--
152-- >>> toDashed "FooBarBazz"
152-- >>> toDashed "FooBarBazz"
153-- "foo-bar-bazz"
153-- "foo-bar-bazz"
154−toDashed :: Text -> Either (ParseErrorBundle Text Void) Text
154+toDashed :: Text -> Either (ParseError Char Void) Text
155toDashed = fmap dasherize . parseCamelCase []
155toDashed = fmap dasherize . parseCamelCase []
156
156
157-- | Transforms underscored_text to CamelCasedText. If first argument is
157-- | Transforms underscored_text to CamelCasedText. If first argument is
@@ -167,7 +167,7 @@ toDashed = fmap dasherize . parseCamelCase []
167toCamelCased
167toCamelCased
168 :: Bool -- ^ Capitalize the first character
168 :: Bool -- ^ Capitalize the first character
169 -> Text -- ^ Input
169 -> Text -- ^ Input
170− -> Either (ParseErrorBundle Text Void) Text -- ^ Output
170+ -> Either (ParseError Char Void) Text -- ^ Output
171toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
171toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
172
172
173-- | Transforms underscored_text to space-separated human-readable text.
173-- | Transforms underscored_text to space-separated human-readable text.
@@ -186,7 +186,7 @@ toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
186toHumanized
186toHumanized
187 :: Bool -- ^ Capitalize the first character
187 :: Bool -- ^ Capitalize the first character
188 -> Text -- ^ Input
188 -> Text -- ^ Input
189− -> Either (ParseErrorBundle Text Void) Text -- ^ Output
189+ -> Either (ParseError Char Void) Text -- ^ Output
190toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
190toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
191
191
192-- | Lift something of type @'Either' ('ParseError' 'Char' 'Void') a@ to
192-- | Lift something of type @'Either' ('ParseError' 'Char' 'Void') a@ to
@@ -197,6 +197,6 @@ toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
197--
197--
198-- /since 0.3.0.0/
198-- /since 0.3.0.0/
199
199
200−betterThrow :: MonadThrow m => Either (ParseErrorBundle Text Void) a -> m a
200+betterThrow :: MonadThrow m => Either (ParseError Char Void) a -> m a
201betterThrow (Left err) = throwM (InflectionParsingFailed err)
201betterThrow (Left err) = throwM (InflectionParsingFailed err)
202betterThrow (Right x) = return x
202betterThrow (Right x) = return x
Text/Inflections/Ordinal.hs+1
@@ -16,6 +16,7 @@ module Text.Inflections.Ordinal
16 , ordinal )
16 , ordinal )
17where
17where
18
18
19+import Data.Monoid ((<>))
19import Data.Text (Text)
20import Data.Text (Text)
20import qualified Data.Text as T
21import qualified Data.Text as T
21
22
Text/Inflections/Parse/CamelCase.hs+3−3
@@ -20,12 +20,12 @@ where
20# if MIN_VERSION_base(4,8,0)
20# if MIN_VERSION_base(4,8,0)
21import Control.Applicative (empty, many, (<|>))
21import Control.Applicative (empty, many, (<|>))
22#else
22#else
23−import Control.Applicative (empty, many, (<|>), (<$>), (<*))
23+import Control.Applicative (empty, many, (<|>), (<$>), (<*), (<*>))
24#endif
24#endif
25import Data.Text (Text)
25import Data.Text (Text)
26import Data.Void (Void)
26import Data.Void (Void)
27import Text.Inflections.Types
27import Text.Inflections.Types
28−import Text.Megaparsec (Parsec, ParseErrorBundle, choice, eof, parse)
28+import Text.Megaparsec (Parsec, ParseError, choice, eof, parse)
29import Text.Megaparsec.Char
29import Text.Megaparsec.Char
30import qualified Data.Text as T
30import qualified Data.Text as T
31
31
@@ -51,7 +51,7 @@ type Parser = Parsec Void Text
51parseCamelCase :: (Foldable f, Functor f)
51parseCamelCase :: (Foldable f, Functor f)
52 => f (Word 'Acronym) -- ^ Collection of acronyms
52 => f (Word 'Acronym) -- ^ Collection of acronyms
53 -> Text -- ^ Input
53 -> Text -- ^ Input
54− -> Either (ParseErrorBundle Text Void) [SomeWord] -- ^ Result of parsing
54+ -> Either (ParseError Char Void) [SomeWord] -- ^ Result of parsing
55parseCamelCase acronyms = parse (parser acronyms) ""
55parseCamelCase acronyms = parse (parser acronyms) ""
56
56
57parser :: (Foldable f, Functor f)
57parser :: (Foldable f, Functor f)
Text/Inflections/Parse/SnakeCase.hs+3−3
@@ -19,12 +19,12 @@ where
19# if MIN_VERSION_base(4,8,0)
19# if MIN_VERSION_base(4,8,0)
20import Control.Applicative (empty, some)
20import Control.Applicative (empty, some)
21#else
21#else
22−import Control.Applicative (empty, some, (<$>), (<*))
22+import Control.Applicative (empty, some, (<$>), (<*), (<*>))
23#endif
23#endif
24import Data.Text (Text)
24import Data.Text (Text)
25import Data.Void (Void)
25import Data.Void (Void)
26import Text.Inflections.Types
26import Text.Inflections.Types
27−import Text.Megaparsec (Parsec, ParseErrorBundle, eof, sepBy, parse)
27+import Text.Megaparsec (Parsec, ParseError, eof, sepBy, parse)
28import Text.Megaparsec.Char
28import Text.Megaparsec.Char
29import qualified Data.Text as T
29import qualified Data.Text as T
30
30
@@ -50,7 +50,7 @@ type Parser = Parsec Void Text
50parseSnakeCase :: (Foldable f, Functor f)
50parseSnakeCase :: (Foldable f, Functor f)
51 => f (Word 'Acronym) -- ^ Collection of acronyms
51 => f (Word 'Acronym) -- ^ Collection of acronyms
52 -> Text -- ^ Input
52 -> Text -- ^ Input
53− -> Either (ParseErrorBundle Text Void) [SomeWord] -- ^ Result of parsing
53+ -> Either (ParseError Char Void) [SomeWord] -- ^ Result of parsing
54parseSnakeCase acronyms = parse (parser acronyms) ""
54parseSnakeCase acronyms = parse (parser acronyms) ""
55
55
56parser :: (Foldable f, Functor f)
56parser :: (Foldable f, Functor f)
Text/Inflections/Types.hs+1−1
@@ -136,7 +136,7 @@ instance Transformable (Word 'Acronym) where
136-- /since 0.3.0.0/
136-- /since 0.3.0.0/
137
137
138data InflectionException
138data InflectionException
139− = InflectionParsingFailed (ParseErrorBundle Text Void)
139+ = InflectionParsingFailed (ParseError Char Void)
140 | InflectionInvalidWord Text
140 | InflectionInvalidWord Text
141 | InflectionInvalidAcronym Text
141 | InflectionInvalidAcronym Text
142 deriving (Eq, Show, Typeable, Data, Generic)
142 deriving (Eq, Show, Typeable, Data, Generic)
docs/CODE_OF_CONDUCT.mddeleted−35
@@ -1,35 +0,0 @@
1−# Code of conduct
2−
3−## Purpose
4−The primary goal of this Code of Conduct is to enable an open and welcoming environment. We pledge to making participation in our project a harassment-free experience for everyone, regardless of gender, sexual
5−orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof).
6−
7−## General recommendations
8−Examples of behavior that contributes to creating a positive environment include:
9−
10−- Using welcoming and inclusive language
11−- Being respectful of differing viewpoints and experiences
12−- Gracefully accepting constructive criticism
13−- Focusing on what is best for the community
14−- Showing empathy towards other community members
15−
16−Examples of unacceptable behavior by participants include:
17−
18−- The use of sexualized language or imagery and unwelcome sexual attention or advances
19−- Trolling, insulting/derogatory comments, and personal or political attacks
20−- Public or private harassment
21−- Publishing others' private information, such as a physical or electronic address, without explicit permission
22−- Other conduct which could reasonably be considered inappropriate in a professional setting
23−
24−## Maintainer responsibilities
25−Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
26−
27−Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
28−
29−## Scope
30−This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
31−
32−## Enforcement
33−Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [community@stackbuilders.com](mailto:community@stackbuilders.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
34−
35−Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
docs/CONTRIBUTING.mddeleted−13
@@ -1,13 +0,0 @@
1−
2−Thank you for your interest in contributing to this Stack Builders' library. To contribute, please take our [Code of Conduct](CODE_OF_CONDUCT.md) into account, along with the following recommendations:
3−
4−- When submitting contributions to this repository, please make sure to discuss with the maintainer(s) the change you want to make. You can do this through an issue, or by sending an email to [community@stackbuilders.com](mailto:community@stackbuilders.com)
5−
6−- Once the change has been discussed with the maintainer(s), feel free to open a Pull Request. Please include a link to the issue you're trying to solve, or a quick summary of the discussed changes.
7−
8−- If adding any new features that you think should be considered in the README file, please add that information in your Pull Request.
9−
10−- Once you get an approval from any of the maintainers, please merge your Pull Request. Keep in mind that some of our Stack Builders repositories use CI/CD pipelines, so you will need to pass all of the required checks before merging.
11−
12−## Getting help
13−Contact any of our current maintainers, or send us an email at [community@stackbuilders.com](mailto:community@stackbuilders.com) for more information. Thank you for contributing!
inflections.cabal+10−10
@@ -1,5 +1,5 @@
1name: inflections
1name: inflections
2−version: 0.4.0.6
2+version: 0.4.0.1
3synopsis: Inflections library for Haskell
3synopsis: Inflections library for Haskell
4description:
4description:
5 Inflections provides methods for singularization, pluralization,
5 Inflections provides methods for singularization, pluralization,
@@ -48,10 +48,10 @@ library
48 else
48 else
49 ghc-options: -O2 -Wall
49 ghc-options: -O2 -Wall
50 build-depends: base >= 4.6 && < 5.0
50 build-depends: base >= 4.6 && < 5.0
51− , exceptions
51+ , exceptions >= 0.6 && < 0.9
52− , megaparsec
52+ , megaparsec >= 6.0 && < 7.0
53− , text
53+ , text >= 0.2 && < 1.3
54− , unordered-containers
54+ , unordered-containers >= 0.2.7 && < 0.3
55 if !impl(ghc >= 7.10)
55 if !impl(ghc >= 7.10)
56 build-depends: void == 0.7.*
56 build-depends: void == 0.7.*
57
57
@@ -62,13 +62,13 @@ test-suite test
62 hs-source-dirs: test
62 hs-source-dirs: test
63 main-is: Spec.hs
63 main-is: Spec.hs
64 build-depends: inflections
64 build-depends: inflections
65− , QuickCheck
65+ , QuickCheck >= 2.7.6 && < 3.0
66 , base >= 4.6 && < 5.0
66 , base >= 4.6 && < 5.0
67− , containers
67+ , containers >= 0.5 && < 0.7
68− , hspec
68+ , hspec >= 2.0 && < 3.0
69− , hspec-megaparsec
69+ , hspec-megaparsec >= 1.0 && < 2.0
70 , megaparsec
70 , megaparsec
71− , text
71+ , text >= 0.2 && < 1.3
72 if !impl(ghc >= 7.10)
72 if !impl(ghc >= 7.10)
73 build-depends: void == 0.7.*
73 build-depends: void == 0.7.*
74
74
stack.yaml+7−1
@@ -1 +1,7 @@
1+---
1−resolver: lts-21.3
2+resolver: lts-7.13
3+
4+extra-deps:
5+ - hspec-megaparsec-1.0.0
6+ - megaparsec-6.0.0
7+ - parser-combinators-0.1.0
stack.yaml.lockdeleted−12
@@ -1,12 +0,0 @@
1−# This file was autogenerated by Stack.
2−# You should not edit this file by hand.
3−# For more information, please see the documentation at:
4−# https://docs.haskellstack.org/en/stable/lock_files
5−
6−packages: []
7−snapshots:
8−- completed:
9− sha256: 97710f56bf093fca0ee5d8dbe19d96b654c752e405b66795b4baedd84a794c60
10− size: 640010
11− url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/3.yaml
12− original: lts-21.3
test/Text/InflectionsSpec.hs+10−26
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -fno-warn-orphans #-}
2{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
3{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
4
3
@@ -9,7 +8,6 @@ import Test.Hspec
9import Test.QuickCheck
8import Test.QuickCheck
10import Text.Inflections
9import Text.Inflections
11import Text.Megaparsec
10import Text.Megaparsec
12−import Data.Text
13
11
14import qualified Data.List.NonEmpty as NE
12import qualified Data.List.NonEmpty as NE
15import qualified Data.Set as S
13import qualified Data.Set as S
@@ -18,35 +16,21 @@ import qualified Data.Set as S
18import Control.Applicative
16import Control.Applicative
19#endif
17#endif
20
18
21−instance Arbitrary Text where
22− arbitrary = pack <$> (arbitrary :: Gen String)
23−
24−arbitraryParseErrorBundle :: Gen (ParseErrorBundle Text Void)
25−arbitraryParseErrorBundle = ParseErrorBundle <$> nonEmptyParseErrors <*> arbitraryPosState
26− where
27− posArbitrary = mkPos <$> ((+1) . abs <$> arbitrary)
28− nonEmptyParseErrors :: Gen (NE.NonEmpty (ParseError Text Void))
29− nonEmptyParseErrors = NE.fromList <$> listOf1 arbitraryParseError
19+arbitraryParseError :: Gen (ParseError Char Void)
30− arbitrarySourcePos :: Gen SourcePos
31− arbitrarySourcePos = SourcePos <$> arbitrary <*> posArbitrary <*> posArbitrary
32− arbitraryPosState :: Gen (PosState Text)
33− arbitraryPosState =
34− PosState
35− <$> arbitrary
36− <*> arbitrary
37− <*> arbitrarySourcePos
38− <*> posArbitrary
39− <*> arbitrary
40−
41−arbitraryParseError :: Gen (ParseError Text Void)
42arbitraryParseError = oneof [trivialError, fancyError]
20arbitraryParseError = oneof [trivialError, fancyError]
43 where
21 where
44− trivialError = TrivialError <$> arbitrary <*> maybeErrorItem <*> setErrorItem
22+ trivialError = TrivialError <$> nonEmptyArbitrary <*> maybeErrorItem <*> setErrorItem
45− fancyError = FancyError <$> arbitrary <*> setErrorFancy
23+ fancyError = FancyError <$> nonEmptyArbitrary <*> setErrorFancy
24+ nonEmptyArbitrary = NE.fromList <$> listOf1 arbitrarySourcePos
46 setErrorFancy = S.fromList <$> listOf arbitraryErrorFancy
25 setErrorFancy = S.fromList <$> listOf arbitraryErrorFancy
47 maybeErrorItem = oneof [ Just <$> arbitraryErrorItem, return Nothing]
26 maybeErrorItem = oneof [ Just <$> arbitraryErrorItem, return Nothing]
48 setErrorItem = S.fromList <$> listOf arbitraryErrorItem
27 setErrorItem = S.fromList <$> listOf arbitraryErrorItem
49
28
29+arbitrarySourcePos :: Gen SourcePos
30+arbitrarySourcePos = SourcePos <$> arbitrary <*> posArbitrary <*> posArbitrary
31+ where
32+ posArbitrary = mkPos <$> ((+1) . abs <$> arbitrary)
33+
50arbitraryErrorFancy :: Gen (ErrorFancy e)
34arbitraryErrorFancy :: Gen (ErrorFancy e)
51arbitraryErrorFancy = oneof [ ErrorFail <$> arbitrary ]
35arbitraryErrorFancy = oneof [ ErrorFail <$> arbitrary ]
52
36
@@ -88,7 +72,7 @@ spec = do
88 describe "betterThrow" $ do
72 describe "betterThrow" $ do
89 context "when given a parse error" $
73 context "when given a parse error" $
90 it "throws the correct exception" $
74 it "throws the correct exception" $
91− property $ forAll arbitraryParseErrorBundle $ \err ->
75+ property $ forAll arbitraryParseError $ \err ->
92 betterThrow (Left err) `shouldThrow`
76 betterThrow (Left err) `shouldThrow`
93 (== InflectionParsingFailed err)
77 (== InflectionParsingFailed err)
94
78