inflections 0.4.0.3 → 0.4.0.4
raw patch · 7 files changed
+43/−23 lines, 7 filesdep ~hspec-megaparsecdep ~megaparsecPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: hspec-megaparsec, megaparsec
API changes (from Hackage documentation)
- Text.Inflections: InflectionParsingFailed :: (ParseError Char Void) -> InflectionException
+ Text.Inflections: InflectionParsingFailed :: (ParseErrorBundle Text Void) -> InflectionException
- Text.Inflections: betterThrow :: MonadThrow m => Either (ParseError Char Void) a -> m a
+ Text.Inflections: betterThrow :: MonadThrow m => Either (ParseErrorBundle Text Void) a -> m a
- Text.Inflections: parseCamelCase :: (Foldable f, Functor f) => f (Word 'Acronym) -> Text -> Either (ParseError Char Void) [SomeWord]
+ Text.Inflections: parseCamelCase :: (Foldable f, Functor f) => f (Word 'Acronym) -> Text -> Either (ParseErrorBundle Text Void) [SomeWord]
- Text.Inflections: parseSnakeCase :: (Foldable f, Functor f) => f (Word 'Acronym) -> Text -> Either (ParseError Char Void) [SomeWord]
+ Text.Inflections: parseSnakeCase :: (Foldable f, Functor f) => f (Word 'Acronym) -> Text -> Either (ParseErrorBundle Text Void) [SomeWord]
- Text.Inflections: toCamelCased :: Bool -> Text -> Either (ParseError Char Void) Text
+ Text.Inflections: toCamelCased :: Bool -> Text -> Either (ParseErrorBundle Text Void) Text
- Text.Inflections: toDashed :: Text -> Either (ParseError Char Void) Text
+ Text.Inflections: toDashed :: Text -> Either (ParseErrorBundle Text Void) Text
- Text.Inflections: toHumanized :: Bool -> Text -> Either (ParseError Char Void) Text
+ Text.Inflections: toHumanized :: Bool -> Text -> Either (ParseErrorBundle Text Void) Text
- Text.Inflections: toUnderscore :: Text -> Either (ParseError Char Void) Text
+ Text.Inflections: toUnderscore :: Text -> Either (ParseErrorBundle Text Void) Text
Files
- CHANGELOG.md +4/−0
- Text/Inflections.hs +5/−5
- Text/Inflections/Parse/CamelCase.hs +2/−2
- Text/Inflections/Parse/SnakeCase.hs +2/−2
- Text/Inflections/Types.hs +1/−1
- inflections.cabal +3/−3
- test/Text/InflectionsSpec.hs +26/−10
CHANGELOG.md view
@@ -1,4 +1,8 @@ ## Inflections 0.4.0.3+* Support `megaparsec` == 7.0*.+* **Drop support** for `GHC 7.8.4`.++## Inflections 0.4.0.3 * Support `exceptions` == 0.10.* ## Inflections 0.4.0.2
Text/Inflections.hs view
@@ -142,7 +142,7 @@ -- -- >>> toUnderscore "FooBarBazz" -- "foo_bar_bazz"-toUnderscore :: Text -> Either (ParseError Char Void) Text+toUnderscore :: Text -> Either (ParseErrorBundle Text Void) Text toUnderscore = fmap underscore . parseCamelCase [] -- | Transforms CamelCasedString to snake-cased-string-with-dashes.@@ -151,7 +151,7 @@ -- -- >>> toDashed "FooBarBazz" -- "foo-bar-bazz"-toDashed :: Text -> Either (ParseError Char Void) Text+toDashed :: Text -> Either (ParseErrorBundle Text Void) Text toDashed = fmap dasherize . parseCamelCase [] -- | Transforms underscored_text to CamelCasedText. If first argument is@@ -167,7 +167,7 @@ toCamelCased :: Bool -- ^ Capitalize the first character -> Text -- ^ Input- -> Either (ParseError Char Void) Text -- ^ Output+ -> Either (ParseErrorBundle Text Void) Text -- ^ Output toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase [] -- | Transforms underscored_text to space-separated human-readable text.@@ -186,7 +186,7 @@ toHumanized :: Bool -- ^ Capitalize the first character -> Text -- ^ Input- -> Either (ParseError Char Void) Text -- ^ Output+ -> Either (ParseErrorBundle Text Void) Text -- ^ Output toHumanized c = fmap (humanizeCustom c) . parseSnakeCase [] -- | Lift something of type @'Either' ('ParseError' 'Char' 'Void') a@ to@@ -197,6 +197,6 @@ -- -- /since 0.3.0.0/ -betterThrow :: MonadThrow m => Either (ParseError Char Void) a -> m a+betterThrow :: MonadThrow m => Either (ParseErrorBundle Text Void) a -> m a betterThrow (Left err) = throwM (InflectionParsingFailed err) betterThrow (Right x) = return x
Text/Inflections/Parse/CamelCase.hs view
@@ -25,7 +25,7 @@ import Data.Text (Text) import Data.Void (Void) import Text.Inflections.Types-import Text.Megaparsec (Parsec, ParseError, choice, eof, parse)+import Text.Megaparsec (Parsec, ParseErrorBundle, choice, eof, parse) import Text.Megaparsec.Char import qualified Data.Text as T @@ -51,7 +51,7 @@ parseCamelCase :: (Foldable f, Functor f) => f (Word 'Acronym) -- ^ Collection of acronyms -> Text -- ^ Input- -> Either (ParseError Char Void) [SomeWord] -- ^ Result of parsing+ -> Either (ParseErrorBundle Text Void) [SomeWord] -- ^ Result of parsing parseCamelCase acronyms = parse (parser acronyms) "" parser :: (Foldable f, Functor f)
Text/Inflections/Parse/SnakeCase.hs view
@@ -24,7 +24,7 @@ import Data.Text (Text) import Data.Void (Void) import Text.Inflections.Types-import Text.Megaparsec (Parsec, ParseError, eof, sepBy, parse)+import Text.Megaparsec (Parsec, ParseErrorBundle, eof, sepBy, parse) import Text.Megaparsec.Char import qualified Data.Text as T @@ -50,7 +50,7 @@ parseSnakeCase :: (Foldable f, Functor f) => f (Word 'Acronym) -- ^ Collection of acronyms -> Text -- ^ Input- -> Either (ParseError Char Void) [SomeWord] -- ^ Result of parsing+ -> Either (ParseErrorBundle Text Void) [SomeWord] -- ^ Result of parsing parseSnakeCase acronyms = parse (parser acronyms) "" parser :: (Foldable f, Functor f)
Text/Inflections/Types.hs view
@@ -136,7 +136,7 @@ -- /since 0.3.0.0/ data InflectionException- = InflectionParsingFailed (ParseError Char Void)+ = InflectionParsingFailed (ParseErrorBundle Text Void) | InflectionInvalidWord Text | InflectionInvalidAcronym Text deriving (Eq, Show, Typeable, Data, Generic)
inflections.cabal view
@@ -1,5 +1,5 @@ name: inflections-version: 0.4.0.3+version: 0.4.0.4 synopsis: Inflections library for Haskell description: Inflections provides methods for singularization, pluralization,@@ -49,7 +49,7 @@ ghc-options: -O2 -Wall build-depends: base >= 4.6 && < 5.0 , exceptions >= 0.6 && < 0.11- , megaparsec >= 6.0 && < 7.0+ , megaparsec >= 7.0.1 && < 8.0 , text >= 0.2 && < 1.3 , unordered-containers >= 0.2.7 && < 0.3 if !impl(ghc >= 7.10)@@ -66,7 +66,7 @@ , base >= 4.6 && < 5.0 , containers >= 0.5 && < 0.7 , hspec >= 2.0 && < 3.0- , hspec-megaparsec >= 1.0 && < 2.0+ , hspec-megaparsec >= 2.0 && < 3.0 , megaparsec , text >= 0.2 && < 1.3 if !impl(ghc >= 7.10)
test/Text/InflectionsSpec.hs view
@@ -1,3 +1,4 @@+{-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} @@ -8,6 +9,7 @@ import Test.QuickCheck import Text.Inflections import Text.Megaparsec+import Data.Text import qualified Data.List.NonEmpty as NE import qualified Data.Set as S@@ -16,21 +18,35 @@ import Control.Applicative #endif -arbitraryParseError :: Gen (ParseError Char Void)+instance Arbitrary Text where+ arbitrary = pack <$> (arbitrary :: Gen String)++arbitraryParseErrorBundle :: Gen (ParseErrorBundle Text Void)+arbitraryParseErrorBundle = ParseErrorBundle <$> nonEmptyParseErrors <*> arbitraryPosState+ where+ posArbitrary = mkPos <$> ((+1) . abs <$> arbitrary)+ nonEmptyParseErrors :: Gen (NE.NonEmpty (ParseError Text Void))+ nonEmptyParseErrors = NE.fromList <$> listOf1 arbitraryParseError+ arbitrarySourcePos :: Gen SourcePos+ arbitrarySourcePos = SourcePos <$> arbitrary <*> posArbitrary <*> posArbitrary+ arbitraryPosState :: Gen (PosState Text)+ arbitraryPosState =+ PosState+ <$> arbitrary+ <*> arbitrary+ <*> arbitrarySourcePos+ <*> posArbitrary+ <*> arbitrary++arbitraryParseError :: Gen (ParseError Text Void) arbitraryParseError = oneof [trivialError, fancyError] where- trivialError = TrivialError <$> nonEmptyArbitrary <*> maybeErrorItem <*> setErrorItem- fancyError = FancyError <$> nonEmptyArbitrary <*> setErrorFancy- nonEmptyArbitrary = NE.fromList <$> listOf1 arbitrarySourcePos+ trivialError = TrivialError <$> arbitrary <*> maybeErrorItem <*> setErrorItem+ fancyError = FancyError <$> arbitrary <*> setErrorFancy setErrorFancy = S.fromList <$> listOf arbitraryErrorFancy maybeErrorItem = oneof [ Just <$> arbitraryErrorItem, return Nothing] setErrorItem = S.fromList <$> listOf arbitraryErrorItem -arbitrarySourcePos :: Gen SourcePos-arbitrarySourcePos = SourcePos <$> arbitrary <*> posArbitrary <*> posArbitrary- where- posArbitrary = mkPos <$> ((+1) . abs <$> arbitrary)- arbitraryErrorFancy :: Gen (ErrorFancy e) arbitraryErrorFancy = oneof [ ErrorFail <$> arbitrary ] @@ -72,7 +88,7 @@ describe "betterThrow" $ do context "when given a parse error" $ it "throws the correct exception" $- property $ forAll arbitraryParseError $ \err ->+ property $ forAll arbitraryParseErrorBundle $ \err -> betterThrow (Left err) `shouldThrow` (== InflectionParsingFailed err)