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?
Asked
Active
Viewed 72 times
0
-
3The result of the last command is bound to the variable `it`. You can `writeFile "filename.txt" it`. Or `writefile "filename.txt" $
`. – vivian Mar 02 '14 at 03:32 -
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? @vivian – MrD Mar 02 '14 at 12:17
-
@DarioP: If it is an instance of `Show`, just use `writeFile "filename.txt" $ show it`. – Zeta Mar 02 '14 at 12:42
-
@zeta I get "not in scope id, did you mean id"... thoughts? – MrD Mar 02 '14 at 13:02
-
1@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 Mar 02 '14 at 13:51
1 Answers
1
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>

vivian
- 1,434
- 1
- 10
- 13