aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-10-04 11:16:34 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-10-04 11:16:34 +0200
commit9b5bd101f7c511a9a0dd4a12a5480ff2628f0b50 (patch)
tree3e71a222dad2959e9da9f09354bd926dfe1f7fc0 /app/Issue
parent13b2faa45ca5df4933619a06d28c42686aea8725 (diff)
add tags to issues
Diffstat (limited to 'app/Issue')
-rw-r--r--app/Issue/Tag.hs23
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