@@ -111,13 +111,11 @@ module Text.Inflections
111111 , toUnderscore
112112 , toDashed
113113 , toCamelCased
114− , toHumanized
115114 , betterThrow )
116115where
117116
118117import Control.Monad.Catch (MonadThrow (..))
119118import Data.Text (Text)
120−import Data.Void (Void)
121119import Text.Inflections.Camelize (camelize, camelizeCustom)
122120import Text.Inflections.Dasherize (dasherize)
123121import Text.Inflections.Data (Transliterations, defaultTransliterations)
@@ -142,7 +140,7 @@ import Prelude hiding (Word)
142140--
143141-- >>> toUnderscore "FooBarBazz"
144142-- "foo_bar_bazz"
145−toUnderscore :: Text -> Either (ParseErrorBundle Text Void) Text
143+toUnderscore :: Text -> Either (ParseError Char Dec) Text
146144toUnderscore = fmap underscore . parseCamelCase []
147145
148146-- | Transforms CamelCasedString to snake-cased-string-with-dashes.
@@ -151,45 +149,26 @@ toUnderscore = fmap underscore . parseCamelCase []
151149--
152150-- >>> toDashed "FooBarBazz"
153151-- "foo-bar-bazz"
154−toDashed :: Text -> Either (ParseErrorBundle Text Void) Text
152+toDashed :: Text -> Either (ParseError Char Dec) Text
155153toDashed = fmap dasherize . parseCamelCase []
156154
157155-- | 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.
156+-- 'True' then FirstCharacter in result string will be in upper case. If
157+-- 'False' then firstCharacter will be in lower case.
160158--
161−-- > toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
159+-- > toCamelCased t = fmap (camelizeCustom t) . parseSnakeCase []
162160--
163161-- >>> toCamelCased True "foo_bar_bazz"
164162-- "FooBarBazz"
165163-- >>> toCamelCased False "foo_bar_bazz"
166164-- "fooBarBazz"
167165toCamelCased
168− :: Bool -- ^ Capitalize the first character
169− -> Text -- ^ Input
170− -> Either (ParseErrorBundle Text Void) Text -- ^ Output
171−toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
166+ :: Bool -- ^ Capitalize the first character
167+ -> Text -- ^ Input
168+ -> Either (ParseError Char Dec) Text -- ^ Ouput
169+toCamelCased t = fmap (camelizeCustom t) . parseSnakeCase []
172170
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
171+-- | Lift something of type @'Either' ('ParseError' 'Char' 'Dec') a@ to
193172-- an instance of 'MonadThrow'. Useful when you want to shortcut on parsing
194173-- failures and you're in an instance of 'MonadThrow'.
195174--
@@ -197,6 +176,6 @@ toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
197176--
198177-- /since 0.3.0.0/
199178
200−betterThrow :: MonadThrow m => Either (ParseErrorBundle Text Void) a -> m a
179+betterThrow :: MonadThrow m => Either (ParseError Char Dec) a -> m a
201180betterThrow (Left err) = throwM (InflectionParsingFailed err)
202181betterThrow (Right x) = return x