Run interactive cli program.

Skip to first unread message

Alexey Veselovsky

Apr 6, 2010, 5:23:41 AM4/6/10
to leksah
I have wrote and run very simple program:

main = do c ← getChar
print c

How to enter smth data to stdin?
Log window is read only. It is also not possible to stop this program.

Also this program blocks leksah if I run it in ghci mode. (if I select
"stop debug" menu, then leksah just closes down).

Hamish Mackenzie

Apr 6, 2010, 8:02:32 AM4/6/10
This is a known issue we have not addressed yet. We send GCHi commands to its stdin, but we have no good way for sending user input there too.

I am not sure how we should fix this. We can't send user input to the process that is being debugged using our command channel (our code waits for the prompt from ghci before sending commands).

If we set up some way to send data to stdin without waiting it may interfere with the GHCi commands we send (because it is still all going down the same pipe).

We need to find out if there is some way we can have separate stdin/stdout/stderr pipes for GHCi itself and the program GHCi is debugging.

In the mean time you could have you app open a socket or named pipe and write input to that from another terminal. Something like this (not tested)...

main = do
sock <- listenOn (PortNumber 8000)
-- Start a new terminal window (this command needs to be changed for OS X or Windows)
forkIO $ system "gnome-terminal -e \"telnet localhost 8000\""
(handle, _, _) <- accept sock -- Wait for the new terminal to connect
-- You might want to add a call to hSetBuffering here
line <- hGetLine handle
print line
sClose sock

(You will need to add process and network to your package dependancies. Then Ctrl+R should add the import statements needed.)

This will allow interaction, but keep stdin clear for leksah to talk to ghci. Ideally you would keep stdout and stderr clear too and write to this socket instead, but Leksah should cope fairly well with arbitrary output.

> --
> To unsubscribe, reply using "remove me" as the subject.

Vladislav Sukhmel

Jan 14, 2014, 2:20:11 PM1/14/14
I'm sorry for bringing this up after so long, but is this challenge solved somehow up to date?

On Tuesday, 6 April 2010 16:02:32 UTC+4, Hamish wrote:
This is a known issue we have not addressed yet.  

Best regargds, Vlad. 

Matthew Sammut

Apr 4, 2016, 4:09:07 AM4/4/16
to leksah
It's 2016, is this issue solved yet?
Reply all
Reply to author
0 new messages