commercialhaskell / stack-ide

Stack-based JSON interface to ide-backend
98 stars 23 forks source link

Support running multiple processes #25

Open mgsloan opened 9 years ago

mgsloan commented 9 years ago

ide-backend supports running multiple processes at once, based on the same interpreter session. Currently, stack-ide only allows one process, an unnecessary restriction.

mgsloan commented 9 years ago

The API changes would look something like this:

diff --git a/stack-ide-api/src/Stack/Ide/JsonAPI.hs b/stack-ide-api/src/Stack/Ide/JsonAPI.hs
index 982fd8a..8fd8d39 100644
--- a/stack-ide-api/src/Stack/Ide/JsonAPI.hs
+++ b/stack-ide-api/src/Stack/Ide/JsonAPI.hs
@@ -76,12 +76,11 @@ data Request =
   | RequestGetAutocompletion AutocompletionSpan
   -- Run
   | RequestRun Bool ModuleName Identifier
-  | RequestProcessInput String
-  | RequestProcessKill
+  | RequestProcessInput ProcessId String
+  | RequestProcessKill ProcessId
   -- Misc
   | RequestShutdownSession

-
 -- | Session updates
 data RequestSessionUpdate
   = RequestUpdateTargets Targets
@@ -108,9 +107,10 @@ data Response =
   | ResponseGetAnnExpTypes [ResponseAnnExpType]
   | ResponseGetAutocompletion [AutocompletionInfo]
   -- Run
-  | ResponseProcessOutput String
-  | ResponseProcessDone RunResult
-  | ResponseNoProcessError
+  | ResponseRun ProcessId
+  | ResponseProcessOutput ProcessId String
+  | ResponseProcessDone ProcessId RunResult
+  | ResponseNoSuchProcessError ProcessId
   -- Misc
   | ResponseInvalidRequest String
   | ResponseShutdownSession
@@ -169,6 +169,8 @@ data CodeVariety =
   -- default to yielding type id info.  The expression annotated code
   -- is yielded in this annotation.

+newtype ProcessId = ProcessId Int
+
 -- | Client version
 --
 -- Standard versioning applies (major, minor, patch)
`
mgsloan commented 9 years ago

Assigning this to myself for now, but not sure when I'll get around to it. Feel free to jump in and do this!