summaryrefslogtreecommitdiff
path: root/lib/LintWriter.hs
diff options
context:
space:
mode:
authorstuebinm2021-09-18 02:09:27 +0200
committerstuebinm2021-09-18 02:09:27 +0200
commit0bd2e836d96fe864b00d2085f29e932130722cc3 (patch)
tree672cc7c3abd645d0fccd0d7a2061ad96bf9c9cb0 /lib/LintWriter.hs
parent1c82540aeea7636a6cfd25acfdd28c1029f5669f (diff)
moved types into Types.hs
it's almost as if there's some structure to this code!
Diffstat (limited to '')
-rw-r--r--lib/LintWriter.hs48
1 files changed, 2 insertions, 46 deletions
diff --git a/lib/LintWriter.hs b/lib/LintWriter.hs
index bfe543e..66f16f1 100644
--- a/lib/LintWriter.hs
+++ b/lib/LintWriter.hs
@@ -9,54 +9,10 @@ module LintWriter where
import Control.Monad.Trans.Maybe ()
import Control.Monad.Writer (MonadTrans (lift),
MonadWriter (tell), WriterT)
-import Data.Aeson (ToJSON (toJSON), (.=))
+import Data.Aeson (ToJSON (toJSON))
import Data.Text (Text)
-import GHC.Generics (Generic)
-import qualified Data.Aeson as A
-import Util (PrettyPrint (..), showText)
-
--- | Levels of errors and warnings, collectively called
--- "Hints" until I can think of some better name
-data Level = Warning | Suggestion | Info | Forbidden | Error | Fatal
- deriving (Show, Generic, ToJSON)
-
--- | a hint comes with an explanation (and a level), or is a dependency
--- (in which case it'll be otherwise treated as an info hint)
-data Lint = Depends Dep | Lint Hint
-
-data Hint = Hint
- { hintLevel :: Level
- , hintMsg :: Text
- } deriving (Generic, ToJSON)
-
-lintLevel :: Lint -> Level
-lintLevel (Lint h) = hintLevel h
-lintLevel (Depends dep) = Info
-
-instance PrettyPrint Lint where
- prettyprint (Lint Hint { hintMsg, hintLevel } ) =
- showText hintLevel <> ": " <> hintMsg
- prettyprint (Depends dep) =
- "Info: found dependency: " <> prettyprint dep
-
-instance ToJSON Lint where
- toJSON (Lint l) = toJSON l
- toJSON (Depends dep) = A.object
- [ "hintMsg" .= prettyprint dep
- , "hintLevel" .= A.String "Dependency Info" ]
-
-
--- shorter constructor
-hint :: Level -> Text -> Lint
-hint level msg = Lint Hint { hintLevel = level, hintMsg = msg }
-
--- | TODO: add a reasonable representation of possible urls
-newtype Dep = Dep Text
- deriving (Generic, ToJSON)
-
-instance PrettyPrint Dep where
- prettyprint (Dep txt) = txt
+import Types
-- | a monad to collect hints. If it yields Left, then the
-- map is flawed in some fundamental way which prevented us