Skip to content

Commit 386ffae

Browse files
authored
Add instance: Hashable SomeLspId (#424)
* Add instance: Hashable SomeLspId * Add separate Hashable (LspId m) and use for Hashable SomeLspId
1 parent daafba0 commit 386ffae

File tree

1 file changed

+9
-1
lines changed
  • lsp-types/src/Language/LSP/Types

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
module Language.LSP.Types.LspId where
88

99
import qualified Data.Aeson as A
10-
import Data.Text (Text)
10+
import Data.Hashable
1111
import Data.Int (Int32)
1212
import Data.IxMap
13+
import Data.Text (Text)
1314

1415
import Language.LSP.Types.Method
1516

@@ -30,6 +31,10 @@ instance IxOrd LspId where
3031
type Base LspId = SomeLspId
3132
toBase = SomeLspId
3233

34+
instance Hashable (LspId m) where
35+
hashWithSalt n (IdInt i) = hashWithSalt n i
36+
hashWithSalt n (IdString t) = hashWithSalt n t
37+
3338
data SomeLspId where
3439
SomeLspId :: !(LspId m) -> SomeLspId
3540

@@ -45,3 +50,6 @@ instance Ord SomeLspId where
4550
go (IdString a) (IdString b) = a `compare` b
4651
go (IdInt _) (IdString _) = LT
4752
go (IdString _) (IdInt _) = GT
53+
54+
instance Hashable SomeLspId where
55+
hashWithSalt n (SomeLspId lspId) = hashWithSalt n lspId

0 commit comments

Comments
 (0)