X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fusing.xml;h=2828c6ae5bdda9958b49c282764697de7dd7caeb;hb=1bf40a4b38180b8b1c1bdaf4919bc327d5b27abe;hp=95f5b9402a776526db2931bdd6a3d8424a2b9e84;hpb=7828bf3ea2ea34e7a3a8662f5f621ef706ffee5c;p=ghc-hetmet.git
diff --git a/docs/users_guide/using.xml b/docs/users_guide/using.xml
index 95f5b94..2828c6a 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-linecommand-lineargumentsargumentscommand-line
-
+
An invocation of GHC takes the following form:
@@ -112,7 +112,7 @@ ghc [argument...]
Command line options in source files
-
+
source-file optionsSometimes 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 optionsstaticoptions
@@ -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,23 @@ module X where
compiler.
-
+
+
+ .ll
+
+ An llvm-intermediate-language source file, usually
+ produced by the compiler.
+
+
+
+
+ .bc
+
+ An llvm-intermediate-language bitcode file, usually
+ produced by the compiler.
+
+
+
.s
@@ -320,7 +336,7 @@ module X where
more detail in .
-
+
ghc ––make
@@ -359,7 +375,7 @@ module X where
more details.
-
+
@@ -442,9 +458,10 @@ module X where
+ ghc --supported-extensionsghc --supported-languages
-
+ Print the supported language extensions.
@@ -514,7 +531,7 @@ module X where
Using ghcseparate 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
@@ -566,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
@@ -579,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
@@ -592,7 +609,7 @@ ghc Main.hs
to add directories to the search path (see ).
-
+
Expression evaluation mode
@@ -616,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:
@@ -629,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
@@ -660,7 +677,7 @@ olleh
-.hs
-
+
C pre-processor (opt.) .hs (with
@@ -668,28 +685,28 @@ olleh
.hspp
-
+
Haskell compiler.hs, .hc, .s
-
+
C compiler (opt.).hc or .c.s
-
+
assembler.s.o
-
+
linkerother
@@ -699,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.
@@ -724,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.
@@ -766,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.
-
-
-
-
-
@@ -795,7 +800,7 @@ ghc -c Foo.hs
verify.
-
+
n
@@ -807,7 +812,7 @@ ghc -c Foo.hs
argument. Specifying on its own is
equivalent to , and the other levels
have the following meanings:
-
+
@@ -857,7 +862,7 @@ ghc -c Foo.hs
-
+
@@ -972,11 +977,12 @@ ghc -c Foo.hs
suspicious code. The warnings that are
not enabled by
are
- ,
,
+ ,
,
,
- , and
+ ,
+ ,
.
@@ -994,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.
@@ -1122,7 +1128,7 @@ foreign import "&f" f :: FunPtr t
is bound in a way that looks lazy, e.g.
where (I# x) = .... Use
where !(I# x) = ... instead. This will be an
- error, rather than a warning, in GHC 6.14.
+ error, rather than a warning, in GHC 7.2.
@@ -1159,6 +1165,21 @@ foreign import "&f" f :: FunPtr t
+ :
+
+
+ Causes the compiler to emit a warning when a Prelude numeric
+ conversion converts a type T to the same type T; such calls
+ are probably no-ops and can be omitted. The functions checked for
+ are: toInteger,
+ toRational,
+ fromIntegral,
+ and realToFrac.
+
+
+
+
+ :
@@ -1184,26 +1205,41 @@ foreign import "&f" f :: FunPtr t
- :
+ ,
+ :
+
+ incomplete patterns, warningpatterns, incomplete
- Similarly for incomplete patterns, the function
+ 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
-
- 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
+
+
@@ -1252,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.
+
+
+
+
+ :
@@ -1270,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.
@@ -1292,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
@@ -1317,8 +1400,8 @@ f foo = foo { x = 6 }
orphan instances, warningorphan 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
@@ -1327,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.
@@ -1359,28 +1442,6 @@ f "2" = 2
- :
-
-
-
- Causes the compiler to warn about lambda-bound
- patterns that can fail, eg. \(x:xs)->....
- Normally, these aren't treated as incomplete patterns by
- .
- “Lambda-bound patterns” includes all places where there is a single pattern,
- including list comprehensions and do-notation. In these cases, a pattern-match
- failure is quite legitimate, and triggers filtering (list comprehensions) or
- the monad fail operation (monads). For example:
-
- f :: [Maybe a] -> [a]
- f xs = [y | Just y <- xs]
-
- Switching on will elicit warnings about
- these probably-innocent cases, which is why the flag is off by default.
-
-
-
- :
@@ -1404,6 +1465,7 @@ f "2" = 2
e.g., the ‘default default’ for Haskell 1.4 caused the
otherwise unconstrained value 1 to be
given the type Int, whereas Haskell 98
+ and later
defaults it to Integer. This may lead to
differences in performance and behaviour, hence the
usefulness of being non-silent about this.
@@ -1436,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
@@ -1485,7 +1547,7 @@ f "2" = 2
unused do binding, warningdo binding, unused
- Report expressions occuring in do and mdo blocks
+ Report expressions occurring in do and mdo blocks
that appear to silently throw information away.
For instance do { mapM popInt xs ; return 10 } would report
the first statement in the do block as suspicious,
@@ -1510,7 +1572,7 @@ f "2" = 2
apparently erroneous do binding, warningdo binding, apparently erroneous
- Report expressions occuring in do and mdo blocks
+ Report expressions occurring in do and mdo blocks
that appear to lack a binding.
For instance do { return (popInt 10) ; return 10 } would report
the first statement in the do block as suspicious,
@@ -1636,37 +1698,12 @@ f "2" = 2
.
-
-
-
- :
- -Ofile <file> option
- optimising, customised
-
-
- (NOTE: not supported since GHC 4.x. Please ask if
- you're interested in this.)
-
- For those who need absolute
- control over exactly what options are
- used (e.g., compiler writers, sometimes :-), a list of
- options can be put in a file and then slurped in with
- .
-
- In that file, comments are of the
- #-to-end-of-line variety; blank
- lines and most whitespace is ignored.
-
- Please ask if you are baffled and would like an
- example of !
-
- 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.)
@@ -1821,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.
@@ -1885,10 +1922,10 @@ 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
+ “code bloat” of expanding that unfolding
at a call site. A bigger function would be assigned a
bigger cost.)
@@ -1922,10 +1959,10 @@ f "2" = 2
-
+
-
- &phases;
+
+ &phases;
&shared_libs;
@@ -1985,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
@@ -1993,7 +2030,7 @@ f "2" = 2
linked with the option (see ). Additionally, the following
compiler options affect parallelism:
-
+
@@ -2050,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
@@ -2110,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,7 +2191,7 @@ f "2" = 2
:
- (x86 only, added in GHC 6.14.1) Use the SSE2 registers and
+ (x86 only, added in GHC 7.0.1) Use the SSE2 registers and
instruction set to implement floating point operations
when using the native code generator. This gives a
substantial performance improvement for floating point,
@@ -2187,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.
-
-
@@ -2219,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
@@ -2259,7 +2255,6 @@ statements or clauses.