X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fusing.xml;h=96d3c73bbf3b690838d906d1fe3271232ee697ca;hb=b896489a1c548680f75e9001fb4bd0b30dbfedb3;hp=a4c673cbe4965318e450b9ce4a5f82ba581312c5;hpb=56aaa78a63ab27c40a6834ed28ff3f32d1ede214;p=ghc-hetmet.git diff --git a/docs/users_guide/using.xml b/docs/users_guide/using.xml index a4c673c..96d3c73 100644 --- a/docs/users_guide/using.xml +++ b/docs/users_guide/using.xml @@ -78,7 +78,7 @@ Hello World! Options overview - + GHC's behaviour is controlled by options, which for historical reasons are also sometimes referred to as command-line flags or arguments. @@ -86,11 +86,11 @@ Hello World! Command-line arguments - + structure, command-line command-linearguments argumentscommand-line - + An invocation of GHC takes the following form: @@ -112,7 +112,7 @@ ghc [argument...] Command line options in source files - + source-file options Sometimes it is useful to make the connection between a @@ -130,7 +130,7 @@ ghc [argument...] module X where ... - + OPTIONS_GHC is a file-header pragma (see ). @@ -163,7 +163,7 @@ module X where for more details. - + Static, Dynamic, and Mode options staticoptions @@ -204,14 +204,14 @@ module X where - + The flag reference tables () lists the status of each flag. There are a few flags that are static except that they can also be used with GHCi's :set command; these are listed as “static/:set” in the - table. + table. @@ -266,7 +266,7 @@ module X where compiler. - + .ll @@ -336,7 +336,7 @@ module X where more detail in . - + ghc ––make @@ -375,7 +375,7 @@ module X where more details. - + @@ -531,7 +531,7 @@ module X where Using <command>ghc</command> <option>––make</option> separate compilation - + In this mode, GHC will build a multi-module Haskell program by following dependencies from one or more root modules (usually just Main). For example, if your @@ -583,7 +583,7 @@ ghc Main.hs source. - + Any of the command-line options described in the rest of this chapter can be used with , but note that any options @@ -596,7 +596,7 @@ ghc Main.hs (say, some auxiliary C code), then the object files can be given on the command line and GHC will include them when linking the executable. - + Note that GHC can only follow dependencies if it has the source file available, so if your program includes a module for which there is no source file, even if you have an object and an @@ -609,7 +609,7 @@ ghc Main.hs to add directories to the search path (see ). - + Expression evaluation mode @@ -633,7 +633,7 @@ ghc -e expr ghc -e Main.main Main.hs - + or we can just use this mode to evaluate expressions in the context of the Prelude: @@ -646,22 +646,22 @@ olleh Batch compiler mode - + In batch mode, GHC will compile one or more source files given on the command line. - + The first phase to run is determined by each input-file suffix, and the last phase is determined by a flag. If no relevant flag is present, then go all the way through to linking. This table summarises: - + - + Phase of the compilation system @@ -677,7 +677,7 @@ olleh - .hs - + C pre-processor (opt.) .hs (with @@ -685,28 +685,28 @@ olleh .hspp - + Haskell compiler .hs , .hc, .s - + C compiler (opt.) .hc or .c .s - + assembler .s .o - + linker other @@ -716,17 +716,17 @@ olleh - + - + Thus, a common invocation would be: ghc -c Foo.hs - + to compile the Haskell source file Foo.hs to an object file Foo.o. @@ -741,7 +741,7 @@ ghc -c Foo.hs flag turns it on. See for more details. - + Note: The option -E option runs just the pre-processing passes of the compiler, dumping the result in a file. @@ -783,18 +783,6 @@ ghc -c Foo.hs - - - - - Does a dry-run, i.e. GHC goes through all the motions - of compiling as normal, but does not actually run any - external commands. - - - - - @@ -812,7 +800,7 @@ ghc -c Foo.hs verify. - + n @@ -824,7 +812,7 @@ ghc -c Foo.hs argument. Specifying on its own is equivalent to , and the other levels have the following meanings: - + @@ -874,7 +862,7 @@ ghc -c Foo.hs - + @@ -990,9 +978,11 @@ ghc -c Foo.hs not enabled by are , + , , , - , and + , + , . @@ -1010,7 +1000,7 @@ ghc -c Foo.hs : - Makes any warning into a fatal error. Useful so that you don't + Makes any warning into a fatal error. Useful so that you don't miss warnings when doing batch compilation. @@ -1215,27 +1205,41 @@ foreign import "&f" f :: FunPtr t - : + , + : + + incomplete patterns, warning patterns, incomplete - Similarly for incomplete patterns, the functions - g and h below will fail when applied to + The option warns + about places where + a pattern-match might fail at runtime. + The function + g below will fail when applied to non-empty lists, so the compiler will emit a warning about this when is - enabled. - + enabled. g [] = 2 -h = \[] -> 2 - - This option isn't enabled by default because it can be + This option isn't enabled by default because it can be a bit noisy, and it doesn't always indicate a bug in the program. However, it's generally considered good practice - to cover all the cases in your functions. + to cover all the cases in your functions, and it is switched + on by . + + The flag is + similar, except that it + applies only to lambda-expressions and pattern bindings, constructs + that only allow a single pattern: + +h = \[] -> 2 +Just k = f y + + @@ -1284,6 +1288,39 @@ f foo = foo { x = 6 } + + : + + missing import lists, warning + import lists, missing + + + + This flag warns if you use an unqualified + import declaration + that does not explicitly list the entities brought into scope. For + example + + +module M where + import X( f ) + import Y + import qualified Z + p x = f x x + + + The flag will warn about the import + of Y but not X + If module Y is later changed to export (say) f, + then the reference to f in M will become + ambiguous. No warning is produced for the import of Z + because extending Z's exports would be unlikely to produce + ambiguity in M. + + + + + : @@ -1302,7 +1339,7 @@ f foo = foo { x = 6 } complexFn :: a -> a -> String complexFn x y = ... _simpleFn ... - The idea is that: (a) users of the class will only call complexFn; + The idea is that: (a) users of the class will only call complexFn; never _simpleFn; and (b) instance declarations can define either complexFn or _simpleFn. @@ -1324,11 +1361,25 @@ f foo = foo { x = 6 } + : + + + type signatures, missing + + If you use the + flag GHC will warn + you about any polymorphic local bindings. As part of + the warning GHC also reports the inferred type. The + option is off by default. + + + + : shadowing, warning - + This option causes a warning to be emitted whenever an inner-scope value has the same name as an outer-scope value, i.e. the inner value shadows the outer one. This can catch @@ -1349,8 +1400,8 @@ f foo = foo { x = 6 } orphan instances, warning orphan rules, warning - - This option causes a warning to be emitted whenever the + + This option causes a warning to be emitted whenever the module contains an "orphan" instance declaration or rewrite rule. An instance declaration is an orphan if it appears in a module in which neither the class nor the type being instanced are declared @@ -1359,7 +1410,7 @@ f foo = foo { x = 6 } orphans is called an orphan module. The trouble with orphans is that GHC must pro-actively read the interface files for all orphan modules, just in case their instances or rules - play a role, whether or not the module's interface would otherwise + play a role, whether or not the module's interface would otherwise be of any use. See for details. @@ -1447,8 +1498,8 @@ f "2" = 2 which are unused. For top-level functions, the warning is only given if the binding is not exported. A definition is regarded as "used" if (a) it is exported, or (b) it is - mentioned in the right hand side of another definition that is used, or (c) the - function it defines begins with an underscore. The last case provides a + mentioned in the right hand side of another definition that is used, or (c) the + function it defines begins with an underscore. The last case provides a way to suppress unused-binding warnings selectively. Notice that a variable is reported as unused even if it appears in the right-hand side of another @@ -1652,7 +1703,7 @@ f "2" = 2 We don't use a flag for day-to-day work. We use to get respectable speed; e.g., when we want to measure something. When we want to go for - broke, we tend to use (and we go for + broke, we tend to use (and we go for lots of coffee breaks). The easiest way to see what (etc.) @@ -1807,7 +1858,7 @@ f "2" = 2 State# token as argument is considered to be single-entry, hence it is considered OK to inline things inside it. This can improve performance of IO and ST monad code, but it - runs the risk of reducing sharing. + runs the risk of reducing sharing. @@ -1871,7 +1922,7 @@ f "2" = 2 unfolding, controlling - (Default: 45) Governs the maximum size that GHC will + (Default: 45) Governs the maximum size that GHC will allow a function unfolding to be. (An unfolding has a “size” that reflects the cost in terms of “code bloat” of expanding that unfolding at @@ -1908,10 +1959,10 @@ f "2" = 2 - + - - &phases; + + &phases; &shared_libs; @@ -1971,7 +2022,7 @@ f "2" = 2 use GHC to compile and run parallel programs, in we describe the language features that affect parallelism. - + Compile-time options for SMP parallelism @@ -1979,7 +2030,7 @@ f "2" = 2 linked with the option (see ). Additionally, the following compiler options affect parallelism: - + @@ -2036,7 +2087,7 @@ f "2" = 2 results you find.. For example, on a dual-core machine we would probably use +RTS -N2 -RTS. - + Omitting x, i.e. +RTS -N -RTS, lets the runtime choose the value of x itself @@ -2096,28 +2147,9 @@ f "2" = 2 - - - RTS - option - - Migrate a thread to the current CPU when it is woken - up. Normally when a thread is woken up after being - blocked it will be scheduled on the CPU it was running on - last; this option allows the thread to immediately migrate - to the CPU that unblocked it. - - The rationale for allowing this eager migration is - that it tends to move threads that are communicating with - each other onto the same CPU; however there are - pathalogical situations where it turns out to be a poor - strategy. Depending on the communication pattern in your - program, it may or may not be a good idea. - - - + Hints for using SMP parallelism @@ -2173,27 +2205,6 @@ f "2" = 2 - - : - - (x86 only)-monly-N-regs - option (iX86 only) GHC tries to - “steal” four registers from GCC, for performance - reasons; it almost always works. However, when GCC is - compiling some modules with four stolen registers, it will - crash, probably saying: - - -Foo.hc:533: fixed or forbidden register was spilled. -This may be due to a compiler bug or to impossible asm -statements or clauses. - - - Just give some registers back with - . Try `3' first, then `2'. - If `2' doesn't work, please report the bug to us. - - @@ -2205,15 +2216,14 @@ statements or clauses. intermediate code generation - GHC can dump its optimized intermediate code (said to be in “Core” format) + GHC can dump its optimized intermediate code (said to be in “Core” format) to a file as a side-effect of compilation. Non-GHC back-end tools can read and process Core files; these files have the suffix .hcr. The Core format is described in - An External Representation for the GHC Core Language, + An External Representation for the GHC Core Language, and sample tools - for manipulating Core files (in Haskell) are in the GHC source distribution - directory under utils/ext-core. - Note that the format of .hcr - files is different from the Core output format that GHC generates + for manipulating Core files (in Haskell) are available in the + extcore package on Hackage. Note that the format of .hcr + files is different from the Core output format that GHC generates for debugging purposes (), though the two formats appear somewhat similar. The Core format natively supports notes which you can add to