-
Notifications
You must be signed in to change notification settings - Fork 206
Plugin startup / private data #83
Comments
Hmm. How do we update the private state? The sync version is easy type SyncCommandFunc resp = forall m. (MonadIO m,GHC.GhcMonad m,HasIdeState m)
=> Dynamic -> [AcceptedContext] -> IdeRequest -> m (IdeResponse resp,Dynamic) What about the async? type AsyncCommandFunc resp = forall m. (MonadIO m,GHC.GhcMonad m,HasIdeState m)
=> (IdeResponse resp -> IO ()) -> [AcceptedContext] -> IdeRequest -> m () At the moment the So there are two different issues
Potentially type AsyncCommandFunc resp = forall m. (MonadIO m,GHC.GhcMonad m,HasIdeState m)
=> (IdeResponse resp -> (Maybe Dynamic) -> IO ()) -> [AcceptedContext] -> IdeRequest -> m (Maybe Dynamic) Another simple but horribly way is to never update the state after initial creation, on the assumption that it creates an |
I don't find this horrible at all, I quite like this approach because then I can put a variety of different ref types in my state. It handily solves the async conundrum. How about doing something like XMonad's ExtensibleState? In line with not actually handling mutation, it'd look like:
(where the So, if there's no value for I like this XMonad-ey approach because it also allows plugins to share state. If plugin A imports plugin B, then it can use plugin B's exported state types. For example, if there's a plugin that tracks how the renamer is renaming things and storing this away in a map, this map is generally useful to numerous queries which don't necessarily reside in the same plugin. This gets a bit tricky though, because it also means that plugin B also needs to actually be used by HIE. |
Good point. We already have a state variable in IdeM, can put either a private accessor for the given plugin or one to access all the state. The types can by shared anyway, because it is all compiled in, so the dependencies are present. |
The extensible state work is happening here: https://github.com/alanz/haskell-ide-engine/tree/plugin-state |
Some plugins need to do some initial startup, and then store some state.
We need to come up with a way to do this.
This will probably include some kind of life-cycle methods exposed as part of the plugin, together with a way to store the state.
It may be simplest to define the state as being of type
Data.Dynamic
, as each plugin will know how to convert it for its own internal use.So we add
and each
CommandFunc
gets an additionalDynamic
parameter passed in.The text was updated successfully, but these errors were encountered: