X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=docs%2Fusers_guide%2Fghci.xml;h=f9efe34fa87eb5aac6e87028bb681253f5765194;hp=edc3e221418fd70d87270e3b163652c0e2e38c3e;hb=366e8db02ab7a5bb5316699bff397d06e47891b2;hpb=77b441f2bbc4a1cc27d097e6e4fbf09425387a83 diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index edc3e22..f9efe34 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -49,6 +49,8 @@ Prelude> :browse [*]<module> display the names defined by <module> :cd <dir> change directory to <dir> :def <cmd> <expr> define a command :<cmd> + :edit <file> edit file + :edit edit last module :help, :? display this list of commands :info [<name> ...] display information about the given names :load <filename> ... load module(s) and their dependents @@ -60,12 +62,13 @@ Prelude> :set args <arg> ... set the arguments returned by System.getArgs :set prog <progname> set the value returned by System.getProgName :set prompt <prompt> set the prompt used in GHCi + :set editor <cmd> set the command used for :edit :show modules show the currently loaded modules :show bindings show the current bindings made at the prompt :ctags [<file>] create tags file for Vi (default: "tags") - :etags [<file>] create tags file for Emacs (defauilt: "TAGS") + :etags [<file>] create tags file for Emacs (default: "TAGS") :type <expr> show the type of <expr> :kind <type> show the kind of <type> :undef <cmd> undefine user-defined command :<cmd> @@ -402,7 +405,7 @@ hello - + Using <literal>do-</literal>notation at the prompt do-notationin GHCi statementsin GHCi @@ -444,7 +447,13 @@ Prelude> Show - + The automatic printing of binding results can be supressed with + (this does not + supress printing the result of non-binding statements). + . + You might want to do this to prevent the result of binding + statements from being fully evaluated by the act of printing + them, for example. Of course, you can also bind normal non-IO expressions using the let-statement: @@ -604,6 +613,12 @@ Prelude IO> behaves in the same way for expressions typed at the prompt. + + Hint: GHCi will tab-complete names that are in scope; for + example, if you run GHCi and type J<tab> + then GHCi will expand it to Just . + + Qualified names @@ -792,22 +807,15 @@ $ ghci Main.hs package be loaded by using the -package flag: -$ ghci -package data +$ ghci -package readline ___ ___ _ / _ \ /\ /\/ __(_) - / /_\// /_/ / / | | GHC Interactive, version 5.05, for Haskell 98. + / /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. -Loading package haskell98 ... linking ... done. -Loading package lang ... linking ... done. -Loading package concurrent ... linking ... done. -Loading package readline ... linking ... done. -Loading package unix ... linking ... done. -Loading package posix ... linking ... done. -Loading package util ... linking ... done. -Loading package data ... linking ... done. +Loading package readline-1.0 ... linking ... done. Prelude> @@ -880,10 +888,8 @@ $ ghci -lm GHCi commands all begin with ‘:’ and consist of a single command name followed by zero or more parameters. The command name may be - abbreviated, as long as the abbreviation is not ambiguous. All of - the builtin commands, with the exception of - :unset and :undef, may be - abbreviated to a single letter. + abbreviated, with ambiguities being resolved in favour of the more + commonly used commands. @@ -1010,6 +1016,22 @@ Prelude> :. cmds.ghci + :edit file + :edit + + + Opens an editor to edit the file + file, or the most recently loaded + module if file is omitted. The + editor to invoke is taken from the EDITOR + environment variable, or a default editor on your system if + EDITOR is not set. You can change the + editor using :set editor. + + + + + :help :help @@ -1081,6 +1103,38 @@ Prelude> :. cmds.ghci + :main arg1 ... argn + :main + + + + When a program is compiled and executed, it can use the + getArgs function to access the + command-line arguments. + However, we cannot simply pass the arguments to the + main function while we are testing in ghci, + as the main function doesn't take its + directly. + + + + Instead, we can use the :main command. + This runs whatever main is in scope, with + any arguments being treated the same as command-line arguments, + e.g.: + + + +Prelude> let main = System.Environment.getArgs >>= print +Prelude> :main foo bar +["foo","bar"] + + + + + + + :module +|- *mod1 ... *modn :module @@ -1143,6 +1197,16 @@ Prelude> :. cmds.ghci + :set editor cmd + + + Sets the command used by :edit to + cmd. + + + + + :set prog prog :set prog