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
|
-- | Create a word from given 'Text'. The input should not contain spaces or
|
||||||
-- 'InflectionInvalidWord' will be thrown.
|
-- 'InflectionInvalidWord' will be thrown.
|
||||||
|
--
|
||||||
|
-- @since 0.3.0.0
|
||||||
|
|
||||||
mkWord :: MonadThrow m => Text -> m (Word 'Normal)
|
mkWord :: MonadThrow m => Text -> m (Word 'Normal)
|
||||||
mkWord txt =
|
mkWord txt =
|
||||||
@ -55,6 +57,8 @@ mkWord txt =
|
|||||||
-- | Create an acronym from given 'Text'. The input should not contain
|
-- | Create an acronym from given 'Text'. The input should not contain
|
||||||
-- spaces or 'InflectionInvalidAcronym' will be thrown. Acronym is different
|
-- spaces or 'InflectionInvalidAcronym' will be thrown. Acronym is different
|
||||||
-- from normal word by that it may not be transformed by inflections.
|
-- 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 :: MonadThrow m => Text -> m (Word 'Acronym)
|
||||||
mkAcronym txt =
|
mkAcronym txt =
|
||||||
@ -63,6 +67,7 @@ mkAcronym txt =
|
|||||||
else return (Word txt)
|
else return (Word txt)
|
||||||
|
|
||||||
-- | A 'Text' value that should be kept whole through applied inflections.
|
-- | A 'Text' value that should be kept whole through applied inflections.
|
||||||
|
|
||||||
data Word (t :: WordType) = Word Text
|
data Word (t :: WordType) = Word Text
|
||||||
deriving (Eq, Ord)
|
deriving (Eq, Ord)
|
||||||
|
|
||||||
@ -73,16 +78,23 @@ instance Show (Word 'Acronym) where
|
|||||||
show (Word x) = "Acronym " ++ show x
|
show (Word x) = "Acronym " ++ show x
|
||||||
|
|
||||||
-- | A type-level tag for words.
|
-- | A type-level tag for words.
|
||||||
|
--
|
||||||
|
-- @since 0.3.0.0
|
||||||
|
|
||||||
data WordType = Normal | Acronym
|
data WordType = Normal | Acronym
|
||||||
|
|
||||||
-- | Get a 'Text' value from 'Word'.
|
-- | Get a 'Text' value from 'Word'.
|
||||||
|
--
|
||||||
|
-- @since 0.3.0.0
|
||||||
|
|
||||||
unWord :: Word t -> Text
|
unWord :: Word t -> Text
|
||||||
unWord (Word s) = s
|
unWord (Word s) = s
|
||||||
|
|
||||||
-- | An existential wrapper that allows to keep words and acronyms in single
|
-- | 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
|
-- 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'.
|
-- apply 'unWord' on it, of course. This is faciliated by 'unSomeWord'.
|
||||||
|
--
|
||||||
|
-- @since 0.3.0.0
|
||||||
|
|
||||||
data SomeWord where
|
data SomeWord where
|
||||||
SomeWord :: (Transformable (Word t), Show (Word t)) => Word t -> SomeWord
|
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
|
-- | Extract 'Text' from 'SomeWord' and apply given function only if the
|
||||||
-- word inside wasn't an acronym.
|
-- word inside wasn't an acronym.
|
||||||
|
--
|
||||||
|
-- @since 0.3.0.0
|
||||||
|
|
||||||
unSomeWord :: (Text -> Text) -> SomeWord -> Text
|
unSomeWord :: (Text -> Text) -> SomeWord -> Text
|
||||||
unSomeWord f (SomeWord w) = transform f w
|
unSomeWord f (SomeWord w) = transform f w
|
||||||
@ -112,6 +126,8 @@ instance Transformable (Word 'Acronym) where
|
|||||||
transform _ = unWord
|
transform _ = unWord
|
||||||
|
|
||||||
-- | The exceptions that is thrown when parsing of input fails.
|
-- | The exceptions that is thrown when parsing of input fails.
|
||||||
|
--
|
||||||
|
-- @since 0.3.0.0
|
||||||
|
|
||||||
data InflectionException
|
data InflectionException
|
||||||
= InflectionParsingFailed (ParseError Char Dec)
|
= InflectionParsingFailed (ParseError Char Dec)
|
||||||
|
Loading…
Reference in New Issue
Block a user