@@ -96,7 +96,6 @@ module Text.Inflections
9696 , camelizeCustom
9797 , dasherize
9898 , humanize
99− , humanizeCustom
10099 , underscore
101100 , titleize
102101 , Transliterations
@@ -111,17 +110,15 @@ module Text.Inflections
111110 , toUnderscore
112111 , toDashed
113112 , toCamelCased
114− , toHumanized
115113 , betterThrow )
116114where
117115
118116import Control.Monad.Catch (MonadThrow (..))
119117import Data.Text (Text)
120−import Data.Void (Void)
121118import Text.Inflections.Camelize (camelize, camelizeCustom)
122119import Text.Inflections.Dasherize (dasherize)
123120import Text.Inflections.Data (Transliterations, defaultTransliterations)
124−import Text.Inflections.Humanize (humanize, humanizeCustom)
121+import Text.Inflections.Humanize (humanize)
125122import Text.Inflections.Ordinal (ordinal, ordinalize)
126123import Text.Inflections.Parameterize (parameterize, parameterizeCustom)
127124import Text.Inflections.Parse.CamelCase (parseCamelCase)
@@ -142,7 +139,7 @@ import Prelude hiding (Word)
142139--
143140-- >>> toUnderscore "FooBarBazz"
144141-- "foo_bar_bazz"
145−toUnderscore :: Text -> Either (ParseErrorBundle Text Void) Text
142+toUnderscore :: Text -> Either (ParseError Char Dec) Text
146143toUnderscore = fmap underscore . parseCamelCase []
147144
148145-- | Transforms CamelCasedString to snake-cased-string-with-dashes.
@@ -151,45 +148,26 @@ toUnderscore = fmap underscore . parseCamelCase []
151148--
152149-- >>> toDashed "FooBarBazz"
153150-- "foo-bar-bazz"
154−toDashed :: Text -> Either (ParseErrorBundle Text Void) Text
151+toDashed :: Text -> Either (ParseError Char Dec) Text
155152toDashed = fmap dasherize . parseCamelCase []
156153
157154-- | 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
159−-- 'False' then the first character will be in lower case.
155+-- 'True' then FirstCharacter in result string will be in upper case. If
156+-- 'False' then firstCharacter will be in lower case.
160157--
161−-- > toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
158+-- > toCamelCased t = fmap (camelizeCustom t) . parseSnakeCase []
162159--
163160-- >>> toCamelCased True "foo_bar_bazz"
164161-- "FooBarBazz"
165162-- >>> toCamelCased False "foo_bar_bazz"
166163-- "fooBarBazz"
167164toCamelCased
168− :: Bool -- ^ Capitalize the first character
169− -> Text -- ^ Input
170− -> Either (ParseErrorBundle Text Void) Text -- ^ Output
171−toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
165+ :: Bool -- ^ Capitalize the first character
166+ -> Text -- ^ Input
167+ -> Either (ParseError Char Dec) Text -- ^ Ouput
168+toCamelCased t = fmap (camelizeCustom t) . parseSnakeCase []
172169
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
176−-- in lower case.
177−--
178−-- > toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
179−--
180−-- >>> toHumanized True "foo_bar_bazz"
181−-- "Foo bar bazz"
182−-- >>> toHumanized False "foo_bar_bazz"
183−-- "foo bar bazz"
184−--
185−-- /since 0.3.0.0/
186−toHumanized
187− :: Bool -- ^ Capitalize the first character
188− -> Text -- ^ Input
189− -> Either (ParseErrorBundle Text Void) Text -- ^ Output
190−toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
191−
192−-- | Lift something of type @'Either' ('ParseError' 'Char' 'Void') a@ to
170+-- | Lift something of type @'Either' ('ParseError' 'Char' 'Dec') a@ to
193171-- an instance of 'MonadThrow'. Useful when you want to shortcut on parsing
194172-- failures and you're in an instance of 'MonadThrow'.
195173--
@@ -197,6 +175,6 @@ toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
197175--
198176-- /since 0.3.0.0/
199177
200−betterThrow :: MonadThrow m => Either (ParseErrorBundle Text Void) a -> m a
178+betterThrow :: MonadThrow m => Either (ParseError Char Dec) a -> m a
201179betterThrow (Left err) = throwM (InflectionParsingFailed err)
202180betterThrow (Right x) = return x