
The following program prints Right ("test","Bool","True") as it should, but it leaves behind in /tmp two files (name is a long string of digits) and an empty directory (name is ghcNNNNN_N). ... and it deletes the input file (/tmp/Main.hs). That's not nice. Ideally, I would want to read input from a String (instead of the file), and not write to disk at all. But cleaning up properly would be OK as a work-around. import Language.Haskell.Interpreter import Mueval.Interpreter import Mueval.ArgsParse main = do writeFile "/tmp/Main.hs" "test = True" result <- runInterpreter $ interpreter $ Options { timeLimit =1, modules =Just ["Prelude"], expression ="test" , loadFile ="/tmp/Main.hs", user="what", printType =True , extensions =False,namedExtensions = [] , noImports =False, rLimits =False, help=True } print result ghc --version The Glorious Glasgow Haskell Compilation System, version 7.4.1 ghc-pkg list| egrep 'mueval|hint' hint-0.3.3.4 mueval-0.8.1.1 uname -a Linux octopus 3.0.0-16-generic #29-Ubuntu SMP Tue Feb 14 12:48:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Johannes Waldmann wrote:
The following program prints Right ("test","Bool","True") as it should, but it leaves behind in /tmp two files (name is a long string of digits) and an empty directory (name is ghcNNNNN_N).
I have a partial solutions for this; see the attached patch for hint. It cleans up the numbered files, which are generated for "phantom modules". There are two phantom modules generated -- one that defines a _show function for hint's internal use, and one that provides a bunch of pre-imported modules for mueval. The latter will not be generated if the 'modules' mueval option is set to Nothing. For some reason, cleaning the ghc* directory fails if the executed code fails (for example, using 'test = undefined' in Johannes' code). Can anybody explain why? The `finally` handler is run, and the phantom module files are actually deleted.
... and it deletes the input file (/tmp/Main.hs).
That appears to be an undocumented mueval feature. It's not a good one, I think.
That's not nice. Ideally, I would want to read input from a String (instead of the file), and not write to disk at all.
I suppose that ghc's interface does not support this, but I have not checked. Best regards, Bertram
participants (2)
-
Bertram Felgenhauer
-
Johannes Waldmann