2

I got an architectural problem here.

Let say there is an IShell. It mainly responsible to map user's commands (represented as a linux-like strings) to an appropriate IExecutable's.

Those executables are pretty various. Hence, there are different modules/assemblies/dlls (or how-the-hell-you-call-it): Module1, Module2, Module3 all providing different implementations of abovementioned IExecutable.

Now there is a requirement to be able substitute any of those modules on the fly, at the run time, without stopping IShell instance. Obviously, there gonna be some kind of API, like /api/update/module1 and... it might return a raw code to be compiled locally (what are advantages and disadvantages?) or it might respond with precompiled *dll.

No matter how, at some point IShell will eventually receive newest version of particular module. And here emerges the biggest problem. Assuming I can "pause" what's happening inside, what's the clearest and robust way to substitute currently loaded module with a new one?

Since most of the code written in Haskell, I am definitely interested in Haskell-related solution. Or, at least, I'd like to acknowledge the fact that there is no one.

P.S. If someone of you, guys, is aware of concept might work, but not Haskell's realization of that one, still let me know. Thanks in advance.

  • 1
    Not saying this is the wrong forum for your question, but my gut feeling is that you're more likely to get a good answer to this question on stack overflow. – David Arno Feb 15 '18 at 13:05
  • 1
    @DavidArno will try it out as well. I thought like this forum is much more appropriate. Seems like mistaken. – Sereja Bogolubov Feb 15 '18 at 13:12
1

I could imagine something like a mutable map that serves to look up a module by name. Once you receive a new version of code, you update that map with a new instance of an IExecutable.

Of course all this can only live inside IO; I suppose it will be in the "impure crust" layer. The "pure core" will be called in a do / >>=, while the lookup of IO IExecutable will happen outside.

IDK how to best load and re-load DLLs in Haskell. But you can use module GHC to compile them from source.

  • Yeah. Seems like impossible to keep those things perfectly pure. IO sounds like a promissing attempt... – Sereja Bogolubov Feb 16 '18 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.