Changes between Version 1 and Version 2 of FAQ


Ignore:
Timestamp:
Dec 8, 2005 4:14:20 PM (9 years ago)
Author:
simonmar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FAQ

    v1 v2  
    6868== When I open a FIFO (named pipe) and try to read from it, I get EOF immediately. == 
    6969 
    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. 
     70This 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. 
    7171When I foreign import a function that returns char or short, I get garbage back. 
    7272 
     
    7575== 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? == 
    7676 
    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. 
     77Compile 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. 
    7878 
    7979== How do I increase the heap size permanently for a given binary? == 
    8080 
    81 See Section 4.14.5, ““Hooks” to change RTS behaviour”. 
     81See [http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html#rts-hooks Section 4.14.5, ““Hooks” to change RTS behaviour”]. 
    8282I'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”. 
    8383 
    84 GHC doesn't ship with support for parallel execution, that support is provided separately by the GPH project. 
     84GHC 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. 
    8585 
    8686== When is it safe to use {{{unsafePerformIO}}}? == 
     
    9797Linking 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. 
    9898 
    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 article from the mailing list has more information. 
     99Long 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. 
    100100 
    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". == 
    102102 
    103103This 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. 
    104104 
    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}}}. == 
    106106 
    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: 
     107The {{{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}}}: 
    108108 
    109109{{{ 
     
    124124== Does GHC implement any kind of extensible records? == 
    125125 
    126 No, extensible records are not implemented in GHC. 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. 
     126No, 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. 
    127127 
    128128== Why do I get errors about missing include files when compiling with -O or -prof? == 
    129129 
    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. 
     130Certain 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. 
    131131 
    132132== How do I compile my program for profiling without overwriting the object files and hi files I've already built? == 
     
    138138}}} 
    139139 
    140 See Section 4.6.4, “Redirecting the compilation output(s)” for more details on the -osuf and -hisuf options. 
     140See [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. 
    141141 
    142142== I can't use readline under GHCi on Windows ==