mirror of
https://github.com/typeable/inflections-hs.git
synced 2024-09-11 06:05:33 +03:00
Add some @since declarations
This commit is contained in:
parent
feac25f60c
commit
008c070982
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user