Re: [Haskell-cafe] Re: Read a single char

2006-10-25 Thread Neil Mitchell

Hi


 Do you have a particular need for typing the end of getContents in
 WinHugs? If so, I can open a bug and might be able to fix it for the
 next release.

Thank you!


Fixed in the CVS version, the next release will allow Ctrl+Z or Ctrl+D
to terminate an input stream. There were also a few additional fixes
around the interact code that I made.

If you want to use these fixes before the next release:

http://haskell.org/hoogle/other/winhugs-interact-fixes-2006-oct-25.zip

Extract winhugs.exe and replace the existing winhugs.exe in a Sep 2006
installation.

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single char

2006-10-25 Thread Dimitri Timofeev
Hi!It works very well, thank you!On 10/25/06, Neil Mitchell [EMAIL PROTECTED] wrote:
Fixed in the CVS version, the next release will allow Ctrl+Z or Ctrl+Dto terminate an input stream. There were also a few additional fixes
around the interact code that I made.If you want to use these fixes before the next release:http://haskell.org/hoogle/other/winhugs-interact-fixes-2006-oct-25.zip
Extract winhugs.exe and replace the existing winhugs.exe in a Sep 2006installation.-- Dimitri
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single Char

2006-10-24 Thread Neil Mitchell

Hi


I have a similar question. When I use getChar with Hugs the newline
(caused by pressing 'Enter')  seems to be carried over into the next
call of main, where it is treated as a single input character.
The workaround is getLine and head, but it would be nice to drop the
newline right away. I suppose the solution offered here:


Hmm, sounds like a bug in WinHugs, I'll check it out.

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single Char

2006-10-24 Thread Hans van Thiel
No, it happens with Hugs on Fedora Core 5 (the fc5 Hugs package), not
WinHugs.

Thanks,

Hans

On Tue, 2006-10-24 at 17:27 +0100, Neil Mitchell wrote:
 Hi
 
  I have a similar question. When I use getChar with Hugs the newline
  (caused by pressing 'Enter')  seems to be carried over into the next
  call of main, where it is treated as a single input character.
  The workaround is getLine and head, but it would be nice to drop the
  newline right away. I suppose the solution offered here:
 
 Hmm, sounds like a bug in WinHugs, I'll check it out
 Thanks
 
 Neil

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single Char

2006-10-24 Thread Neil Mitchell

No, it happens with Hugs on Fedora Core 5 (the fc5 Hugs package), not
WinHugs.


Woops, the previous post in a different thread was talking about
WinHugs, and I forgot to context-switch :)

Does GHCi give the different behaviour? If so, one of them is probably a bug.

Thanks

Neil



Thanks,

Hans

On Tue, 2006-10-24 at 17:27 +0100, Neil Mitchell wrote:
 Hi

  I have a similar question. When I use getChar with Hugs the newline
  (caused by pressing 'Enter')  seems to be carried over into the next
  call of main, where it is treated as a single input character.
  The workaround is getLine and head, but it would be nice to drop the
  newline right away. I suppose the solution offered here:

 Hmm, sounds like a bug in WinHugs, I'll check it out
 Thanks

 Neil



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread Dimitri Timofeev
Hi!Sorry if it is a bit off-topic in this thread.How can I input EOF symbol in WinHugs? Ctrl-Z and Ctrl-D don't work for me,so I can't use getContents function. Maybe there is a piece of documentationthat I should read?
Thanks!-- Dimitri
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread Neil Mitchell

H


How can I input EOF symbol in WinHugs?


No possible way. If you could type the NUL character that might
possibly work, but even then 1) you can't, 2) it might not.

Do you have a particular need for typing the end of getContents in
WinHugs? If so, I can open a bug and might be able to fix it for the
next release.

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single Char

2006-10-24 Thread John Meacham
On Tue, Oct 24, 2006 at 06:14:14PM +0200, Hans van Thiel wrote:
 I have a similar question. When I use getChar with Hugs the newline
 (caused by pressing 'Enter')  seems to be carried over into the next
 call of main, where it is treated as a single input character. 
 The workaround is getLine and head, but it would be nice to drop the
 newline right away. I suppose the solution offered here: 

that is the correct behavior, input is never discarded, it is just saved
up until you press enter for the first time. if you type fooenter,
your next four getChars will get 'f' 'o' 'o' and '\n'. it is not haskell
that is treating enter as specially, it is your terminal, getChar just
returns exactly what was passed to it.
 
 hSetBuffering stdin NoBuffering 
 
 will have the desired effect, but is there another way?

this will cause getChar to return right away as soon as they type the
first character. which is probably what you want. of course, if they
press an enter, you will see an enter. but you don't have to wait until
they press one.

John

-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread Dimitri Timofeev
On 10/25/06, Neil Mitchell [EMAIL PROTECTED] wrote:
 How can I input EOF symbol in WinHugs?No possible way. If you could type the NUL character that mightpossibly work, but even then 1) you can't, 2) it might not.Do you have a particular need for typing the end of getContents in
WinHugs? If so, I can open a bug and might be able to fix it for thenext release.Thank you!Surely I can get along without getContents in WinHugs: last time I thought aboutit I just wanted to show getContents function to my students (and using hGetContents
on a file handle seems to be better example). Another function thatcould be useful when teaching IO is 'interact', and it seems that it's alsoimpossible to use it without typing EOF (am I right?).So it would be nice to have a way to type EOF in WinHugs, but surely it's a
feature one can live without.And thank you for WinHugs, it is really useful!-- Dimitri
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread John Meacham
On Wed, Oct 25, 2006 at 01:06:28AM +0400, Dimitri Timofeev wrote:
 Sorry if it is a bit off-topic in this thread.
 How can I input EOF symbol in WinHugs? Ctrl-Z and Ctrl-D don't work for me,
 so I can't use getContents function. Maybe there is a piece of documentation
 that I should read?

does F6 work? it used to back with DOS something or another.

John

-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread Dimitri Timofeev
On 10/25/06, John Meacham [EMAIL PROTECTED] wrote:
does F6 work? it used to back with DOS something or another.It works in console Hugs, as well as Ctrl-Z, but does not work in WinHugs.-- Dimitri
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread Neil Mitchell

Hi


Surely I can get along without getContents in WinHugs: last time I thought
about
it I just wanted to show getContents function to my students (and using
hGetContents
on a file handle seems to be better example). Another function that
could be useful when teaching IO is 'interact', and it seems that it's also
impossible to use it without typing EOF (am I right?).


You can use interact, you just have to hit the stop button to break
out of it. Interestingly Ctrl+C is captured by interact, as is
Ctrl+Z/Ctrl+D, so fixing it up to return -1 in these cases should be
pretty easy - i'll try and get that done tomorrow.


And thank you for WinHugs, it is really useful!


Thank you :) - its nice to know that it is being used.

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single char

2006-10-23 Thread Neil Mitchell

Hi


   getChar doesn't return until I press Enter. I need something that
returns immediately after I press any key.


It's a problem with buffering:

http://haskell.org/hoogle/?q=buffering

suggests:

hSetBuffering stdin NoBuffering

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Read a single char

2006-10-23 Thread Brian Smith
On 10/23/06, Neil Mitchell [EMAIL PROTECTED] wrote:
HigetChar doesn't return until I press Enter. I need something that returns immediately after I press any key.It's a problem with buffering:hSetBuffering stdin NoBuffering
This usually doesn't work on Windows:GHC 6.4.2 and 6.6: requires enterHugs (console) Sept. 2006: requires enter
WinHugs (GUI) Sept. 2006: works as expectedBut it seems to work on Linux:GHC 6.4.1 on Ubuntu 6.06: works as expectedGHC 6.6 on Ubuntu 6.06: works as expectedI am really interested in hearing of a solution that works on all platforms.
 import IO main = do hSetBuffering stdin NoBuffering hGetChar stdinRegards,Brian 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe