
On 2/10/07, Joel Reymont
Is anyone using Haskell as a scripting language in their app?
I'm thinking of viable it would be to embed ghc in a Mac (Cocoa) app.
Is your application primarily written in Haskell? If not, you would have to create an interface between that language and Haskell in order for your Haskell programs to manipulate your domain objects and user interface. I think people would be happy if you did this because then there would be a Haskell API for Cocoa, but it seems like a lot of work. My guess is that it would be easier to do such bindings for Javascript due to its dynamic nature and it being an object-oriented language. Also, several projects have embedded Javascript successfully and so you would have many examples to base your project on. Visual Haskell also embeds GHC (into Visual Studio). However, Visual Haskell makes my Visual Studio unstable and often unresponsive. Because of this, I decided to use a multi-process design when embeddeding GHC into an editor--I built a customized version of the stock GHC executable that accepts commands from its parent process instead of through the command line. This way, any crashing or similar problems in the modified compiler will not result in the user losing any work in the editor. Also, I don't have to worry about threading problems, I can more clearly monitor the memory usage of the compiler/code-analyzer distinctly from that of the editor, and it should also be easier to swap in another Haskell implementation (e.g. jhc, yhc) if I wanted to. But, there were disadvantages too (e.g. I had to implement my own lexer because doing doing it with GHC via IPC was too slow for interactive use). Also, I recommend looking into embedding YHC. I have not had a chance to use it yet, but it looks like it is a better fit to an "interpreter-only" embedding situation than GHC--with GHC, you are getting a lot more than you seem to be asking for. - Brian