@@ -111,13 +111,11 @@ module Text.Inflections
111 , toUnderscore
111 , toUnderscore
112 , toDashed
112 , toDashed
113 , toCamelCased
113 , toCamelCased
115 , betterThrow )
114 , betterThrow )
118import Control.Monad.Catch (MonadThrow (..))
117import Control.Monad.Catch (MonadThrow (..))
119import Data.Text (Text)
118import Data.Text (Text)
120−import Data.Void (Void)
121import Text.Inflections.Camelize (camelize, camelizeCustom)
119import Text.Inflections.Camelize (camelize, camelizeCustom)
122import Text.Inflections.Dasherize (dasherize)
120import Text.Inflections.Dasherize (dasherize)
123import Text.Inflections.Data (Transliterations, defaultTransliterations)
121import Text.Inflections.Data (Transliterations, defaultTransliterations)
@@ -142,7 +140,7 @@ import Prelude hiding (Word)
143-- >>> toUnderscore "FooBarBazz"
141-- >>> toUnderscore "FooBarBazz"
144-- "foo_bar_bazz"
142-- "foo_bar_bazz"
145−toUnderscore :: Text -> Either (ParseErrorBundle Text Void) Text
143+toUnderscore :: Text -> Either (ParseError Char Dec) Text
146toUnderscore = fmap underscore . parseCamelCase []
144toUnderscore = fmap underscore . parseCamelCase []
148-- | Transforms CamelCasedString to snake-cased-string-with-dashes.
146-- | Transforms CamelCasedString to snake-cased-string-with-dashes.
@@ -151,45 +149,26 @@ toUnderscore = fmap underscore . parseCamelCase []
152-- >>> toDashed "FooBarBazz"
150-- >>> toDashed "FooBarBazz"
153-- "foo-bar-bazz"
151-- "foo-bar-bazz"
154−toDashed :: Text -> Either (ParseErrorBundle Text Void) Text
152+toDashed :: Text -> Either (ParseError Char Dec) Text
155toDashed = fmap dasherize . parseCamelCase []
153toDashed = fmap dasherize . parseCamelCase []
157-- | Transforms underscored_text to CamelCasedText. If first argument is
155-- | 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
156+-- 'True' then FirstCharacter in result string will be in upper case. If
159−-- 'False' then the first character will be in lower case.
157+-- 'False' then firstCharacter will be in lower case.
161−-- > toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
159+-- > toCamelCased t = fmap (camelizeCustom t) . parseSnakeCase []
163-- >>> toCamelCased True "foo_bar_bazz"
161-- >>> toCamelCased True "foo_bar_bazz"
164-- "FooBarBazz"
162-- "FooBarBazz"
165-- >>> toCamelCased False "foo_bar_bazz"
163-- >>> toCamelCased False "foo_bar_bazz"
166-- "fooBarBazz"
164-- "fooBarBazz"
167toCamelCased
165toCamelCased
168− :: Bool -- ^ Capitalize the first character
166+ :: Bool -- ^ Capitalize the first character
169− -> Text -- ^ Input
167+ -> Text -- ^ Input
170− -> Either (ParseErrorBundle Text Void) Text -- ^ Output
168+ -> Either (ParseError Char Dec) Text -- ^ Ouput
171−toCamelCased c = fmap (camelizeCustom c) . parseSnakeCase []
169+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
171+-- | Lift something of type @'Either' ('ParseError' 'Char' 'Dec') a@ to
193-- an instance of 'MonadThrow'. Useful when you want to shortcut on parsing
172-- an instance of 'MonadThrow'. Useful when you want to shortcut on parsing
194-- failures and you're in an instance of 'MonadThrow'.
173-- failures and you're in an instance of 'MonadThrow'.
@@ -197,6 +176,6 @@ toHumanized c = fmap (humanizeCustom c) . parseSnakeCase []
198-- /since 0.3.0.0/
177-- /since 0.3.0.0/
200−betterThrow :: MonadThrow m => Either (ParseErrorBundle Text Void) a -> m a
179+betterThrow :: MonadThrow m => Either (ParseError Char Dec) a -> m a
201betterThrow (Left err) = throwM (InflectionParsingFailed err)
180betterThrow (Left err) = throwM (InflectionParsingFailed err)
202betterThrow (Right x) = return x
181betterThrow (Right x) = return x