From b17396b2eeefdf113b862b254cb152557bebf68d Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sat, 18 Sep 2021 00:27:22 +0200 Subject: 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. --- lib/LintWriter.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/LintWriter.hs') 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 -- cgit v1.2.3