@@ -96,7 +96,6 @@ module Text.Inflections
96 , camelizeCustom
96 , camelizeCustom
97 , dasherize
97 , dasherize
98 , humanize
98 , humanize
100 , underscore
99 , underscore
101 , titleize
100 , titleize
102 , Transliterations
101 , Transliterations
@@ -111,17 +110,15 @@ module Text.Inflections
111 , toUnderscore
110 , toUnderscore
112 , toDashed
111 , toDashed
113 , toCamelCased
112 , toCamelCased
115 , betterThrow )
113 , betterThrow )
118import Control.Monad.Catch (MonadThrow (..))
116import Control.Monad.Catch (MonadThrow (..))
119import Data.Text (Text)
117import Data.Text (Text)
120−import Data.Void (Void)
121import Text.Inflections.Camelize (camelize, camelizeCustom)
118import Text.Inflections.Camelize (camelize, camelizeCustom)
122import Text.Inflections.Dasherize (dasherize)
119import Text.Inflections.Dasherize (dasherize)
123import Text.Inflections.Data (Transliterations, defaultTransliterations)
120import Text.Inflections.Data (Transliterations, defaultTransliterations)
124−import Text.Inflections.Humanize (humanize, humanizeCustom)
121+import Text.Inflections.Humanize (humanize)
125import Text.Inflections.Ordinal (ordinal, ordinalize)
122import Text.Inflections.Ordinal (ordinal, ordinalize)
126import Text.Inflections.Parameterize (parameterize, parameterizeCustom)
123import Text.Inflections.Parameterize (parameterize, parameterizeCustom)
127import Text.Inflections.Parse.CamelCase (parseCamelCase)
124import Text.Inflections.Parse.CamelCase (parseCamelCase)
@@ -142,7 +139,7 @@ import Prelude hiding (Word)
143-- >>> toUnderscore "FooBarBazz"
140-- >>> toUnderscore "FooBarBazz"
144-- "foo_bar_bazz"
141-- "foo_bar_bazz"
145−toUnderscore :: Text -> Either (ParseErrorBundle Text Void) Text
142+toUnderscore :: Text -> Either (ParseError Char Dec) Text
146toUnderscore = fmap underscore . parseCamelCase []
143toUnderscore = fmap underscore . parseCamelCase []
148-- | Transforms CamelCasedString to snake-cased-string-with-dashes.
145-- | Transforms CamelCasedString to snake-cased-string-with-dashes.
@@ -151,45 +148,26 @@ toUnderscore = fmap underscore . parseCamelCase []
152-- >>> toDashed "FooBarBazz"
149-- >>> toDashed "FooBarBazz"
153-- "foo-bar-bazz"
150-- "foo-bar-bazz"
154−toDashed :: Text -> Either (ParseErrorBundle Text Void) Text
151+toDashed :: Text -> Either (ParseError Char Dec) Text
155toDashed = fmap dasherize . parseCamelCase []
152toDashed = fmap dasherize . parseCamelCase []
157-- | Transforms underscored_text to CamelCasedText. If first argument is
154-- | Transforms underscored_text to CamelCasedText. If first argument is
158−-- 'True' then the first character in the result string will be in upper case. If
155+-- 'True' then FirstCharacter in result string will be in upper case. If
159−-- 'False' then the first character will be in lower case.
156+-- 'False' then firstCharacter will be in lower case.
161−-- > toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
158+-- > toCamelCased t = fmap (camelizeCustom t) . parseSnakeCase []
163-- >>> toCamelCased True "foo_bar_bazz"
160-- >>> toCamelCased True "foo_bar_bazz"
164-- "FooBarBazz"
161-- "FooBarBazz"
165-- >>> toCamelCased False "foo_bar_bazz"
162-- >>> toCamelCased False "foo_bar_bazz"
166-- "fooBarBazz"
163-- "fooBarBazz"
167toCamelCased
164toCamelCased
168− :: Bool -- ^ Capitalize the first character
165+ :: Bool -- ^ Capitalize the first character
169− -> Text -- ^ Input
166+ -> Text -- ^ Input
170− -> Either (ParseErrorBundle Text Void) Text -- ^ Output
167+ -> Either (ParseError Char Dec) Text -- ^ Ouput
171−toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
168+toCamelCased t = fmap (camelizeCustom t) . parseSnakeCase []
173−-- | Transforms underscored_text to space-separated human-readable text.
174−-- If first argument is 'True' then the first character in the result
175−-- string will be in upper case. If 'False' then the first character will be
178−-- > toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
180−-- >>> toHumanized True "foo_bar_bazz"
182−-- >>> toHumanized False "foo_bar_bazz"
187− :: Bool -- ^ Capitalize the first character
189− -> Either (ParseErrorBundle Text Void) Text -- ^ Output
190−toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
192−-- | Lift something of type @'Either' ('ParseError' 'Char' 'Void') a@ to
170+-- | Lift something of type @'Either' ('ParseError' 'Char' 'Dec') a@ to
193-- an instance of 'MonadThrow'. Useful when you want to shortcut on parsing
171-- an instance of 'MonadThrow'. Useful when you want to shortcut on parsing
194-- failures and you're in an instance of 'MonadThrow'.
172-- failures and you're in an instance of 'MonadThrow'.
@@ -197,6 +175,6 @@ toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
198-- /since 0.3.0.0/
176-- /since 0.3.0.0/
200−betterThrow :: MonadThrow m => Either (ParseErrorBundle Text Void) a -> m a
178+betterThrow :: MonadThrow m => Either (ParseError Char Dec) a -> m a
201betterThrow (Left err) = throwM (InflectionParsingFailed err)
179betterThrow (Left err) = throwM (InflectionParsingFailed err)
202betterThrow (Right x) = return x
180betterThrow (Right x) = return x