git.iko.soy/typeable/inflections-hs
on master help sign in
15 files changed+159−67
since splitsnapshots
unifiedsplit
.travis.yml+8−3 CHANGELOG.md+16 LICENSE+17−18 README.md+11−8 Text/Inflections.hs+5−5 Text/Inflections/Ordinal.hs−1 Text/Inflections/Parse/CamelCase.hs+2−2 Text/Inflections/Parse/SnakeCase.hs+2−2 Text/Inflections/Types.hs+1−1 docs/CODE_OF_CONDUCT.md+35 docs/CONTRIBUTING.md+13 inflections.cabal+10−10 stack.yaml+1−7 stack.yaml.lock+12 test/Text/InflectionsSpec.hs+26−10
.travis.yml+8−3
@@ -9,12 +9,14 @@ cache:
99
1010matrix:
1111 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]}}
1412 - env: CABALVER=1.24 GHCVER=7.10.3
1513 addons: {apt: {packages: [cabal-install-1.24,ghc-7.10.3],sources: [hvr-ghc]}}
1614 - env: CABALVER=1.24 GHCVER=8.0.2
1715 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]}}
1820
1921before_install:
2022 - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
@@ -32,7 +34,10 @@ script:
3234 esac
3335 - cabal build
3436 - cabal sdist
35− - cabal haddock | grep "100%" | wc -l | grep "13"
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" ;;
40+ esac
3641
3742notifications:
3843 email: false
CHANGELOG.md+16
@@ -1,3 +1,19 @@
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+
117## Inflections 0.4.0.1
218* Support `megaparsec` >= 6.4.0
319
LICENSE+17−18
@@ -1,22 +1,21 @@
1−Copyright (c) 2014-2016 Justin Leitgeb
2−
31MIT License
42
5−Permission is hereby granted, free of charge, to any person obtaining
6−a copy of this software and associated documentation files (the
7−"Software"), to deal in the Software without restriction, including
8−without limitation the rights to use, copy, modify, merge, publish,
9−distribute, sublicense, and/or sell copies of the Software, and to
10−permit persons to whom the Software is furnished to do so, subject to
11−the following conditions:
3+Copyright (c) 2022 Stack Builders Inc.
4+
5+Permission is hereby granted, free of charge, to any person obtaining a copy
6+of this software and associated documentation files (the "Software"), to deal
7+in the Software without restriction, including without limitation the rights
8+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+copies of the Software, and to permit persons to whom the Software is
10+furnished to do so, subject to the following conditions:
1211
13−The above copyright notice and this permission notice shall be
14−included in all copies or substantial portions of the Software.
12+The above copyright notice and this permission notice shall be included in all
13+copies or substantial portions of the Software.
1514
16−THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17−EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18−MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19−NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20−LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21−OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22−WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+SOFTWARE.
README.md+11−8
@@ -49,11 +49,10 @@ If you want to specify a custom default replacement or approximation table for
4949the `transliterate` function, you should instead call the `transliterateCustom`
5050function which accepts a String for replacements and a Map for substitution.
5151
52−## TODO
52+## Future work
5353
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
56−request!
54+Ideally, we want to implement other functions found in the Rails
55+inflections library. If you need one of those functions, please submit a pull request!
5756
5857## Further documentation
5958
@@ -64,10 +63,14 @@ For more information, please see the the
6463
6564Justin Leitgeb <justin@stackbuilders.com>
6665
67−## Contributing
66+## License
6867
69−You may submit pull requests to this repository on GitHub. Tests are appreciated with your contribution.
68+MIT, see [the LICENSE file](LICENSE).
7069
71−## License
70+## Contributing
71+
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.
7273
73−MIT - see [the LICENSE file](LICENSE).
74+---
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)
142142--
143143-- >>> toUnderscore "FooBarBazz"
144144-- "foo_bar_bazz"
145−toUnderscore :: Text -> Either (ParseError Char Void) Text
145+toUnderscore :: Text -> Either (ParseErrorBundle Text Void) Text
146146toUnderscore = fmap underscore . parseCamelCase []
147147
148148-- | Transforms CamelCasedString to snake-cased-string-with-dashes.
@@ -151,7 +151,7 @@ toUnderscore = fmap underscore . parseCamelCase []
151151--
152152-- >>> toDashed "FooBarBazz"
153153-- "foo-bar-bazz"
154−toDashed :: Text -> Either (ParseError Char Void) Text
154+toDashed :: Text -> Either (ParseErrorBundle Text Void) Text
155155toDashed = fmap dasherize . parseCamelCase []
156156
157157-- | Transforms underscored_text to CamelCasedText. If first argument is
@@ -167,7 +167,7 @@ toDashed = fmap dasherize . parseCamelCase []
167167toCamelCased
168168 :: Bool -- ^ Capitalize the first character
169169 -> Text -- ^ Input
170− -> Either (ParseError Char Void) Text -- ^ Output
170+ -> Either (ParseErrorBundle Text Void) Text -- ^ Output
171171toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
172172
173173-- | Transforms underscored_text to space-separated human-readable text.
@@ -186,7 +186,7 @@ toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
186186toHumanized
187187 :: Bool -- ^ Capitalize the first character
188188 -> Text -- ^ Input
189− -> Either (ParseError Char Void) Text -- ^ Output
189+ -> Either (ParseErrorBundle Text Void) Text -- ^ Output
190190toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
191191
192192-- | Lift something of type @'Either' ('ParseError' 'Char' 'Void') a@ to
@@ -197,6 +197,6 @@ toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
197197--
198198-- /since 0.3.0.0/
199199
200−betterThrow :: MonadThrow m => Either (ParseError Char Void) a -> m a
200+betterThrow :: MonadThrow m => Either (ParseErrorBundle Text Void) a -> m a
201201betterThrow (Left err) = throwM (InflectionParsingFailed err)
202202betterThrow (Right x) = return x
Text/Inflections/Ordinal.hs−1
@@ -16,7 +16,6 @@ module Text.Inflections.Ordinal
1616 , ordinal )
1717where
1818
19−import Data.Monoid ((<>))
2019import Data.Text (Text)
2120import qualified Data.Text as T
2221
Text/Inflections/Parse/CamelCase.hs+2−2
@@ -25,7 +25,7 @@ import Control.Applicative (empty, many, (<|>), (<$>), (<*))
2525import Data.Text (Text)
2626import Data.Void (Void)
2727import Text.Inflections.Types
28−import Text.Megaparsec (Parsec, ParseError, choice, eof, parse)
28+import Text.Megaparsec (Parsec, ParseErrorBundle, choice, eof, parse)
2929import Text.Megaparsec.Char
3030import qualified Data.Text as T
3131
@@ -51,7 +51,7 @@ type Parser = Parsec Void Text
5151parseCamelCase :: (Foldable f, Functor f)
5252 => f (Word 'Acronym) -- ^ Collection of acronyms
5353 -> Text -- ^ Input
54− -> Either (ParseError Char Void) [SomeWord] -- ^ Result of parsing
54+ -> Either (ParseErrorBundle Text Void) [SomeWord] -- ^ Result of parsing
5555parseCamelCase acronyms = parse (parser acronyms) ""
5656
5757parser :: (Foldable f, Functor f)
Text/Inflections/Parse/SnakeCase.hs+2−2
@@ -24,7 +24,7 @@ import Control.Applicative (empty, some, (<$>), (<*))
2424import Data.Text (Text)
2525import Data.Void (Void)
2626import Text.Inflections.Types
27−import Text.Megaparsec (Parsec, ParseError, eof, sepBy, parse)
27+import Text.Megaparsec (Parsec, ParseErrorBundle, eof, sepBy, parse)
2828import Text.Megaparsec.Char
2929import qualified Data.Text as T
3030
@@ -50,7 +50,7 @@ type Parser = Parsec Void Text
5050parseSnakeCase :: (Foldable f, Functor f)
5151 => f (Word 'Acronym) -- ^ Collection of acronyms
5252 -> Text -- ^ Input
53− -> Either (ParseError Char Void) [SomeWord] -- ^ Result of parsing
53+ -> Either (ParseErrorBundle Text Void) [SomeWord] -- ^ Result of parsing
5454parseSnakeCase acronyms = parse (parser acronyms) ""
5555
5656parser :: (Foldable f, Functor f)
Text/Inflections/Types.hs+1−1
@@ -136,7 +136,7 @@ instance Transformable (Word 'Acronym) where
136136-- /since 0.3.0.0/
137137
138138data InflectionException
139− = InflectionParsingFailed (ParseError Char Void)
139+ = InflectionParsingFailed (ParseErrorBundle Text Void)
140140 | InflectionInvalidWord Text
141141 | InflectionInvalidAcronym Text
142142 deriving (Eq, Show, Typeable, Data, Generic)
docs/CODE_OF_CONDUCT.mdnew file+35
@@ -0,0 +1,35 @@
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.mdnew file+13
@@ -0,0 +1,13 @@
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 @@
11name: inflections
2−version: 0.4.0.1
2+version: 0.4.0.6
33synopsis: Inflections library for Haskell
44description:
55 Inflections provides methods for singularization, pluralization,
@@ -48,10 +48,10 @@ library
4848 else
4949 ghc-options: -O2 -Wall
5050 build-depends: base >= 4.6 && < 5.0
51− , exceptions >= 0.6 && < 0.9
52− , megaparsec >= 6.0 && < 7.0
53− , text >= 0.2 && < 1.3
54− , unordered-containers >= 0.2.7 && < 0.3
51+ , exceptions
52+ , megaparsec
53+ , text
54+ , unordered-containers
5555 if !impl(ghc >= 7.10)
5656 build-depends: void == 0.7.*
5757
@@ -62,13 +62,13 @@ test-suite test
6262 hs-source-dirs: test
6363 main-is: Spec.hs
6464 build-depends: inflections
65− , QuickCheck >= 2.7.6 && < 3.0
65+ , QuickCheck
6666 , base >= 4.6 && < 5.0
67− , containers >= 0.5 && < 0.7
68− , hspec >= 2.0 && < 3.0
69− , hspec-megaparsec >= 1.0 && < 2.0
67+ , containers
68+ , hspec
69+ , hspec-megaparsec
7070 , megaparsec
71− , text >= 0.2 && < 1.3
71+ , text
7272 if !impl(ghc >= 7.10)
7373 build-depends: void == 0.7.*
7474
stack.yaml+1−7
@@ -1,7 +1 @@
1−---
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
1+resolver: lts-21.3
stack.yaml.locknew file+12
@@ -0,0 +1,12 @@
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+26−10
@@ -1,3 +1,4 @@
1+{-# OPTIONS_GHC -fno-warn-orphans #-}
12{-# LANGUAGE CPP #-}
23{-# LANGUAGE OverloadedStrings #-}
34
@@ -8,6 +9,7 @@ import Test.Hspec
89import Test.QuickCheck
910import Text.Inflections
1011import Text.Megaparsec
12+import Data.Text
1113
1214import qualified Data.List.NonEmpty as NE
1315import qualified Data.Set as S
@@ -16,21 +18,35 @@ import qualified Data.Set as S
1618import Control.Applicative
1719#endif
1820
19−arbitraryParseError :: Gen (ParseError Char Void)
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
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)
2042arbitraryParseError = oneof [trivialError, fancyError]
2143 where
22− trivialError = TrivialError <$> nonEmptyArbitrary <*> maybeErrorItem <*> setErrorItem
23− fancyError = FancyError <$> nonEmptyArbitrary <*> setErrorFancy
24− nonEmptyArbitrary = NE.fromList <$> listOf1 arbitrarySourcePos
44+ trivialError = TrivialError <$> arbitrary <*> maybeErrorItem <*> setErrorItem
45+ fancyError = FancyError <$> arbitrary <*> setErrorFancy
2546 setErrorFancy = S.fromList <$> listOf arbitraryErrorFancy
2647 maybeErrorItem = oneof [ Just <$> arbitraryErrorItem, return Nothing]
2748 setErrorItem = S.fromList <$> listOf arbitraryErrorItem
2849
29−arbitrarySourcePos :: Gen SourcePos
30−arbitrarySourcePos = SourcePos <$> arbitrary <*> posArbitrary <*> posArbitrary
31− where
32− posArbitrary = mkPos <$> ((+1) . abs <$> arbitrary)
33−
3450arbitraryErrorFancy :: Gen (ErrorFancy e)
3551arbitraryErrorFancy = oneof [ ErrorFail <$> arbitrary ]
3652
@@ -72,7 +88,7 @@ spec = do
7288 describe "betterThrow" $ do
7389 context "when given a parse error" $
7490 it "throws the correct exception" $
75− property $ forAll arbitraryParseError $ \err ->
91+ property $ forAll arbitraryParseErrorBundle $ \err ->
7692 betterThrow (Left err) `shouldThrow`
7793 (== InflectionParsingFailed err)
7894