diff options
Diffstat (limited to '')
-rw-r--r-- | lib/LintWriter.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/LintWriter.hs b/lib/LintWriter.hs index 055e2d4..02815e3 100644 --- a/lib/LintWriter.hs +++ b/lib/LintWriter.hs @@ -9,7 +9,8 @@ module LintWriter where import Control.Monad.Trans.Maybe () import Control.Monad.Writer (MonadTrans (lift), - MonadWriter (tell), WriterT) + MonadWriter (tell), WriterT, + runWriterT) import Data.Aeson (ToJSON (toJSON)) import Data.Text (Text) @@ -45,6 +46,16 @@ lintsToDeps (LintResult a) = case a of Left _ -> [] Right (_, lints) -> mapMaybe lintToDep lints +-- | convert a lint result into a flat list of lints +-- (throwing away information on if a single error was fatal) +resultToLints :: LintResult a -> [Lint] +resultToLints (LintResult res) = case res of + Left l -> [l] + Right (_, lints) -> lints + +-- | Confusingly, this returns lints, not a … +runLintWriter :: LintWriter a -> [Lint] +runLintWriter = resultToLints . LintResult . runWriterT -- | write a hint into the LintWriter monad lint :: Level -> Text -> LintWriter () |