Skip to content

Commit d1a6c8d

Browse files
committed
Remove HoverContentsEmpty
But keep the `Monoid` instance because it allows `mconcat` Closes #162
1 parent fb45245 commit d1a6c8d

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

haskell-lsp-types/src/Language/Haskell/LSP/Types/DataTypesJSON.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,16 +1623,13 @@ instance FromJSON MarkedString where
16231623
data HoverContents =
16241624
HoverContentsMS (List MarkedString)
16251625
| HoverContents MarkupContent
1626-
| HoverContentsEmpty
16271626
deriving (Read,Show,Eq)
16281627

16291628
instance ToJSON HoverContents where
16301629
toJSON (HoverContentsMS x) = toJSON x
16311630
toJSON (HoverContents x) = toJSON x
1632-
toJSON (HoverContentsEmpty) = A.Null
16331631
instance FromJSON HoverContents where
16341632
parseJSON v@(A.String _) = HoverContentsMS <$> parseJSON v
1635-
parseJSON (A.Null) = pure HoverContentsEmpty
16361633
parseJSON v@(A.Array _) = HoverContentsMS <$> parseJSON v
16371634
parseJSON v@(A.Object _) = HoverContents <$> parseJSON v
16381635
<|> HoverContentsMS <$> parseJSON v
@@ -1646,10 +1643,8 @@ instance Semigroup HoverContents where
16461643
#endif
16471644

16481645
instance Monoid HoverContents where
1649-
mempty = HoverContentsEmpty
1646+
mempty = HoverContentsMS (List [])
16501647

1651-
HoverContentsEmpty `mappend` hc = hc
1652-
hc `mappend` HoverContentsEmpty = hc
16531648
HoverContents h1 `mappend` HoverContents h2 = HoverContents (h1 `mappend` h2)
16541649
HoverContents h1 `mappend` HoverContentsMS (List h2s) = HoverContents (mconcat (h1: (map toMarkupContent h2s)))
16551650
HoverContentsMS (List h1s) `mappend` HoverContents h2 = HoverContents (mconcat ((map toMarkupContent h1s) ++ [h2]))

test/JsonSpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ instance Arbitrary MarkupKind where
5959
instance Arbitrary HoverContents where
6060
arbitrary = oneof [ HoverContentsMS <$> arbitrary
6161
, HoverContents <$> arbitrary
62-
, pure HoverContentsEmpty]
62+
]
6363

6464
-- | make lists of maximum length 3 for test performance
6565
smallList :: Gen a -> Gen [a]

0 commit comments

Comments
 (0)