From e68d652323e454abf7e6c01ecedd919859cf9274 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 30 Sep 2021 14:01:25 +0200 Subject: nicer json output which leaks less haskell names --- lib/Types.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/Types.hs') diff --git a/lib/Types.hs b/lib/Types.hs index fd2bd20..c39297f 100644 --- a/lib/Types.hs +++ b/lib/Types.hs @@ -26,7 +26,7 @@ import WithCli.Pure (Argument (argumentType, parseArgumen -- | Levels of errors and warnings, collectively called -- "Hints" until I can think of some better name data Level = Info | Suggestion | Warning | Forbidden | Error | Fatal - deriving (Show, Generic, ToJSON, Ord, Eq, A.FromJSON) + deriving (Show, Generic, Ord, Eq, ToJSON) instance Argument Level where argumentType Proxy = "Lint Level" @@ -54,7 +54,7 @@ data Dep = Local RelPath | Link Text | MapLink Text | LocalMap RelPath data Hint = Hint { hintLevel :: Level , hintMsg :: Text - } deriving (Generic, ToJSON) + } deriving (Generic) -- | shorter constructor (called hint because (a) older name and -- (b) lint also exists and is monadic) @@ -75,13 +75,14 @@ instance PrettyPrint Lint where " Info: map offers entrypoint " <> prettyprint dep instance ToJSON Lint where - toJSON (Lint l) = toJSON l + toJSON (Lint (Hint l m)) = A.object + [ "msg" .= m, "level" .= l ] toJSON (Depends dep) = A.object - [ "hintMsg" .= prettyprint dep - , "hintLevel" .= A.String "Dependency Info" ] + [ "msg" .= prettyprint dep + , "level" .= A.String "Dependency Info" ] toJSON (Offers l) = A.object - [ "hintMsg" .= prettyprint l - , "hintLevel" .= A.String "Entrypoint Info" ] + [ "msg" .= prettyprint l + , "level" .= A.String "Entrypoint Info" ] instance ToJSON Dep where toJSON = \case -- cgit v1.2.3