|
RE: reading in ghci-6-4-branch: msg#00057lang.haskell.glasgow.bugs
On 22 June 2005 08:04, Serge D. Mechveliani wrote: > Who knows, please, how to work with the program of > > > main = interact (\ s -> shows (read s :: Bool) "\n") > > > in the interpreter ghci ? > > This is on ghc-cvs-6-4-branch-June-15-2005 > under Debian Linux, i386-uknown. > > When compiled, it works: > ghc --make ReadBug > > ./a.out > > True press Enter > > press Control-d > > True > > And it does not work under ghci: > > -------------------------------------------------- >> ghci ReadBug.hs > > ___ ___ _ > / _ \ /\ /\/ __(_) > / /_\// /_/ / / | | GHC Interactive, version 6.4.1, for > Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ > \____/\/ /_/\____/|_| Type :? for help. > > Loading package base-1.0 ... linking ... done. > Compiling Main ( ReadBug.hs, interpreted ) > Ok, modules loaded: Main. > (0.08 secs, 3210432 bytes) > *Main> main > True > ^D*** Exception: Prelude.read: no parse > *Main> > ------------------------------------------------ > > > Is this a GHC bug? Not really. When stdin is in non-blocking mode, as it is by default inside GHCi, then ^D loses its special meaning (this is standard Unix terminal behaviour, we turn off "cooked" mode on the terminal). In your example, the ^D character is being sent to the program, and causing a parse error. You can re-enable ^D by putting stdin in LineBuffering mode, but then ^D will also close GHCi, because GHCi is using the same stdin (it might be possible to work around this, because ^D doesn't really "close" stdin, but GHCi definitely got confused when I tried it). Cheers, Simon
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [ ghc-Bugs-1225368 ] Typechecker loop and stack overflow in 6.4, SourceForge.net |
|---|---|
| Next by Date: | [ ghc-Bugs-1223893 ] Double constant leads to malformed .hc, SourceForge.net |
| Previous by Thread: | Re: reading in ghci-6-4-branch, Bernard Pope |
| Next by Thread: | [ ghc-Bugs-1225368 ] Typechecker loop and stack overflow in 6.4, SourceForge.net |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |