X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fusing.xml;h=ce7ef7680b2f174ce1cd8f478a42289a1b9481b6;hb=aedb94f5f220b5e442b23ecc445fd38c8d9b6ba0;hp=9df6eb50b694e60ff27cc97be8210fcdf27ef0f6;hpb=e11fa7a5e0025460df3b8562ccbf3ffd1db68d5d;p=ghc-hetmet.git diff --git a/docs/users_guide/using.xml b/docs/users_guide/using.xml index 9df6eb5..ce7ef76 100644 --- a/docs/users_guide/using.xml +++ b/docs/users_guide/using.xml @@ -73,10 +73,9 @@ module X where maintains internally, so you'll be desperately disappointed if you try to glob etc. inside OPTIONS_GHC. - NOTE: the contents of OPTIONS_GHC are prepended to the - command-line options, so you do have the - ability to override OPTIONS_GHC settings via the command - line. + NOTE: the contents of OPTIONS_GHC are appended to the + command-line options, so options given in the source file + override those given on the command-line. It is not recommended to move all the contents of your Makefiles into your source files, but in some circumstances, the @@ -343,6 +342,20 @@ module X where + ghc --show-iface file + + + + + Read the interface in + file and dump it as text to + stdout. For example ghc --show-iface M.hi. + + + + + + ghc --supported-languages @@ -409,20 +422,6 @@ module X where - - - - ghc --print-docdir - - - - - Print the path to GHC's documentation directory. Note that - some distributions do no include the documentation, in which case - this directory may be empty or may not exist. - - - @@ -639,7 +638,7 @@ ghc -c Foo.hs Overriding the default behaviour for a file As described above, the way in which a file is processed by GHC - depends on its suffix. This behaviour can be overriden using the + depends on its suffix. This behaviour can be overridden using the option: @@ -842,10 +841,13 @@ ghc -c Foo.hs of warnings which are generally likely to indicate bugs in your program. These are: , - , + , + , , - , and - . The following flags are + , + , and + . The following + flags are simple ways to select standard “packages” of warnings: @@ -898,6 +900,16 @@ ghc -c Foo.hs + + : + + + Warnings are treated only as warnings, not as errors. This is + the default, but can be useful to negate a + flag. + + + The full set of warning options is described below. To turn @@ -907,21 +919,59 @@ ghc -c Foo.hs - : + : - + + warnings deprecations + Causes a warning to be emitted when a + module, function or type with a WARNING or DEPRECATED pragma + is used. See for more + details on the pragmas. + + This option is on by default. + + + + + : + + + + deprecated-flags Causes a warning to be emitted when a deprecated - function or type is used. Entities can be marked as - deprecated using a pragma, see . + commandline flag is used. This option is on by default. + : + + + + Causes a warning to be emitted for foreign imports of + the following form: + +foreign import "f" f :: FunPtr t + + on the grounds that it probably should be + +foreign import "&f" f :: FunPtr t + + The first form declares that `f` is a (pure) C + function that takes no arguments and returns a pointer to a + C function with type `t`, whereas the second form declares + that `f` itself is a C function with type `t`. The first + declaration is usually a mistake, and one that is hard to + debug because it results in a crash, hence this + warning. + + + + : @@ -973,11 +1023,11 @@ ghc -c Foo.hs imported. This happens unless either the Prelude module is explicitly imported with an import ... Prelude ... line, or this implicit import is disabled (either by - or a + or a LANGUAGE NoImplicitPrelude pragma). Note that no warning is given for syntax that implicitly - refers to the Prelude, even if + refers to the Prelude, even if would change whether it refers to the Prelude. For example, no warning is given when 368 means @@ -1121,7 +1171,7 @@ f foo = foo { x = 6 } This option causes a warning to be emitted whenever the module contains an "orphan" instance declaration or rewrite rule. - An instance declartion is an orphan if it appears in a module in + An instance declaration is an orphan if it appears in a module in which neither the class nor the type being instanced are declared in the same module. A rule is an orphan if it is a rule for a function declared in another module. A module containing any @@ -1129,7 +1179,8 @@ f foo = foo { x = 6 } 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 - be of any use. Other things being equal, avoid orphan modules. + be of any use. See for details. + @@ -1513,15 +1564,31 @@ f "2" = 2 - - + + - Turn off the "state hack" whereby any lambda with a - 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. + Turn on call-pattern specialisation. + + + + + + + + + + Turn on the liberate-case transformation. + + + + + + + + + + Turn on the static argument transformation. @@ -1593,24 +1660,6 @@ f "2" = 2 - - - - - Switches on an experimental "optimisation". - Switching it on makes the compiler a little keener to - inline a function that returns a constructor, if the - context is that of a thunk. - - x = plusInt a b - - If we inlined plusInt we might get an opportunity to use - update-in-place for the thunk 'x'. - - - - - : inlining, controlling @@ -1713,11 +1762,11 @@ f "2" = 2 is also possible to obtain performance improvements with parallelism on programs that do not use concurrency. This section describes how to use GHC to compile and run parallel programs, in we desribe the language features that affect + linkend="lang-parallel" /> we describe the language features that affect parallelism. - Options to enable SMP parallelism + Options for SMP parallelism In order to make use of multiple CPUs, your program must be linked with the option (see RTS option Use x simultaneous threads when running the program. Normally x - should be chosen to match the number of CPU cores on the machine. - There is no means (currently) by which this value may vary after - the program has started. - - For example, on a dual-core machine we would probably use + should be chosen to match the number of CPU cores on the + machineWhether hyperthreading cores should be counted or not is an + open question; please feel free to experiment and let us know what + results you find.. For example, + on a dual-core machine we would probably use +RTS -N2 -RTS. - Whether hyperthreading cores should be counted or not is an - open question; please feel free to experiment and let us know what - results you find. + Setting also has the effect of + setting (the number of OS threads to + use for garbage collection) to the same value. + + There is no means (currently) by which this value + may vary after the program has started. + + The following options affect the way the runtime schedules + threads on CPUs: + + + + + RTS + option + + Disable automatic migration for load balancing. + Normally the runtime will automatically try to schedule + threads across the available CPUs to make use of idle + CPUs; this option disables that behaviour. It is probably + only of use if you are explicitly scheduling threads onto + CPUs with GHC.Conc.forkOnIO. + + + + + 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 - Add the -sstderr RTS option when + Add the -s RTS option when running the program to see timing stats, which will help to tell you whether your program got faster by using more CPUs or not. If the user time is greater than @@ -1815,16 +1905,15 @@ statements or clauses. intermediate code generation GHC can dump its optimized intermediate code (said to be in “Core” format) - to a file as a side-effect of compilation. Core files, which are given the suffix - .hcr, can be read and processed by non-GHC back-end - tools. The Core format is formally described in + 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, - and sample tools (in Haskell) - for manipulating Core files are available in the GHC source distribution - directory /fptools/ghc/utils/ext-core. + 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 (though similar) to the Core output format generated - for debugging purposes (). + 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 your source code using the CORE pragma (see -GHC can also read in External Core files as source; just give the .hcr file on -the command line, instead of the .hs or .lhs Haskell source. -A current infelicity is that you need to give the -fglasgow-exts flag too, because -ordinary Haskell 98, when translated to External Core, uses things like rank-2 types. +Currently (as of version 6.8.2), GHC does not have the ability to read in External Core files as source. If you would like GHC to have this ability, please make your wishes known to the GHC Team. + &debug;