Skip to content

Commit 81a9931

Browse files
hashable instance for location, range, position (#415)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 0164358 commit 81a9931

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lsp-types/src/Language/LSP/Types/Common.hs

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module Language.LSP.Types.Common (
1818
import Control.Applicative
1919
import Control.DeepSeq
2020
import Data.Aeson
21+
import Data.Hashable
2122
import Data.Int (Int32)
2223
import Data.Mod.Word
2324
import Text.Read (Read(readPrec))
@@ -33,6 +34,8 @@ newtype UInt = UInt (Mod (2^31))
3334
deriving stock (Generic)
3435
deriving anyclass (NFData)
3536

37+
instance Hashable UInt where hashWithSalt s (UInt n) = hashWithSalt s (unMod n)
38+
3639
instance Show UInt where
3740
show (UInt u) = show $ unMod u
3841

lsp-types/src/Language/LSP/Types/Location.hs

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Language.LSP.Types.Location where
44

55
import Control.DeepSeq
66
import Data.Aeson.TH
7+
import Data.Hashable
78
import GHC.Generics hiding (UInt)
89
import Language.LSP.Types.Common
910
import Language.LSP.Types.Uri
@@ -26,6 +27,8 @@ data Position =
2627
instance NFData Position
2728
deriveJSON lspOptions ''Position
2829

30+
instance Hashable Position
31+
2932
-- ---------------------------------------------------------------------
3033

3134
data Range =
@@ -37,6 +40,8 @@ data Range =
3740
instance NFData Range
3841
deriveJSON lspOptions ''Range
3942

43+
instance Hashable Range
44+
4045
-- ---------------------------------------------------------------------
4146

4247
data Location =
@@ -48,6 +53,8 @@ data Location =
4853
instance NFData Location
4954
deriveJSON lspOptions ''Location
5055

56+
instance Hashable Location
57+
5158
-- ---------------------------------------------------------------------
5259

5360
-- | Represents a link between a source and a target location.

0 commit comments

Comments
 (0)