diff options
author | stuebinm | 2021-09-17 23:50:45 +0200 |
---|---|---|
committer | stuebinm | 2021-09-17 23:50:45 +0200 |
commit | bfe45dc4996537b72436f4041d0ca819aa3444e1 (patch) | |
tree | 70e4966273b5447159bf39b4556e02affe911801 /lib/LintWriter.hs | |
parent | 7a9226d84cf9dde33d0fc3e7852a22c36ab1c39b (diff) |
(somewhat) reasonable representation of parse errors
This makes map loading (and parsing) part of the linter, and also makes
it return "general lints" and nothing else in case that failed.
Possibly a sum type would be nicer here, but I guess it's not really
important since everything ends up as json anyways?
Diffstat (limited to 'lib/LintWriter.hs')
-rw-r--r-- | lib/LintWriter.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/LintWriter.hs b/lib/LintWriter.hs index ca7ff08..8e45812 100644 --- a/lib/LintWriter.hs +++ b/lib/LintWriter.hs @@ -10,20 +10,23 @@ import Control.Monad.Trans.Maybe () import Control.Monad.Writer (MonadTrans (lift), MonadWriter (tell), WriterT) import Data.Aeson (ToJSON (toJSON)) -import Data.Text (Text) +import Data.Text (Text, unpack) import GHC.Generics (Generic) - -- | Levels of errors and warnings, collectively called -- "Hints" until I can think of some better name -data Level = Warning | Suggestion | Info | Forbidden | Error +data Level = Warning | Suggestion | Info | Forbidden | Error | Fatal deriving (Show, Generic, ToJSON) -- | a hint comes with an explanation (and a level) data Hint = Hint { hintLevel :: Level , hintMsg :: Text } - deriving (Show, Generic, ToJSON) + deriving (Generic, ToJSON) + +instance Show Hint where + show Hint { hintMsg, hintLevel } = + show hintLevel <> ": " <> unpack hintMsg -- shorter constructor hint :: Level -> Text -> Hint |