{-# 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