{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Language.LSP.Types.Parsing where
import Language.LSP.Types.LspId
import Language.LSP.Types.Method
import Language.LSP.Types.Message
import Data.Aeson
import Data.Aeson.Types
import Data.GADT.Compare
import Data.Type.Equality
import Data.Function (on)
data FromServerMessage' a where
FromServerMess :: forall t (m :: Method FromServer t) a. SMethod m -> Message m -> FromServerMessage' a
FromServerRsp :: forall (m :: Method FromClient Request) a. a m -> ResponseMessage m -> FromServerMessage' a
type FromServerMessage = FromServerMessage' SMethod
instance Eq FromServerMessage where
== :: FromServerMessage -> FromServerMessage -> Bool
(==) = Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Value -> Value -> Bool)
-> (FromServerMessage -> Value)
-> FromServerMessage
-> FromServerMessage
-> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` FromServerMessage -> Value
forall a. ToJSON a => a -> Value
toJSON
instance Show FromServerMessage where
show :: FromServerMessage -> String
show = Value -> String
forall a. Show a => a -> String
show (Value -> String)
-> (FromServerMessage -> Value) -> FromServerMessage -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FromServerMessage -> Value
forall a. ToJSON a => a -> Value
toJSON
instance ToJSON FromServerMessage where
toJSON :: FromServerMessage -> Value
toJSON (FromServerMess SMethod m
m Message m
p) = SMethod m -> (ToJSON (Message m) => Value) -> Value
forall {t :: MethodType} (m :: Method 'FromServer t) x.
SServerMethod m -> (ToJSON (ServerMessage m) => x) -> x
serverMethodJSON SMethod m
m (Message m -> Value
forall a. ToJSON a => a -> Value
toJSON Message m
p)
toJSON (FromServerRsp SMethod m
m ResponseMessage m
p) = SMethod m -> (HasJSON (ResponseMessage m) => Value) -> Value
forall (m :: Method 'FromClient 'Request) x.
SClientMethod m -> (HasJSON (ResponseMessage m) => x) -> x
clientResponseJSON SMethod m
m (ResponseMessage m -> Value
forall a. ToJSON a => a -> Value
toJSON ResponseMessage m
p)
fromServerNot :: forall (m :: Method FromServer Notification).
Message m ~ NotificationMessage m => NotificationMessage m -> FromServerMessage
fromServerNot :: forall (m :: Method 'FromServer 'Notification).
(Message m ~ NotificationMessage m) =>
NotificationMessage m -> FromServerMessage
fromServerNot m :: NotificationMessage m
m@NotificationMessage{_method :: forall (f :: From) (m :: Method f 'Notification).
NotificationMessage m -> SMethod m
_method=SMethod m
meth} = SMethod m -> Message m -> FromServerMessage
forall (m :: MethodType) (m :: Method 'FromServer m)
(a :: Method 'FromClient 'Request -> *).
SMethod m -> Message m -> FromServerMessage' a
FromServerMess SMethod m
meth NotificationMessage m
Message m
m
fromServerReq :: forall (m :: Method FromServer Request).
Message m ~ RequestMessage m => RequestMessage m -> FromServerMessage
fromServerReq :: forall (m :: Method 'FromServer 'Request).
(Message m ~ RequestMessage m) =>
RequestMessage m -> FromServerMessage
fromServerReq m :: RequestMessage m
m@RequestMessage{_method :: forall (f :: From) (m :: Method f 'Request).
RequestMessage m -> SMethod m
_method=SMethod m
meth} = SMethod m -> Message m -> FromServerMessage
forall (m :: MethodType) (m :: Method 'FromServer m)
(a :: Method 'FromClient 'Request -> *).
SMethod m -> Message m -> FromServerMessage' a
FromServerMess SMethod m
meth RequestMessage m
Message m
m
data FromClientMessage' a where
FromClientMess :: forall t (m :: Method FromClient t) a. SMethod m -> Message m -> FromClientMessage' a
FromClientRsp :: forall (m :: Method FromServer Request) a. a m -> ResponseMessage m -> FromClientMessage' a
type FromClientMessage = FromClientMessage' SMethod
instance ToJSON FromClientMessage where
toJSON :: FromClientMessage -> Value
toJSON (FromClientMess SMethod m
m Message m
p) = SMethod m -> (ToJSON (Message m) => Value) -> Value
forall {t :: MethodType} (m :: Method 'FromClient t) x.
SClientMethod m -> (ToJSON (ClientMessage m) => x) -> x
clientMethodJSON SMethod m
m (Message m -> Value
forall a. ToJSON a => a -> Value
toJSON Message m
p)
toJSON (FromClientRsp SMethod m
m ResponseMessage m
p) = SMethod m -> (HasJSON (ResponseMessage m) => Value) -> Value
forall (m :: Method 'FromServer 'Request) x.
SServerMethod m -> (HasJSON (ResponseMessage m) => x) -> x
serverResponseJSON SMethod m
m (ResponseMessage m -> Value
forall a. ToJSON a => a -> Value
toJSON ResponseMessage m
p)
fromClientNot :: forall (m :: Method FromClient Notification).
Message m ~ NotificationMessage m => NotificationMessage m -> FromClientMessage
fromClientNot :: forall (m :: Method 'FromClient 'Notification).
(Message m ~ NotificationMessage m) =>
NotificationMessage m -> FromClientMessage
fromClientNot m :: NotificationMessage m
m@NotificationMessage{_method :: forall (f :: From) (m :: Method f 'Notification).
NotificationMessage m -> SMethod m
_method=SMethod m
meth} = SMethod m -> Message m -> FromClientMessage
forall (m :: MethodType) (m :: Method 'FromClient m)
(a :: Method 'FromServer 'Request -> *).
SMethod m -> Message m -> FromClientMessage' a
FromClientMess SMethod m
meth NotificationMessage m
Message m
m
fromClientReq :: forall (m :: Method FromClient Request).
Message m ~ RequestMessage m => RequestMessage m -> FromClientMessage
fromClientReq :: forall (m :: Method 'FromClient 'Request).
(Message m ~ RequestMessage m) =>
RequestMessage m -> FromClientMessage
fromClientReq m :: RequestMessage m
m@RequestMessage{_method :: forall (f :: From) (m :: Method f 'Request).
RequestMessage m -> SMethod m
_method=SMethod m
meth} = SMethod m -> Message m -> FromClientMessage
forall (m :: MethodType) (m :: Method 'FromClient m)
(a :: Method 'FromServer 'Request -> *).
SMethod m -> Message m -> FromClientMessage' a
FromClientMess SMethod m
meth RequestMessage m
Message m
m
type LookupFunc f a = forall (m :: Method f Request). LspId m -> Maybe (SMethod m, a m)
{-# INLINE parseServerMessage #-}
parseServerMessage :: LookupFunc FromClient a -> Value -> Parser (FromServerMessage' a)
parseServerMessage :: forall (a :: Method 'FromClient 'Request -> *).
LookupFunc 'FromClient a -> Value -> Parser (FromServerMessage' a)
parseServerMessage LookupFunc 'FromClient a
lookupId v :: Value
v@(Object Object
o) = do
Maybe SomeServerMethod
methMaybe <- Object
o Object -> Key -> Parser (Maybe SomeServerMethod)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:! Key
"method"
Maybe (LspId Any)
idMaybe <- Object
o Object -> Key -> Parser (Maybe (LspId Any))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:! Key
"id"
case Maybe SomeServerMethod
methMaybe of
Just (SomeServerMethod SMethod m
m) ->
case SMethod m -> ServerNotOrReq m
forall {t :: MethodType} (m :: Method 'FromServer t).
SServerMethod m -> ServerNotOrReq m
splitServerMethod SMethod m
m of
ServerNotOrReq m
IsServerNot -> SMethod m -> Message m -> FromServerMessage' a
forall (m :: MethodType) (m :: Method 'FromServer m)
(a :: Method 'FromClient 'Request -> *).
SMethod m -> Message m -> FromServerMessage' a
FromServerMess SMethod m
m (NotificationMessage m -> FromServerMessage' a)
-> Parser (NotificationMessage m) -> Parser (FromServerMessage' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (NotificationMessage m)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
ServerNotOrReq m
IsServerReq -> SMethod m -> Message m -> FromServerMessage' a
forall (m :: MethodType) (m :: Method 'FromServer m)
(a :: Method 'FromClient 'Request -> *).
SMethod m -> Message m -> FromServerMessage' a
FromServerMess SMethod m
m (RequestMessage m -> FromServerMessage' a)
-> Parser (RequestMessage m) -> Parser (FromServerMessage' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (RequestMessage m)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
ServerNotOrReq m
IsServerEither | SCustomMethod Text
cm <- SMethod m
m -> do
case Maybe (LspId Any)
idMaybe of
Just LspId Any
_ ->
let m' :: SMethod 'CustomMethod
m' = (Text -> SMethod 'CustomMethod
forall {f :: From} {t :: MethodType}. Text -> SMethod 'CustomMethod
SCustomMethod Text
cm :: SMethod (CustomMethod :: Method FromServer Request))
in SMethod 'CustomMethod
-> Message 'CustomMethod -> FromServerMessage' a
forall (m :: MethodType) (m :: Method 'FromServer m)
(a :: Method 'FromClient 'Request -> *).
SMethod m -> Message m -> FromServerMessage' a
FromServerMess SMethod 'CustomMethod
m' (CustomMessage 'FromServer 'Request -> FromServerMessage' a)
-> Parser (CustomMessage 'FromServer 'Request)
-> Parser (FromServerMessage' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (CustomMessage 'FromServer 'Request)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
Maybe (LspId Any)
Nothing ->
let m' :: SMethod 'CustomMethod
m' = (Text -> SMethod 'CustomMethod
forall {f :: From} {t :: MethodType}. Text -> SMethod 'CustomMethod
SCustomMethod Text
cm :: SMethod (CustomMethod :: Method FromServer Notification))
in SMethod 'CustomMethod
-> Message 'CustomMethod -> FromServerMessage' a
forall (m :: MethodType) (m :: Method 'FromServer m)
(a :: Method 'FromClient 'Request -> *).
SMethod m -> Message m -> FromServerMessage' a
FromServerMess SMethod 'CustomMethod
m' (CustomMessage 'FromServer 'Notification -> FromServerMessage' a)
-> Parser (CustomMessage 'FromServer 'Notification)
-> Parser (FromServerMessage' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (CustomMessage 'FromServer 'Notification)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
Maybe SomeServerMethod
Nothing -> do
case Maybe (LspId Any)
idMaybe of
Just LspId Any
i -> do
case LspId Any -> Maybe (SMethod Any, a Any)
LookupFunc 'FromClient a
lookupId LspId Any
i of
Just (SMethod Any
m,a Any
res) -> SMethod Any
-> (HasJSON (ResponseMessage Any) => Parser (FromServerMessage' a))
-> Parser (FromServerMessage' a)
forall (m :: Method 'FromClient 'Request) x.
SClientMethod m -> (HasJSON (ResponseMessage m) => x) -> x
clientResponseJSON SMethod Any
m ((HasJSON (ResponseMessage Any) => Parser (FromServerMessage' a))
-> Parser (FromServerMessage' a))
-> (HasJSON (ResponseMessage Any) => Parser (FromServerMessage' a))
-> Parser (FromServerMessage' a)
forall a b. (a -> b) -> a -> b
$ a Any -> ResponseMessage Any -> FromServerMessage' a
forall (m :: Method 'FromClient 'Request)
(a :: Method 'FromClient 'Request -> *).
a m -> ResponseMessage m -> FromServerMessage' a
FromServerRsp a Any
res (ResponseMessage Any -> FromServerMessage' a)
-> Parser (ResponseMessage Any) -> Parser (FromServerMessage' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (ResponseMessage Any)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
Maybe (SMethod Any, a Any)
Nothing -> String -> Parser (FromServerMessage' a)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (FromServerMessage' a))
-> String -> Parser (FromServerMessage' a)
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"Failed in looking up response type of", Value -> String
forall a. Show a => a -> String
show Value
v]
Maybe (LspId Any)
Nothing -> String -> Parser (FromServerMessage' a)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (FromServerMessage' a))
-> String -> Parser (FromServerMessage' a)
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"Got unexpected message without method or id"]
parseServerMessage LookupFunc 'FromClient a
_ Value
v = String -> Parser (FromServerMessage' a)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (FromServerMessage' a))
-> String -> Parser (FromServerMessage' a)
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"parseServerMessage expected object, got:",Value -> String
forall a. Show a => a -> String
show Value
v]
{-# INLINE parseClientMessage #-}
parseClientMessage :: LookupFunc FromServer a -> Value -> Parser (FromClientMessage' a)
parseClientMessage :: forall (a :: Method 'FromServer 'Request -> *).
LookupFunc 'FromServer a -> Value -> Parser (FromClientMessage' a)
parseClientMessage LookupFunc 'FromServer a
lookupId v :: Value
v@(Object Object
o) = do
Maybe SomeClientMethod
methMaybe <- Object
o Object -> Key -> Parser (Maybe SomeClientMethod)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:! Key
"method"
Maybe (LspId Any)
idMaybe <- Object
o Object -> Key -> Parser (Maybe (LspId Any))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:! Key
"id"
case Maybe SomeClientMethod
methMaybe of
Just (SomeClientMethod SMethod m
m) ->
case SMethod m -> ClientNotOrReq m
forall {t :: MethodType} (m :: Method 'FromClient t).
SClientMethod m -> ClientNotOrReq m
splitClientMethod SMethod m
m of
ClientNotOrReq m
IsClientNot -> SMethod m -> Message m -> FromClientMessage' a
forall (m :: MethodType) (m :: Method 'FromClient m)
(a :: Method 'FromServer 'Request -> *).
SMethod m -> Message m -> FromClientMessage' a
FromClientMess SMethod m
m (NotificationMessage m -> FromClientMessage' a)
-> Parser (NotificationMessage m) -> Parser (FromClientMessage' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (NotificationMessage m)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
ClientNotOrReq m
IsClientReq -> SMethod m -> Message m -> FromClientMessage' a
forall (m :: MethodType) (m :: Method 'FromClient m)
(a :: Method 'FromServer 'Request -> *).
SMethod m -> Message m -> FromClientMessage' a
FromClientMess SMethod m
m (RequestMessage m -> FromClientMessage' a)
-> Parser (RequestMessage m) -> Parser (FromClientMessage' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (RequestMessage m)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
ClientNotOrReq m
IsClientEither | SCustomMethod Text
cm <- SMethod m
m -> do
case Maybe (LspId Any)
idMaybe of
Just LspId Any
_ ->
let m' :: SMethod 'CustomMethod
m' = (Text -> SMethod 'CustomMethod
forall {f :: From} {t :: MethodType}. Text -> SMethod 'CustomMethod
SCustomMethod Text
cm :: SMethod (CustomMethod :: Method FromClient Request))
in SMethod 'CustomMethod
-> Message 'CustomMethod -> FromClientMessage' a
forall (m :: MethodType) (m :: Method 'FromClient m)
(a :: Method 'FromServer 'Request -> *).
SMethod m -> Message m -> FromClientMessage' a
FromClientMess SMethod 'CustomMethod
m' (CustomMessage 'FromClient 'Request -> FromClientMessage' a)
-> Parser (CustomMessage 'FromClient 'Request)
-> Parser (FromClientMessage' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (CustomMessage 'FromClient 'Request)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
Maybe (LspId Any)
Nothing ->
let m' :: SMethod 'CustomMethod
m' = (Text -> SMethod 'CustomMethod
forall {f :: From} {t :: MethodType}. Text -> SMethod 'CustomMethod
SCustomMethod Text
cm :: SMethod (CustomMethod :: Method FromClient Notification))
in SMethod 'CustomMethod
-> Message 'CustomMethod -> FromClientMessage' a
forall (m :: MethodType) (m :: Method 'FromClient m)
(a :: Method 'FromServer 'Request -> *).
SMethod m -> Message m -> FromClientMessage' a
FromClientMess SMethod 'CustomMethod
m' (CustomMessage 'FromClient 'Notification -> FromClientMessage' a)
-> Parser (CustomMessage 'FromClient 'Notification)
-> Parser (FromClientMessage' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (CustomMessage 'FromClient 'Notification)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
Maybe SomeClientMethod
Nothing -> do
case Maybe (LspId Any)
idMaybe of
Just LspId Any
i -> do
case LspId Any -> Maybe (SMethod Any, a Any)
LookupFunc 'FromServer a
lookupId LspId Any
i of
Just (SMethod Any
m,a Any
res) -> SMethod Any
-> (HasJSON (ResponseMessage Any) => Parser (FromClientMessage' a))
-> Parser (FromClientMessage' a)
forall (m :: Method 'FromServer 'Request) x.
SServerMethod m -> (HasJSON (ResponseMessage m) => x) -> x
serverResponseJSON SMethod Any
m ((HasJSON (ResponseMessage Any) => Parser (FromClientMessage' a))
-> Parser (FromClientMessage' a))
-> (HasJSON (ResponseMessage Any) => Parser (FromClientMessage' a))
-> Parser (FromClientMessage' a)
forall a b. (a -> b) -> a -> b
$ a Any -> ResponseMessage Any -> FromClientMessage' a
forall (m :: Method 'FromServer 'Request)
(a :: Method 'FromServer 'Request -> *).
a m -> ResponseMessage m -> FromClientMessage' a
FromClientRsp a Any
res (ResponseMessage Any -> FromClientMessage' a)
-> Parser (ResponseMessage Any) -> Parser (FromClientMessage' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (ResponseMessage Any)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
Maybe (SMethod Any, a Any)
Nothing -> String -> Parser (FromClientMessage' a)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (FromClientMessage' a))
-> String -> Parser (FromClientMessage' a)
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"Failed in looking up response type of", Value -> String
forall a. Show a => a -> String
show Value
v]
Maybe (LspId Any)
Nothing -> String -> Parser (FromClientMessage' a)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (FromClientMessage' a))
-> String -> Parser (FromClientMessage' a)
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"Got unexpected message without method or id"]
parseClientMessage LookupFunc 'FromServer a
_ Value
v = String -> Parser (FromClientMessage' a)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (FromClientMessage' a))
-> String -> Parser (FromClientMessage' a)
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"parseClientMessage expected object, got:",Value -> String
forall a. Show a => a -> String
show Value
v]
{-# INLINE clientResponseJSON #-}
clientResponseJSON :: SClientMethod m -> (HasJSON (ResponseMessage m) => x) -> x
clientResponseJSON :: forall (m :: Method 'FromClient 'Request) x.
SClientMethod m -> (HasJSON (ResponseMessage m) => x) -> x
clientResponseJSON SClientMethod m
m HasJSON (ResponseMessage m) => x
x = case SClientMethod m -> ClientNotOrReq m
forall {t :: MethodType} (m :: Method 'FromClient t).
SClientMethod m -> ClientNotOrReq m
splitClientMethod SClientMethod m
m of
ClientNotOrReq m
IsClientReq -> x
HasJSON (ResponseMessage m) => x
x
ClientNotOrReq m
IsClientEither -> x
HasJSON (ResponseMessage m) => x
x
{-# INLINE serverResponseJSON #-}
serverResponseJSON :: SServerMethod m -> (HasJSON (ResponseMessage m) => x) -> x
serverResponseJSON :: forall (m :: Method 'FromServer 'Request) x.
SServerMethod m -> (HasJSON (ResponseMessage m) => x) -> x
serverResponseJSON SServerMethod m
m HasJSON (ResponseMessage m) => x
x = case SServerMethod m -> ServerNotOrReq m
forall {t :: MethodType} (m :: Method 'FromServer t).
SServerMethod m -> ServerNotOrReq m
splitServerMethod SServerMethod m
m of
ServerNotOrReq m
IsServerReq -> x
HasJSON (ResponseMessage m) => x
x
ServerNotOrReq m
IsServerEither -> x
HasJSON (ResponseMessage m) => x
x
{-# INLINE clientMethodJSON#-}
clientMethodJSON :: SClientMethod m -> (ToJSON (ClientMessage m) => x) -> x
clientMethodJSON :: forall {t :: MethodType} (m :: Method 'FromClient t) x.
SClientMethod m -> (ToJSON (ClientMessage m) => x) -> x
clientMethodJSON SClientMethod m
m ToJSON (ClientMessage m) => x
x =
case SClientMethod m -> ClientNotOrReq m
forall {t :: MethodType} (m :: Method 'FromClient t).
SClientMethod m -> ClientNotOrReq m
splitClientMethod SClientMethod m
m of
ClientNotOrReq m
IsClientNot -> x
ToJSON (ClientMessage m) => x
x
ClientNotOrReq m
IsClientReq -> x
ToJSON (ClientMessage m) => x
x
ClientNotOrReq m
IsClientEither -> x
ToJSON (ClientMessage m) => x
x
{-# INLINE serverMethodJSON #-}
serverMethodJSON :: SServerMethod m -> (ToJSON (ServerMessage m) => x) -> x
serverMethodJSON :: forall {t :: MethodType} (m :: Method 'FromServer t) x.
SServerMethod m -> (ToJSON (ServerMessage m) => x) -> x
serverMethodJSON SServerMethod m
m ToJSON (ServerMessage m) => x
x =
case SServerMethod m -> ServerNotOrReq m
forall {t :: MethodType} (m :: Method 'FromServer t).
SServerMethod m -> ServerNotOrReq m
splitServerMethod SServerMethod m
m of
ServerNotOrReq m
IsServerNot -> x
ToJSON (ServerMessage m) => x
x
ServerNotOrReq m
IsServerReq -> x
ToJSON (ServerMessage m) => x
x
ServerNotOrReq m
IsServerEither -> x
ToJSON (ServerMessage m) => x
x
type HasJSON a = (ToJSON a,FromJSON a,Eq a)
data ClientNotOrReq (m :: Method FromClient t) where
IsClientNot
:: ( HasJSON (ClientMessage m)
, Message m ~ NotificationMessage m)
=> ClientNotOrReq (m :: Method FromClient Notification)
IsClientReq
:: forall (m :: Method FromClient Request).
( HasJSON (ClientMessage m)
, HasJSON (ResponseMessage m)
, Message m ~ RequestMessage m)
=> ClientNotOrReq m
IsClientEither
:: ClientNotOrReq CustomMethod
data ServerNotOrReq (m :: Method FromServer t) where
IsServerNot
:: ( HasJSON (ServerMessage m)
, Message m ~ NotificationMessage m)
=> ServerNotOrReq (m :: Method FromServer Notification)
IsServerReq
:: forall (m :: Method FromServer Request).
( HasJSON (ServerMessage m)
, HasJSON (ResponseMessage m)
, Message m ~ RequestMessage m)
=> ServerNotOrReq m
IsServerEither
:: ServerNotOrReq CustomMethod
{-# INLINE splitClientMethod #-}
splitClientMethod :: SClientMethod m -> ClientNotOrReq m
splitClientMethod :: forall {t :: MethodType} (m :: Method 'FromClient t).
SClientMethod m -> ClientNotOrReq m
splitClientMethod SMethod m
SInitialize = ClientNotOrReq m
ClientNotOrReq 'Initialize
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
SInitialized = ClientNotOrReq m
ClientNotOrReq 'Initialized
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
SShutdown = ClientNotOrReq m
ClientNotOrReq 'Shutdown
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
SExit = ClientNotOrReq m
ClientNotOrReq 'Exit
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
SWorkspaceDidChangeWorkspaceFolders = ClientNotOrReq m
ClientNotOrReq 'WorkspaceDidChangeWorkspaceFolders
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
SWorkspaceDidChangeConfiguration = ClientNotOrReq m
ClientNotOrReq 'WorkspaceDidChangeConfiguration
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
SWorkspaceDidChangeWatchedFiles = ClientNotOrReq m
ClientNotOrReq 'WorkspaceDidChangeWatchedFiles
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
SWorkspaceSymbol = ClientNotOrReq m
ClientNotOrReq 'WorkspaceSymbol
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
SWorkspaceExecuteCommand = ClientNotOrReq m
ClientNotOrReq 'WorkspaceExecuteCommand
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
SWindowWorkDoneProgressCancel = ClientNotOrReq m
ClientNotOrReq 'WindowWorkDoneProgressCancel
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
STextDocumentDidOpen = ClientNotOrReq m
ClientNotOrReq 'TextDocumentDidOpen
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
STextDocumentDidChange = ClientNotOrReq m
ClientNotOrReq 'TextDocumentDidChange
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
STextDocumentWillSave = ClientNotOrReq m
ClientNotOrReq 'TextDocumentWillSave
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
STextDocumentWillSaveWaitUntil = ClientNotOrReq m
ClientNotOrReq 'TextDocumentWillSaveWaitUntil
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentDidSave = ClientNotOrReq m
ClientNotOrReq 'TextDocumentDidSave
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
STextDocumentDidClose = ClientNotOrReq m
ClientNotOrReq 'TextDocumentDidClose
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SMethod m
STextDocumentCompletion = ClientNotOrReq m
ClientNotOrReq 'TextDocumentCompletion
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
SCompletionItemResolve = ClientNotOrReq m
ClientNotOrReq 'CompletionItemResolve
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentHover = ClientNotOrReq m
ClientNotOrReq 'TextDocumentHover
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentSignatureHelp = ClientNotOrReq m
ClientNotOrReq 'TextDocumentSignatureHelp
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentDeclaration = ClientNotOrReq m
ClientNotOrReq 'TextDocumentDeclaration
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentDefinition = ClientNotOrReq m
ClientNotOrReq 'TextDocumentDefinition
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentTypeDefinition = ClientNotOrReq m
ClientNotOrReq 'TextDocumentTypeDefinition
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentImplementation = ClientNotOrReq m
ClientNotOrReq 'TextDocumentImplementation
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentReferences = ClientNotOrReq m
ClientNotOrReq 'TextDocumentReferences
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentDocumentHighlight = ClientNotOrReq m
ClientNotOrReq 'TextDocumentDocumentHighlight
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentDocumentSymbol = ClientNotOrReq m
ClientNotOrReq 'TextDocumentDocumentSymbol
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentCodeAction = ClientNotOrReq m
ClientNotOrReq 'TextDocumentCodeAction
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentCodeLens = ClientNotOrReq m
ClientNotOrReq 'TextDocumentCodeLens
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
SCodeLensResolve = ClientNotOrReq m
ClientNotOrReq 'CodeLensResolve
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentDocumentLink = ClientNotOrReq m
ClientNotOrReq 'TextDocumentDocumentLink
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
SDocumentLinkResolve = ClientNotOrReq m
ClientNotOrReq 'DocumentLinkResolve
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentDocumentColor = ClientNotOrReq m
ClientNotOrReq 'TextDocumentDocumentColor
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentColorPresentation = ClientNotOrReq m
ClientNotOrReq 'TextDocumentColorPresentation
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentFormatting = ClientNotOrReq m
ClientNotOrReq 'TextDocumentFormatting
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentRangeFormatting = ClientNotOrReq m
ClientNotOrReq 'TextDocumentRangeFormatting
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentOnTypeFormatting = ClientNotOrReq m
ClientNotOrReq 'TextDocumentOnTypeFormatting
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentRename = ClientNotOrReq m
ClientNotOrReq 'TextDocumentRename
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentPrepareRename = ClientNotOrReq m
ClientNotOrReq 'TextDocumentPrepareRename
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentFoldingRange = ClientNotOrReq m
ClientNotOrReq 'TextDocumentFoldingRange
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentSelectionRange = ClientNotOrReq m
ClientNotOrReq 'TextDocumentSelectionRange
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentPrepareCallHierarchy = ClientNotOrReq m
ClientNotOrReq 'TextDocumentPrepareCallHierarchy
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
SCallHierarchyIncomingCalls = ClientNotOrReq m
ClientNotOrReq 'CallHierarchyIncomingCalls
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
SCallHierarchyOutgoingCalls = ClientNotOrReq m
ClientNotOrReq 'CallHierarchyOutgoingCalls
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentSemanticTokens = ClientNotOrReq m
ClientNotOrReq 'TextDocumentSemanticTokens
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentSemanticTokensFull = ClientNotOrReq m
ClientNotOrReq 'TextDocumentSemanticTokensFull
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentSemanticTokensFullDelta = ClientNotOrReq m
ClientNotOrReq 'TextDocumentSemanticTokensFullDelta
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
STextDocumentSemanticTokensRange = ClientNotOrReq m
ClientNotOrReq 'TextDocumentSemanticTokensRange
forall (m :: Method 'FromClient 'Request).
(HasJSON (ClientMessage m), HasJSON (ResponseMessage m),
ClientMessage m ~ RequestMessage m) =>
ClientNotOrReq m
IsClientReq
splitClientMethod SMethod m
SCancelRequest = ClientNotOrReq m
ClientNotOrReq 'CancelRequest
forall (m :: Method 'FromClient 'Notification).
(HasJSON (ClientMessage m),
ClientMessage m ~ NotificationMessage m) =>
ClientNotOrReq m
IsClientNot
splitClientMethod SCustomMethod{} = ClientNotOrReq m
ClientNotOrReq 'CustomMethod
forall {t :: MethodType}. ClientNotOrReq 'CustomMethod
IsClientEither
{-# INLINE splitServerMethod #-}
splitServerMethod :: SServerMethod m -> ServerNotOrReq m
splitServerMethod :: forall {t :: MethodType} (m :: Method 'FromServer t).
SServerMethod m -> ServerNotOrReq m
splitServerMethod SMethod m
SWindowShowMessage = ServerNotOrReq m
ServerNotOrReq 'WindowShowMessage
forall (m :: Method 'FromServer 'Notification).
(HasJSON (ServerMessage m),
ServerMessage m ~ NotificationMessage m) =>
ServerNotOrReq m
IsServerNot
splitServerMethod SMethod m
SWindowShowMessageRequest = ServerNotOrReq m
ServerNotOrReq 'WindowShowMessageRequest
forall (m :: Method 'FromServer 'Request).
(HasJSON (ServerMessage m), HasJSON (ResponseMessage m),
ServerMessage m ~ RequestMessage m) =>
ServerNotOrReq m
IsServerReq
splitServerMethod SMethod m
SWindowShowDocument = ServerNotOrReq m
ServerNotOrReq 'WindowShowDocument
forall (m :: Method 'FromServer 'Request).
(HasJSON (ServerMessage m), HasJSON (ResponseMessage m),
ServerMessage m ~ RequestMessage m) =>
ServerNotOrReq m
IsServerReq
splitServerMethod SMethod m
SWindowLogMessage = ServerNotOrReq m
ServerNotOrReq 'WindowLogMessage
forall (m :: Method 'FromServer 'Notification).
(HasJSON (ServerMessage m),
ServerMessage m ~ NotificationMessage m) =>
ServerNotOrReq m
IsServerNot
splitServerMethod SMethod m
SWindowWorkDoneProgressCreate = ServerNotOrReq m
ServerNotOrReq 'WindowWorkDoneProgressCreate
forall (m :: Method 'FromServer 'Request).
(HasJSON (ServerMessage m), HasJSON (ResponseMessage m),
ServerMessage m ~ RequestMessage m) =>
ServerNotOrReq m
IsServerReq
splitServerMethod SMethod m
SProgress = ServerNotOrReq m
ServerNotOrReq 'Progress
forall (m :: Method 'FromServer 'Notification).
(HasJSON (ServerMessage m),
ServerMessage m ~ NotificationMessage m) =>
ServerNotOrReq m
IsServerNot
splitServerMethod SMethod m
STelemetryEvent = ServerNotOrReq m
ServerNotOrReq 'TelemetryEvent
forall (m :: Method 'FromServer 'Notification).
(HasJSON (ServerMessage m),
ServerMessage m ~ NotificationMessage m) =>
ServerNotOrReq m
IsServerNot
splitServerMethod SMethod m
SClientRegisterCapability = ServerNotOrReq m
ServerNotOrReq 'ClientRegisterCapability
forall (m :: Method 'FromServer 'Request).
(HasJSON (ServerMessage m), HasJSON (ResponseMessage m),
ServerMessage m ~ RequestMessage m) =>
ServerNotOrReq m
IsServerReq
splitServerMethod SMethod m
SClientUnregisterCapability = ServerNotOrReq m
ServerNotOrReq 'ClientUnregisterCapability
forall (m :: Method 'FromServer 'Request).
(HasJSON (ServerMessage m), HasJSON (ResponseMessage m),
ServerMessage m ~ RequestMessage m) =>
ServerNotOrReq m
IsServerReq
splitServerMethod SMethod m
SWorkspaceWorkspaceFolders = ServerNotOrReq m
ServerNotOrReq 'WorkspaceWorkspaceFolders
forall (m :: Method 'FromServer 'Request).
(HasJSON (ServerMessage m), HasJSON (ResponseMessage m),
ServerMessage m ~ RequestMessage m) =>
ServerNotOrReq m
IsServerReq
splitServerMethod SMethod m
SWorkspaceConfiguration = ServerNotOrReq m
ServerNotOrReq 'WorkspaceConfiguration
forall (m :: Method 'FromServer 'Request).
(HasJSON (ServerMessage m), HasJSON (ResponseMessage m),
ServerMessage m ~ RequestMessage m) =>
ServerNotOrReq m
IsServerReq
splitServerMethod SMethod m
SWorkspaceApplyEdit = ServerNotOrReq m
ServerNotOrReq 'WorkspaceApplyEdit
forall (m :: Method 'FromServer 'Request).
(HasJSON (ServerMessage m), HasJSON (ResponseMessage m),
ServerMessage m ~ RequestMessage m) =>
ServerNotOrReq m
IsServerReq
splitServerMethod SMethod m
SWorkspaceSemanticTokensRefresh = ServerNotOrReq m
ServerNotOrReq 'WorkspaceSemanticTokensRefresh
forall (m :: Method 'FromServer 'Request).
(HasJSON (ServerMessage m), HasJSON (ResponseMessage m),
ServerMessage m ~ RequestMessage m) =>
ServerNotOrReq m
IsServerReq
splitServerMethod SMethod m
STextDocumentPublishDiagnostics = ServerNotOrReq m
ServerNotOrReq 'TextDocumentPublishDiagnostics
forall (m :: Method 'FromServer 'Notification).
(HasJSON (ServerMessage m),
ServerMessage m ~ NotificationMessage m) =>
ServerNotOrReq m
IsServerNot
splitServerMethod SMethod m
SCancelRequest = ServerNotOrReq m
ServerNotOrReq 'CancelRequest
forall (m :: Method 'FromServer 'Notification).
(HasJSON (ServerMessage m),
ServerMessage m ~ NotificationMessage m) =>
ServerNotOrReq m
IsServerNot
splitServerMethod SCustomMethod{} = ServerNotOrReq m
ServerNotOrReq 'CustomMethod
forall {t :: MethodType}. ServerNotOrReq 'CustomMethod
IsServerEither
data CustomEq m1 m2 where
CustomEq
:: (m1 ~ (CustomMethod :: Method f t1), m2 ~ (CustomMethod :: Method f t2))
=> { forall (f :: From) (t1 :: MethodType) (m1 :: Method f t1)
(t2 :: MethodType) (m2 :: Method f t2).
CustomEq m1 m2 -> (t1 ~ t2) => m1 :~~: m2
runCustomEq :: (t1 ~ t2 => m1 :~~: m2) }
-> CustomEq m1 m2
runEq :: (t1 ~ t2)
=> (SMethod m1 -> SMethod m2 -> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2)))
-> SMethod (m1 :: Method f t1)
-> SMethod (m2 :: Method f t2)
-> Maybe (m1 :~~: m2)
runEq :: forall (t1 :: MethodType) (t2 :: MethodType) (f :: From)
(m1 :: Method f t1) (m2 :: Method f t2).
(t1 ~ t2) =>
(SMethod m1
-> SMethod m2 -> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2)))
-> SMethod m1 -> SMethod m2 -> Maybe (m1 :~~: m2)
runEq SMethod m1
-> SMethod m2 -> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
f SMethod m1
m1 SMethod m2
m2 = do
Either (CustomEq m1 m2) (m1 :~~: m2)
res <- SMethod m1
-> SMethod m2 -> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
f SMethod m1
m1 SMethod m2
m2
(m1 :~~: m2) -> Maybe (m1 :~~: m2)
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((m1 :~~: m2) -> Maybe (m1 :~~: m2))
-> (m1 :~~: m2) -> Maybe (m1 :~~: m2)
forall a b. (a -> b) -> a -> b
$ case Either (CustomEq m1 m2) (m1 :~~: m2)
res of
Right m1 :~~: m2
eq -> m1 :~~: m2
eq
Left CustomEq m1 m2
ceq -> CustomEq m1 m2 -> (t1 ~ t2) => m1 :~~: m2
forall (f :: From) (t1 :: MethodType) (m1 :: Method f t1)
(t2 :: MethodType) (m2 :: Method f t2).
CustomEq m1 m2 -> (t1 ~ t2) => m1 :~~: m2
runCustomEq CustomEq m1 m2
ceq
mEqServer :: SServerMethod m1 -> SServerMethod m2 -> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
mEqServer :: forall {t1 :: MethodType} {t2 :: MethodType}
(m1 :: Method 'FromServer t1) (m2 :: Method 'FromServer t2).
SServerMethod m1
-> SServerMethod m2 -> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
mEqServer SServerMethod m1
m1 SServerMethod m2
m2 = ServerNotOrReq m1
-> ServerNotOrReq m2
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
go (SServerMethod m1 -> ServerNotOrReq m1
forall {t :: MethodType} (m :: Method 'FromServer t).
SServerMethod m -> ServerNotOrReq m
splitServerMethod SServerMethod m1
m1) (SServerMethod m2 -> ServerNotOrReq m2
forall {t :: MethodType} (m :: Method 'FromServer t).
SServerMethod m -> ServerNotOrReq m
splitServerMethod SServerMethod m2
m2)
where
go :: ServerNotOrReq m1
-> ServerNotOrReq m2
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
go ServerNotOrReq m1
IsServerNot ServerNotOrReq m2
IsServerNot = do
m1 :~: m2
Refl <- SServerMethod m1 -> SMethod m2 -> Maybe (m1 :~: m2)
forall k (f :: k -> *) (a :: k) (b :: k).
GEq f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: Method 'FromServer t1) (b :: Method 'FromServer t1).
SMethod a -> SMethod b -> Maybe (a :~: b)
geq SServerMethod m1
m1 SMethod m2
SServerMethod m2
m2
Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2)))
-> Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a b. (a -> b) -> a -> b
$ (m1 :~~: m1) -> Either (CustomEq m1 m2) (m1 :~~: m1)
forall a b. b -> Either a b
Right m1 :~~: m1
forall {k1} (a :: k1). a :~~: a
HRefl
go ServerNotOrReq m1
IsServerReq ServerNotOrReq m2
IsServerReq = do
m1 :~: m2
Refl <- SServerMethod m1 -> SMethod m2 -> Maybe (m1 :~: m2)
forall k (f :: k -> *) (a :: k) (b :: k).
GEq f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: Method 'FromServer t1) (b :: Method 'FromServer t1).
SMethod a -> SMethod b -> Maybe (a :~: b)
geq SServerMethod m1
m1 SMethod m2
SServerMethod m2
m2
Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2)))
-> Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a b. (a -> b) -> a -> b
$ (m1 :~~: m1) -> Either (CustomEq m1 m2) (m1 :~~: m1)
forall a b. b -> Either a b
Right m1 :~~: m1
forall {k1} (a :: k1). a :~~: a
HRefl
go ServerNotOrReq m1
IsServerEither ServerNotOrReq m2
IsServerEither
| SCustomMethod Text
c1 <- SServerMethod m1
m1
, SCustomMethod Text
c2 <- SServerMethod m2
m2
, Text
c1 Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
c2
= Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a. a -> Maybe a
Just (Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2)))
-> Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a b. (a -> b) -> a -> b
$ CustomEq m1 m2 -> Either (CustomEq m1 m2) (m1 :~~: m2)
forall a b. a -> Either a b
Left (CustomEq m1 m2 -> Either (CustomEq m1 m2) (m1 :~~: m2))
-> CustomEq m1 m2 -> Either (CustomEq m1 m2) (m1 :~~: m2)
forall a b. (a -> b) -> a -> b
$ ((t1 ~ t2) => m1 :~~: m2) -> CustomEq m1 m2
forall (f :: From) (t1 :: MethodType) (m1 :: Method f t1)
(t2 :: MethodType) (m2 :: Method f t2).
(m1 ~ 'CustomMethod, m2 ~ 'CustomMethod) =>
((t1 ~ t2) => m1 :~~: m2) -> CustomEq m1 m2
CustomEq m1 :~~: m1
m1 :~~: m2
(t1 ~ t2) => m1 :~~: m2
forall {k1} (a :: k1). a :~~: a
HRefl
go ServerNotOrReq m1
_ ServerNotOrReq m2
_ = Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a. Maybe a
Nothing
mEqClient :: SClientMethod m1 -> SClientMethod m2 -> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
mEqClient :: forall {t1 :: MethodType} {t2 :: MethodType}
(m1 :: Method 'FromClient t1) (m2 :: Method 'FromClient t2).
SClientMethod m1
-> SClientMethod m2 -> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
mEqClient SClientMethod m1
m1 SClientMethod m2
m2 = ClientNotOrReq m1
-> ClientNotOrReq m2
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
go (SClientMethod m1 -> ClientNotOrReq m1
forall {t :: MethodType} (m :: Method 'FromClient t).
SClientMethod m -> ClientNotOrReq m
splitClientMethod SClientMethod m1
m1) (SClientMethod m2 -> ClientNotOrReq m2
forall {t :: MethodType} (m :: Method 'FromClient t).
SClientMethod m -> ClientNotOrReq m
splitClientMethod SClientMethod m2
m2)
where
go :: ClientNotOrReq m1
-> ClientNotOrReq m2
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
go ClientNotOrReq m1
IsClientNot ClientNotOrReq m2
IsClientNot = do
m1 :~: m2
Refl <- SClientMethod m1 -> SMethod m2 -> Maybe (m1 :~: m2)
forall k (f :: k -> *) (a :: k) (b :: k).
GEq f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: Method 'FromClient t1) (b :: Method 'FromClient t1).
SMethod a -> SMethod b -> Maybe (a :~: b)
geq SClientMethod m1
m1 SMethod m2
SClientMethod m2
m2
Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2)))
-> Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a b. (a -> b) -> a -> b
$ (m1 :~~: m1) -> Either (CustomEq m1 m2) (m1 :~~: m1)
forall a b. b -> Either a b
Right m1 :~~: m1
forall {k1} (a :: k1). a :~~: a
HRefl
go ClientNotOrReq m1
IsClientReq ClientNotOrReq m2
IsClientReq = do
m1 :~: m2
Refl <- SClientMethod m1 -> SMethod m2 -> Maybe (m1 :~: m2)
forall k (f :: k -> *) (a :: k) (b :: k).
GEq f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: Method 'FromClient t1) (b :: Method 'FromClient t1).
SMethod a -> SMethod b -> Maybe (a :~: b)
geq SClientMethod m1
m1 SMethod m2
SClientMethod m2
m2
Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2)))
-> Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a b. (a -> b) -> a -> b
$ (m1 :~~: m1) -> Either (CustomEq m1 m2) (m1 :~~: m1)
forall a b. b -> Either a b
Right m1 :~~: m1
forall {k1} (a :: k1). a :~~: a
HRefl
go ClientNotOrReq m1
IsClientEither ClientNotOrReq m2
IsClientEither
| SCustomMethod Text
c1 <- SClientMethod m1
m1
, SCustomMethod Text
c2 <- SClientMethod m2
m2
, Text
c1 Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
c2
= Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a. a -> Maybe a
Just (Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2)))
-> Either (CustomEq m1 m2) (m1 :~~: m2)
-> Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a b. (a -> b) -> a -> b
$ CustomEq m1 m2 -> Either (CustomEq m1 m2) (m1 :~~: m2)
forall a b. a -> Either a b
Left (CustomEq m1 m2 -> Either (CustomEq m1 m2) (m1 :~~: m2))
-> CustomEq m1 m2 -> Either (CustomEq m1 m2) (m1 :~~: m2)
forall a b. (a -> b) -> a -> b
$ ((t1 ~ t2) => m1 :~~: m2) -> CustomEq m1 m2
forall (f :: From) (t1 :: MethodType) (m1 :: Method f t1)
(t2 :: MethodType) (m2 :: Method f t2).
(m1 ~ 'CustomMethod, m2 ~ 'CustomMethod) =>
((t1 ~ t2) => m1 :~~: m2) -> CustomEq m1 m2
CustomEq m1 :~~: m1
m1 :~~: m2
(t1 ~ t2) => m1 :~~: m2
forall {k1} (a :: k1). a :~~: a
HRefl
go ClientNotOrReq m1
_ ClientNotOrReq m2
_ = Maybe (Either (CustomEq m1 m2) (m1 :~~: m2))
forall a. Maybe a
Nothing