diff options
author | stuebinm | 2021-09-18 00:27:22 +0200 |
---|---|---|
committer | stuebinm | 2021-09-18 00:27:22 +0200 |
commit | b17396b2eeefdf113b862b254cb152557bebf68d (patch) | |
tree | 09ab8776b87a7c193d08144b3d40ecd4f249f11e /lib/LintWriter.hs | |
parent | bfe45dc4996537b72436f4041d0ca819aa3444e1 (diff) |
tame the strings
Adds a PrettyPrint typeclass which operates on Text and should replace
Show, since constantly converting strings from linked lists to arrays
seems somewhat silly.
Diffstat (limited to 'lib/LintWriter.hs')
-rw-r--r-- | lib/LintWriter.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/LintWriter.hs b/lib/LintWriter.hs index 8e45812..10c727d 100644 --- a/lib/LintWriter.hs +++ b/lib/LintWriter.hs @@ -10,9 +10,11 @@ import Control.Monad.Trans.Maybe () import Control.Monad.Writer (MonadTrans (lift), MonadWriter (tell), WriterT) import Data.Aeson (ToJSON (toJSON)) -import Data.Text (Text, unpack) +import Data.Text (Text) import GHC.Generics (Generic) +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 @@ -24,9 +26,9 @@ data Hint = Hint , hintMsg :: Text } deriving (Generic, ToJSON) -instance Show Hint where - show Hint { hintMsg, hintLevel } = - show hintLevel <> ": " <> unpack hintMsg +instance PrettyPrint Hint where + prettyprint Hint { hintMsg, hintLevel } = + showText hintLevel <> ": " <> hintMsg -- shorter constructor hint :: Level -> Text -> Hint |