+-- | A session representing one instance of launching and connecting to a server.
+--
+-- You can send and receive messages to the server within 'Session' via 'getMessage',
+-- 'sendRequest' and 'sendNotification'.
+--
+-- @
+-- runSession \"path\/to\/root\/dir\" $ do
+-- docItem <- getDocItem "Desktop/simple.hs" "haskell"
+-- sendNotification TextDocumentDidOpen (DidOpenTextDocumentParams docItem)
+-- diagnostics <- getMessage :: Session PublishDiagnosticsNotification
+-- @
+type Session = ParserStateReader FromServerMessage SessionState SessionContext IO
+
+-- | Stuff you can configure for a 'Session'.
+data SessionConfig = SessionConfig
+ {
+ capabilities :: ClientCapabilities, -- ^ Specific capabilities the client should advertise.
+ timeout :: Int -- ^ Maximum time to wait for a request in seconds.
+ }
+
+instance Default SessionConfig where
+ def = SessionConfig def 60
+
+class Monad m => MonadSessionConfig m where
+ sessionConfig :: m SessionConfig
+
+instance Monad m => MonadSessionConfig (StateT SessionState (ReaderT SessionContext m)) where
+ sessionConfig = config <$> lift Reader.ask
+