Re: [Haskell-cafe] Interactive chatbot
No worries, I'd rather have it twice than not at all :-) Thank you all for the helpful tipps. We ended up knowing a lot more about Haskell. The easiest solution however, was to compile it all into an application - tadaa, deleting works as wished for. Regards, Torsten Am 05.11.2009 um 02:00 schrieb Ben Millwood: > Oops, I clicked "reply" instead of "reply to all". Duplicating the > message below. > I suppose this means someone is going to get two copies of this. Sorry > someone! > > On Thu, Nov 5, 2009 at 12:56 AM, Ben Millwood > wrote: >> On Wed, Nov 4, 2009 at 10:21 PM, Torsten Otto wrote: >>> >>> When we read the user's input through t <- getLine >>> it is not possible to delete typos before hitting enter and thereby sending >>> the input off to the system (at least in OS X, bash). I didn't find that >>> terribly problematic, but of course it is a bit of a show stopper from their >>> point of view. >>> >> >> As people have said it's worth checking what buffering settings you >> are using (especially note that ghci changes some interesting settings >> in relation to how input is handled, and compiled code may behave >> differently), but it might also be worth checking the terminal >> application's preferences to see if there are settings related to the >> interpretation of the backspace key that you need to twiddle one way >> or the other. In particular, if you are finding that pressing delete >> makes ^H appear on the input line instead of deleting things, or if >> pressing ctrl-H deletes stuff where the delete key fails to do so, it >> might be a problem with your terminal rather than with your program. >> This is only based on what I vaguely remember from faffing with the >> Mac Terminal application some time ago when it wouldn't co-operate >> with screen, but it may be worth a look. >> >> yours, >> Ben Millwood >> ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Interactive chatbot
Oops, I clicked "reply" instead of "reply to all". Duplicating the message below. I suppose this means someone is going to get two copies of this. Sorry someone! On Thu, Nov 5, 2009 at 12:56 AM, Ben Millwood wrote: > On Wed, Nov 4, 2009 at 10:21 PM, Torsten Otto wrote: >> >> When we read the user's input through >>> t <- getLine >> it is not possible to delete typos before hitting enter and thereby sending >> the input off to the system (at least in OS X, bash). I didn't find that >> terribly problematic, but of course it is a bit of a show stopper from their >> point of view. >> > > As people have said it's worth checking what buffering settings you > are using (especially note that ghci changes some interesting settings > in relation to how input is handled, and compiled code may behave > differently), but it might also be worth checking the terminal > application's preferences to see if there are settings related to the > interpretation of the backspace key that you need to twiddle one way > or the other. In particular, if you are finding that pressing delete > makes ^H appear on the input line instead of deleting things, or if > pressing ctrl-H deletes stuff where the delete key fails to do so, it > might be a problem with your terminal rather than with your program. > This is only based on what I vaguely remember from faffing with the > Mac Terminal application some time ago when it wouldn't co-operate > with screen, but it may be worth a look. > > yours, > Ben Millwood > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Interactive chatbot
On Wed, Nov 4, 2009 at 3:14 PM, Jason Dagit wrote: > > > On Wed, Nov 4, 2009 at 2:21 PM, Torsten Otto wrote: >> >> Hi! >> >> My students have the task to program an interactive chatbot. We have run >> into a problem that I can't solve either: >> >> When we read the user's input through >> > t <- getLine >> it is not possible to delete typos before hitting enter and thereby >> sending the input off to the system (at least in OS X, bash). I didn't find >> that terribly problematic, but of course it is a bit of a show stopper from >> their point of view. > > Is it possible that you need to tweak the input buffering settings? > http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#v:hSetBuffering > You probably want to look at 'interact' also. > Or just switch to readline as others have suggested. > Jason Another possibility (perhaps simpler) is to use an external program such as rlwrap to handle input. Shachaf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Interactive chatbot
On Wed, Nov 4, 2009 at 2:21 PM, Torsten Otto wrote: > Hi! > > My students have the task to program an interactive chatbot. We have run > into a problem that I can't solve either: > > When we read the user's input through > > t <- getLine > it is not possible to delete typos before hitting enter and thereby sending > the input off to the system (at least in OS X, bash). I didn't find that > terribly problematic, but of course it is a bit of a show stopper from their > point of view. > Is it possible that you need to tweak the input buffering settings? http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#v:hSetBuffering You probably want to look at 'interact' also. Or just switch to readline as others have suggested. Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Interactive chatbot
On Wed, Nov 4, 2009 at 2:21 PM, Torsten Otto wrote: > Hi! > > My students have the task to program an interactive chatbot. We have run > into a problem that I can't solve either: > > When we read the user's input through >> t <- getLine > it is not possible to delete typos before hitting enter and thereby sending > the input off to the system (at least in OS X, bash). Why reinvent the shell? Is the program not setup in such a way as to make the ShellAC package a useful solution? I see someone already chimed in with readline. You might want to look at haskeline too, if you go that path (both are a step lower than ShellAC wrt abstraction). Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Interactive chatbot
The library at http://hackage.haskell.org/package/readline might solve your problem. Cheers, Greg On Nov 4, 2009, at 2:21 PM, Torsten Otto wrote: Hi! My students have the task to program an interactive chatbot. We have run into a problem that I can't solve either: When we read the user's input through > t <- getLine it is not possible to delete typos before hitting enter and thereby sending the input off to the system (at least in OS X, bash). I didn't find that terribly problematic, but of course it is a bit of a show stopper from their point of view. The input is then used to generate a reply in purely functional code, and the reply sent to the command line via putStr. Is there a more clever way to interact with the user that would allow editing ones text before sending it to the bot? I guess we could try with a website, but don't know off hand how to do that, either, although I've seen beautiful webservers made in Haskell... Regards, Torsten Otto ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Interactive chatbot
Hi! My students have the task to program an interactive chatbot. We have run into a problem that I can't solve either: When we read the user's input through > t <- getLine it is not possible to delete typos before hitting enter and thereby sending the input off to the system (at least in OS X, bash). I didn't find that terribly problematic, but of course it is a bit of a show stopper from their point of view. The input is then used to generate a reply in purely functional code, and the reply sent to the command line via putStr. Is there a more clever way to interact with the user that would allow editing ones text before sending it to the bot? I guess we could try with a website, but don't know off hand how to do that, either, although I've seen beautiful webservers made in Haskell... Regards, Torsten Otto ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe