aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue/Tag.hs
blob: 2699342a04ae4b83e88ba929145f98ab25c7ead4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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