diff options
Diffstat (limited to 'app/Issue')
-rw-r--r-- | app/Issue/Tag.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/Issue/Tag.hs b/app/Issue/Tag.hs new file mode 100644 index 0000000..2699342 --- /dev/null +++ b/app/Issue/Tag.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE ViewPatterns #-} + +module Issue.Tag (Tag (..), extract) where + +import Data.Maybe (catMaybes) +import Data.Text (Text) +import Data.Text qualified as T + +data Tag = Tag Text Text deriving (Show) + +extract :: Text -> [Tag] +extract = + catMaybes + . map + ( ( \case + ((T.uncons -> Just ('@', k)) : v) -> + Just (Tag k (T.unwords v)) + _ -> Nothing + ) + . T.words + ) + . T.lines |