0
votes

I have a Haskell function which returns quite a large output. (In fact, beyond the console's buffer size.) Is there any way GHCI output can be automatically saved to an external txt file rather than simply displayed?

1
The result of the last command is bound to the variable it. You can writeFile "filename.txt" it. Or writefile "filename.txt" $ <statement>.vivian
Tried that, not working. The point is my function returns [Integer] and writeFile seems to expect [Char]. Any ideas on how I could fix that? @vivianMrD
@DarioP: If it is an instance of Show, just use writeFile "filename.txt" $ show it.Zeta
@zeta I get "not in scope id, did you mean id"... thoughts?MrD
@DarioP: Yes - it stores the result of the last command. If there hasn't been a last statement with a value (for instance, all statements have been let ... expressions), it will be not in scope. So basically take vivian's comment, but put a $ show before your statements.Zeta

1 Answers

1
votes

The result of the last command is bound to the variable it.

You can

writeFile "filename.txt" $ show it

or

writefile "filename.txt" $ show $ <statement>