Skip to content

Commit bcef5c3

Browse files
committed
pimp show instance for SimpleContext to match json representation
1 parent a510b1a commit bcef5c3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

kore-rpc-types/src/Kore/JsonRpc/Types/ContextLog.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ module Kore.JsonRpc.Types.ContextLog (
99
) where
1010

1111
import Data.Aeson.TH (deriveJSON)
12-
import Data.Aeson.Types (FromJSON (..), Options (..), ToJSON (..), defaultOptions)
12+
import Data.Aeson.Types (FromJSON (..), ToJSON (..), defaultOptions)
1313
import Data.Aeson.Types qualified as JSON
1414
import Data.Char (toLower)
15+
import Data.Data (Data, toConstr)
1516
import Data.Sequence (Seq)
1617
import Data.Text (Text, unpack)
1718
import Data.Text qualified as Text
@@ -51,7 +52,10 @@ data SimpleContext
5152
CtxError
5253
| CtxWarn
5354
| CtxInfo
54-
deriving stock (Show, Eq, Ord, Enum)
55+
deriving stock (Eq, Ord, Enum, Data)
56+
57+
instance Show SimpleContext where
58+
show = JSON.camelTo2 '-' . drop 3 . show . toConstr
5559

5660
$( deriveJSON
5761
defaultOptions
@@ -127,7 +131,7 @@ data CLContext
127131
deriving stock (Eq)
128132

129133
instance Show CLContext where
130-
show (CLNullary c) = map toLower . drop 3 $ show c
134+
show (CLNullary c) = show c
131135
show (CLWithId withId) = show withId
132136

133137
instance ToJSON CLContext where

0 commit comments

Comments
 (0)