File tree Expand file tree Collapse file tree 6 files changed +39
-0
lines changed
src/Language/LSP/Protocol Expand file tree Collapse file tree 6 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ library
7171 , base >= 4.11 && < 5
7272 , binary
7373 , containers
74+ , data-default
7475 , deepseq
7576 , Diff >= 0.2
7677 , dlist
@@ -122,6 +123,7 @@ library
122123 Language.LSP.Protocol.Types.Location
123124 Language.LSP.Protocol.Types.LspEnum
124125 Language.LSP.Protocol.Types.MarkupContent
126+ Language.LSP.Protocol.Types.Orphans
125127 Language.LSP.Protocol.Types.Progress
126128 Language.LSP.Protocol.Types.SemanticTokens
127129 Language.LSP.Protocol.Types.Singletons
Original file line number Diff line number Diff line change 11{-#LANGUAGE TemplateHaskell #-}
2+ {-# OPTIONS_GHC -Wno-orphans #-}
23
34module Language.LSP.Protocol.Message.Lens where
45
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ module Language.LSP.Protocol.Types (
2424 , module WatchKinds
2525 -- * Main LSP types and functions
2626 , module Generated
27+ -- ** Orphan instances for the generated types
28+ , module Orphans
2729 ) where
2830
2931import Language.LSP.Protocol.Internal.Types as Generated
@@ -37,4 +39,5 @@ import Language.LSP.Protocol.Types.Singletons as Singletons
3739import Language.LSP.Protocol.Types.Uri as Uri
3840import Language.LSP.Protocol.Types.Uri.OsPath as Uri
3941import Language.LSP.Protocol.Types.Edit as Edits
42+ import Language.LSP.Protocol.Types.Orphans as Orphans
4043import Language.LSP.Protocol.Types.WatchKinds as WatchKinds
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ module Language.LSP.Protocol.Types.Common (
1919 , Null (.. )
2020 , absorbNull
2121 , nullToMaybe
22+ , maybeToNull
2223 , (.=?)
2324) where
2425
@@ -153,6 +154,17 @@ nullToMaybe :: a |? Null -> Maybe a
153154nullToMaybe (InL a) = Just a
154155nullToMaybe (InR _) = Nothing
155156
157+ maybeToNull :: Maybe a -> a |? Null
158+ maybeToNull (Just x) = InL x
159+ maybeToNull Nothing = InR Null
160+
161+ -- This is equivalent to the instance for 'Maybe s'
162+ instance Semigroup s => Semigroup (s |? Null ) where
163+ InL x <> InL y = InL (x <> y)
164+ InL x <> InR _ = InL x
165+ InR _ <> InL x = InL x
166+ InR _ <> InR y = InR y
167+
156168 -- We use String so we can use fromString on it to get a key that works
157169 -- in both aeson-1 and aeson-2
158170-- | Include a value in an JSON object optionally, omitting it if it is 'Nothing'.
Original file line number Diff line number Diff line change 11{-#LANGUAGE TemplateHaskell #-}
2+ {-# OPTIONS_GHC -Wno-orphans #-}
23
34module Language.LSP.Protocol.Types.Lens where
45
Original file line number Diff line number Diff line change 1+ {-# OPTIONS_GHC -Wno-orphans #-}
2+ module Language.LSP.Protocol.Types.Orphans where
3+
4+ import Language.LSP.Protocol.Internal.Types
5+ import Data.Default
6+ import Data.Semigroup ()
7+
8+ instance Semigroup WorkspaceEdit where
9+ (WorkspaceEdit a b c) <> (WorkspaceEdit a' b' c') = WorkspaceEdit (a <> a') (b <> b') (c <> c')
10+ instance Monoid WorkspaceEdit where
11+ mempty = WorkspaceEdit Nothing Nothing Nothing
12+
13+ instance Default ClientCapabilities where
14+ def = ClientCapabilities def def def def def Nothing
15+ instance Default WorkspaceClientCapabilities
16+ instance Default TextDocumentClientCapabilities
17+ instance Default NotebookDocumentClientCapabilities where
18+ instance Default NotebookDocumentSyncClientCapabilities
19+ instance Default WindowClientCapabilities
20+ instance Default GeneralClientCapabilities
You can’t perform that action at this time.
0 commit comments