Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What about having a ghci daemon and a feeder script that takes the script path and location, communicates with the already running ghci process to load and execute the script in the proper directory and pipes the output back to the feeder script for stdout?</p> <p>Unfortunately, I have no idea how to write something like this, but it seems like it could be really fast judging by the speed of :l in ghci. As it seems most of the cost in runhaskell is in starting up ghci, not parsing and running the script. </p> <p><strong>Edit:</strong> After some playing around, I found the <a href="http://hackage.haskell.org/package/hint" rel="nofollow">Hint package</a> (a wrapper around the GHC API) to be of perfect use here. The following code will load the passed in module name (here assumed to be in the same directory) and will execute the main function. Now 'all' that's left is to make it a daemon, and have it accept scripts on a pipe or socket.</p> <pre><code>import Language.Haskell.Interpreter import Control.Monad run = runInterpreter . test test :: String -&gt; Interpreter () test mname = do loadModules [mname ++ ".hs"] setTopLevelModules [mname] res &lt;- interpret "main" (as :: IO()) liftIO res </code></pre> <p><strong>Edit2:</strong> As far as stdout/err/in go, using <a href="http://nominolo.blogspot.com/2010/04/haskell-tip-redirect-stdout-in-haskell.html" rel="nofollow">this specific GHC trick</a> It looks like it would be possible to redirect the std's of the client program into the feeder program, then into some named pipes (perhaps) that the daemon is connected to at all times, and then have the daemon's stdout back to another named pipe that the feeder program is listening to. Pseudo-example:</p> <pre><code>grep ... | feeder my_script.hs | xargs ... | ^---------------- &lt; V | named pipe -&gt; daemon -&gt; named pipe </code></pre> <p>Here the feeder would be a small compiled harness program to just redirect the std's into and then back out of the daemon and give the name and location of the script to the daemon.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload