From 9b5bd101f7c511a9a0dd4a12a5480ff2628f0b50 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Wed, 4 Oct 2023 11:16:34 +0200 Subject: add tags to issues --- app/Issue/Tag.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/Issue/Tag.hs (limited to 'app/Issue/Tag.hs') 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 -- cgit v1.2.3