getContents, getLine, etc.

Ross Paterson ross@soi.city.ac.uk
Fri, 1 Aug 2003 12:36:52 +0100


On Fri, Aug 01, 2003 at 11:02:02AM +0100, Malcolm Wallace wrote:
> "Wojciech Moczydlowski, Jr" <khaliff@astercity.net> writes:
> 
> >                          However, backspace doesn't work, no matter which
> > function(getContents, getLine) I use, which makes debugging and normal work
> > with the program a nightmare. Does anyone know any workaround (i.e. sensible
> > replacement to getLine) apart from switching to ghc and using the readline 
> > library?
> 
> I recently posted the attached "SimpleLineEditor" module to the Haskell
> libraries mailing list.  To use the module in Hugs, you probably need
> to run it through cpp before loading it.  Then, call
>     initialise     :: IO ()
> before reading the terminal, and
>     restore        :: IO ()
> afterwards, and the replacement for Prelude.getLine is
>     getLineEdited  :: String -> IO (Maybe String)
> where the string argument is the prompt for the user.

I suspect this won't work, because Hugs singles out stdin for some
very wierd treatment (raw mode, with Hugs echoing to stdout, even when
it's not the same as stdin).  It's horrible, but looks hard to change,
because it interacts with a lot of environments.