Changes between Version 1 and Version 2 of FAQ
- Timestamp:
- 12/08/05 08:14:20 (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
FAQ
v1 v2 68 68 == When I open a FIFO (named pipe) and try to read from it, I get EOF immediately. == 69 69 70 This is a consequence of the fact that GHC opens the FIFO in non-blocking mode. The behaviour varies from OS to OS: on Linux and Solaris you can wait for a writer by doing an explicit threadWaitRead on the file descriptor (gotten from Posix.handleToFd) before the first read, but this doesn't work on FreeBSD (although rumour has it that recent versions of FreeBSD changed the behaviour to match other OSs). A workaround for all systems is to open the FIFO for writing yourself, before (or at the same time as) opening it for reading.70 This is a consequence of the fact that GHC opens the FIFO in non-blocking mode. The behaviour varies from OS to OS: on Linux and Solaris you can wait for a writer by doing an explicit threadWaitRead on the file descriptor (gotten from {{{Posix.handleToFd}}}) before the first read, but this doesn't work on FreeBSD (although rumour has it that recent versions of FreeBSD changed the behaviour to match other OSs). A workaround for all systems is to open the FIFO for writing yourself, before (or at the same time as) opening it for reading. 71 71 When I foreign import a function that returns char or short, I get garbage back. 72 72 … … 75 75 == My program is failing with head [], or an array bounds error, or some other random error, and I have no idea how to find the bug. Can you help? == 76 76 77 Compile your program with -prof -auto-all (make sure you have the profiling libraries installed), and run it with +RTS -xc -RTS to get a “stack trace” at the point at which the exception was raised. See Section 4.14.4, “RTS options for hackers, debuggers, and over-interested souls”for more details.77 Compile your program with {{{-prof -auto-all}}} (make sure you have the profiling libraries installed), and run it with {{{+RTS -xc -RTS}}} to get a “stack trace” at the point at which the exception was raised. See [http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html#rts-options-debugging Section 4.14.4, “RTS options for hackers, debuggers, and over-interested souls”] for more details. 78 78 79 79 == How do I increase the heap size permanently for a given binary? == 80 80 81 See Section 4.14.5, ““Hooks” to change RTS behaviour”.81 See [http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html#rts-hooks Section 4.14.5, ““Hooks” to change RTS behaviour”]. 82 82 I'm trying to compile my program for parallel execution with the -parallel, and GHC complains with an error like “failed to load interface file for Prelude”. 83 83 84 GHC doesn't ship with support for parallel execution, that support is provided separately by the GPHproject.84 GHC doesn't ship with support for parallel execution, that support is provided separately by the [http://www.macs.hw.ac.uk/~dsg/gph/ GPH] project. 85 85 86 86 == When is it safe to use {{{unsafePerformIO}}}? == … … 97 97 Linking a small program should take no more than a few seconds. Larger programs can take longer, but even linking GHC itself only takes 3-4 seconds on our development machines. 98 98 99 Long link times have been attributed to using Sun's linker on Solaris, as compared to GNU ld which appears to be much faster. So if you're on a Sun box, try switching to GNU ld. This articlefrom the mailing list has more information.99 Long link times have been attributed to using Sun's linker on Solaris, as compared to GNU ld which appears to be much faster. So if you're on a Sun box, try switching to GNU ld. [http://www.haskell.org/pipermail/glasgow-haskell-users/2002-November/004477.html This article] from the mailing list has more information. 100 100 101 == If I explicitly set the buffering on a Handle to "NoBuffering"I'm not able to enter EOF by typing "Ctrl-D". ==101 == If I explicitly set the buffering on a Handle to {{{NoBuffering}}} I'm not able to enter EOF by typing "Ctrl-D". == 102 102 103 103 This is a consequence of Unixy terminal semantics. Unix does line buffering on terminals in the kernel as part of the terminal processing, unless you turn it off. However, the Ctrl-D processing is also part of the terminal processing which gets turned off when the kernel line buffering is disabled. So GHC tries its best to get NoBuffering semantics by turning off the kernel line buffering, but as a result you lose Ctrl-D. C'est la vie. 104 104 105 == If I print out a string using putStr, and then attempt to read some input using hGetLine, I don't see the output from the putStr. ==105 == If I print out a string using {{{putStr}}}, and then attempt to read some input using {{{hGetLine}}}, I don't see the output from the {{{putStr}}}. == 106 106 107 The stdout handle is line-buffered by default, which means that output sent to the handle is only flushed when a newline (/n) is output, the buffer is full, or hFlush is called on the Handle. The right way to make the text appear without sending a newline is to use hFlush:107 The {{{stdout}}} handle is line-buffered by default, which means that output sent to the handle is only flushed when a newline (/n) is output, the buffer is full, or {{{hFlush}}} is called on the {{{Handle}}}. The right way to make the text appear without sending a newline is to use {{{hFlush}}}: 108 108 109 109 {{{ … … 124 124 == Does GHC implement any kind of extensible records? == 125 125 126 No, extensible records are not implemented in GHC. Hugsimplements TRex, one extensible record variant. The problem is that the record design space is large, and seems to lack local optima. And all reasonable variants break backward compatibility. As a result, nothing much happens.126 No, extensible records are not implemented in GHC. [http://www.haskell.org/hugs/ Hugs] implements TRex, one extensible record variant. The problem is that the record design space is large, and seems to lack local optima. And all reasonable variants break backward compatibility. As a result, nothing much happens. 127 127 128 128 == Why do I get errors about missing include files when compiling with -O or -prof? == 129 129 130 Certain options, such as -O, turn on via-C compilation, instead of using the native code generator. Include files named by -#include options or in foreign import declarations are only used in via-C compilation mode. See Section 8.2.2.1, “Finding Header files”for more details.130 Certain options, such as -O, turn on via-C compilation, instead of using the native code generator. Include files named by -#include options or in foreign import declarations are only used in via-C compilation mode. See [http://www.haskell.org/ghc/docs/latest/html/users_guide/sec-ffi-ghc.html#finding-header-files Section 8.2.2.1, “Finding Header files”] for more details. 131 131 132 132 == How do I compile my program for profiling without overwriting the object files and hi files I've already built? == … … 138 138 }}} 139 139 140 See Section 4.6.4, “Redirecting the compilation output(s)” for more details on the -osuf and -hisufoptions.140 See [http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation.html#options-output Section 4.6.4, “Redirecting the compilation output(s)”] for more details on the {{{-osuf}}} and {{{-hisuf}}} options. 141 141 142 142 == I can't use readline under GHCi on Windows ==
