From 008c07098267f2f27c4ea2ddb9c52b9b6d2208f2 Mon Sep 17 00:00:00 2001 From: mrkkrp Date: Wed, 21 Dec 2016 15:14:17 +0300 Subject: [PATCH] Add some @since declarations --- Text/Inflections/Types.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Text/Inflections/Types.hs b/Text/Inflections/Types.hs index 90c01cf..011b22e 100644 --- a/Text/Inflections/Types.hs +++ b/Text/Inflections/Types.hs @@ -45,6 +45,8 @@ import Prelude hiding (Word) -- | Create a word from given 'Text'. The input should not contain spaces or -- 'InflectionInvalidWord' will be thrown. +-- +-- @since 0.3.0.0 mkWord :: MonadThrow m => Text -> m (Word 'Normal) mkWord txt = @@ -55,6 +57,8 @@ mkWord txt = -- | Create an acronym from given 'Text'. The input should not contain -- spaces or 'InflectionInvalidAcronym' will be thrown. Acronym is different -- from normal word by that it may not be transformed by inflections. +-- +-- @since 0.3.0.0 mkAcronym :: MonadThrow m => Text -> m (Word 'Acronym) mkAcronym txt = @@ -63,6 +67,7 @@ mkAcronym txt = else return (Word txt) -- | A 'Text' value that should be kept whole through applied inflections. + data Word (t :: WordType) = Word Text deriving (Eq, Ord) @@ -73,16 +78,23 @@ instance Show (Word 'Acronym) where show (Word x) = "Acronym " ++ show x -- | A type-level tag for words. +-- +-- @since 0.3.0.0 data WordType = Normal | Acronym -- | Get a 'Text' value from 'Word'. +-- +-- @since 0.3.0.0 + unWord :: Word t -> Text unWord (Word s) = s -- | An existential wrapper that allows to keep words and acronyms in single -- list for example. The only thing that receiver of 'SomeWord' can do is to -- apply 'unWord' on it, of course. This is faciliated by 'unSomeWord'. +-- +-- @since 0.3.0.0 data SomeWord where SomeWord :: (Transformable (Word t), Show (Word t)) => Word t -> SomeWord @@ -96,6 +108,8 @@ instance Show SomeWord where -- | Extract 'Text' from 'SomeWord' and apply given function only if the -- word inside wasn't an acronym. +-- +-- @since 0.3.0.0 unSomeWord :: (Text -> Text) -> SomeWord -> Text unSomeWord f (SomeWord w) = transform f w @@ -112,6 +126,8 @@ instance Transformable (Word 'Acronym) where transform _ = unWord -- | The exceptions that is thrown when parsing of input fails. +-- +-- @since 0.3.0.0 data InflectionException = InflectionParsingFailed (ParseError Char Dec)