How to getCh on MS Windows command line?
Simon Marlow
marlowsd at gmail.com
Mon Nov 10 09:11:58 EST 2008
Ahn, Ki Yung wrote:
> What I mean by getCh is the non-buffered non-echoed version of getChar,
> which Hugs used to provided as an extension but not any more.
>
> Is there any way to have a non-buffered non-echoed single character
> input function on MS Windows command line using only the libraries in
> the MS Windows distribution packages of either GHC or Hugs?
>
> The reason to why this is important for me is because I am translating
> Graham Hutton's "Programming in Haskell" into Korean (soon to be
> published), which illustrates interactive programming with the example
> of a calculator that responds instantly for every keystroke of numbers
> and arithmetic operations running on text mode. It is very important to
> consider the readers who only have access to MS Windows systems, because
> Korean OS market share is completely skewed towards MS Windows for very
> embarrassing reasons that I do not even want to mention. And, isn't GHC
> developed in MSR anyway? :-)
>
>
> I remember that this is an old problem for both of the two most widely
> used Haskell implementation, Hugs and GHC.
>
> In ghc 6.8 getChar had a bit strange behavior. As far as I remember it
> always worked as if it were NoBuffering. Fortunately, in the recently
> released ghc 6.10, this has been fixed. We now actually have to set the
> buffering mode to NoBuffering with hSetBufferring to get the
> non-buffered behavior of getChar. But, it still isn't working on MS
> Windows.
Here's the ticket:
http://hackage.haskell.org/trac/ghc/ticket/2189
This needs somebody familiar with the intricacies of Windows Consoles to
fix. Any takers?
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list