diff options
Diffstat (limited to '')
-rw-r--r-- | lib/LintWriter.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/LintWriter.hs b/lib/LintWriter.hs index de7d314..5ff56bd 100644 --- a/lib/LintWriter.hs +++ b/lib/LintWriter.hs @@ -14,12 +14,12 @@ import Control.Monad.Writer (MonadWriter (tell), WriterT, import Data.Aeson (ToJSON (toJSON)) import Data.Text (Text) -import Control.Monad.Reader (local) import Control.Monad.Trans.Reader (Reader, asks, runReader) import Control.Monad.Writer.Lazy (lift) import Data.Maybe (mapMaybe) -import GHC.Generics (Generic) +import qualified Data.Text as T import Types +import Util (PrettyPrint (..)) -- | for now, all context we have is how "deep" in the directory tree @@ -38,9 +38,15 @@ newtype LintResult ctxt = LintResult (LintResult' ctxt) -- better, less confusing serialisation of an Either Hint (a, [Hint]). -- Note that Left hint is also serialised as a list to make the resulting -- json schema more regular. -instance ToJSON a => ToJSON (LintResult a) where +instance ToJSON (LintResult a) where toJSON (LintResult res) = toJSON $ snd res +instance PrettyPrint ctxt => PrettyPrint (LintResult ctxt) where + prettyprint (LintResult (ctxt, res)) = + T.concat (map showHint res) + where showHint hint = prettyprint hint <> context + context = " (" <> prettyprint ctxt <> ")\n" + lintToDep :: Lint -> Maybe Dep lintToDep = \case Depends dep -> Just dep |