X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fdocs%2Fusers_guide%2Fghci.sgml;h=87f294447500a7c3b19dd5fcdc15028810efcb57;hb=95bf7df47d988d0d5754652e1bb3f0cea3fba19b;hp=5fc8d9fa051e617fd49474b3d9b5596fff403d04;hpb=d5ab53493d661acc52e2d693258076136e634e95;p=ghc-hetmet.git
diff --git a/ghc/docs/users_guide/ghci.sgml b/ghc/docs/users_guide/ghci.sgml
index 5fc8d9f..87f2944 100644
--- a/ghc/docs/users_guide/ghci.sgml
+++ b/ghc/docs/users_guide/ghci.sgml
@@ -12,7 +12,7 @@
you're famililar with HugsHugs, then you'll be right at home with GHCi. However, GHCi
also has support for interactively loading compiled code, as well as
- supporting allexcept the FFI, at the moment
+ supporting allexcept foreign export, at the momentthe language extensions that GHC provides.
FFIGHCi supportForeign Function InterfaceGHCi support
@@ -150,6 +150,31 @@ Main> fac 17
in the same directory and you can't call them all
Main.hs.
+ The search path for finding source files is specified with
+ the option on the GHCi command line, like
+ so:
+ghci -idir1:...:dirn
+
+ or it can be set using the :set command
+ from within GHCi (see )Note that in
+ GHCi, and mode, the
+ option is used to specify the search path for
+ source files, whereas in standard
+ batch-compilation mode the option is used to
+ specify the search path for interface files, see .
+
+ One consequence of the way that GHCi follows dependencies
+ to find modules to load is that every module must have a source
+ file. The only exception to the rule is modules that come from
+ a package, including the Prelude and standard
+ libraries such as IO and
+ Complex. If you attempt to load a module for
+ which GHCi can't find a source file, even if there are object
+ and interface files for the module, you'll get an error
+ message.
+
One final note: if you load a module called Main, it must
contain a main function, just like in
GHC.
@@ -280,7 +305,7 @@ Ok, modules loaded: A, B, C, D.
HINT: since GHCi will only use a compiled object file if it
can sure that the compiled version is up-to-date, a good technique
when working on a large program is to occasionally run
- ghc --make to compile the whole project (say
+ ghc ––make to compile the whole project (say
before you go for lunch :-), then continue working in the
interpreter. As you modify code, the new modules will be
interpreted, but the rest of the project will remain
@@ -515,13 +540,13 @@ Wed Mar 14 12:23:13 GMT 2001
-
+ Invoking GHCiinvokingGHCi
-
+ GHCi is invoked with the command ghci or
- ghc --interactive. One or more modules or
+ ghc ––interactive. One or more modules or
filenames can also be specified on the command line; this
instructs GHCi to load the specified modules or filenames (and all
the modules they depend on), just as if you had said
@@ -703,11 +728,11 @@ Prelude> :mycd ..
Or I could define a simple way to invoke
- “ghc --make Main” in the
+ “ghc ––make Main” in the
current directory:
-Prelude> :def make (\_ -> return ":! ghc --make Main")
+Prelude> :def make (\_ -> return ":! ghc ––make Main")
@@ -724,6 +749,24 @@ Prelude> :def make (\_ -> return ":! ghc --make Main")
+ :infoname
+ ...
+ :info
+
+
+ Displays information about the given name(s). For
+ example, if name is a class, then
+ the class methods and their types will be printed; if
+ name is a type constructor, then
+ its definition will be printed; if
+ name is a function, then its type
+ will be printed. If name has
+ been loaded from a source file, then GHCi will also display
+ the location of its definition in the source.
+
+
+
+ :loadmodule ...:load
@@ -914,7 +957,7 @@ Prelude> :def make (\_ -> return ":! ghc --make Main")
-
+ Setting GHC command-line options in GHCiNormal GHC command-line options may also be set using
@@ -947,7 +990,7 @@ Prelude> :set -fno-glasgow-exts
-
+ The .ghci file.ghcifile
@@ -977,6 +1020,34 @@ Prelude> :set -fno-glasgow-exts
a static one, but in fact it works to set it using
:set like this. The changes won't take effect
until the next :load, though.)
+
+ Two command-line options control whether the
+ .ghci files are read:
+
+
+
+
+
+
+
+ Don't read either ./.ghci or
+ $HOME/.ghci when starting up.
+
+
+
+
+
+
+
+ Read .ghci and
+ $HOME/.ghci. This is normally the
+ default, but the option may
+ be used to override a previous
+ option.
+
+
+
+
@@ -1000,15 +1071,6 @@ Prelude> :set -fno-glasgow-exts
- System.exit causes GHCi to exit!
- System.exitin
- GHCi
-
- Yes, it does.
-
-
-
- System.getArgs returns GHCi's command
line arguments!
@@ -1017,7 +1079,7 @@ Prelude> :set -fno-glasgow-exts
- The interpreter can't load modules with FFI
+ The interpreter can't load modules with foreign export
declarations!Unfortunately not. We haven't implemented it yet.
@@ -1027,15 +1089,6 @@ Prelude> :set -fno-glasgow-exts
- Hugs has a :add command for adding
- modules without throwing away any that are already loaded.
- Why doesn't this work in GHCi?
-
- We haven't implemented it yet. Sorry about that.
-
-
-
- -O doesn't work with GHCi!
@@ -1071,8 +1124,31 @@ Prelude> :set -fno-glasgow-exts
properly with GHC's concurrency model.
-
+
+ After using getContents, I can't use
+ stdin again until I do
+ :load or :reload.
+
+
+ This is the defined behaviour of
+ getContents: it puts the stdin Handle in
+ a state known as semi-closed, wherein
+ any further I/O operations on it are forbidden. Because I/O
+ state is retained between computations, the semi-closed
+ state persists until the next :load or
+ :reload command.
+
+ You can make stdin reset itself
+ after every evaluation by giving GHCi the command
+ :set +r. This works because
+ stdin is just a top-level expression that
+ can be reverted to its unevaluated state in the same way as
+ any other top-level expression (CAF).
+
+
+
+