X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fghci.xml;h=3ba2012eee34a086f7cd4ac1cb7fa227c7f6c1a5;hb=5263c9ab4408e3b62dbf7505ab40a81946d4e49b;hp=6014b312a3ac9ab22638a7fb5a20cfa76f72929a;hpb=08be85b35bade4827fb957deb05b244e0435155f;p=ghc-hetmet.git diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index 6014b31..3ba2012 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -393,9 +393,9 @@ Prelude> Show - The automatic printing of binding results can be supressed with + The automatic printing of binding results can be suppressed with (this does not - supress printing the result of non-binding statements). + suppress 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 @@ -929,6 +929,7 @@ right :: [a] left: +[qsort.hs:2:15-46] *Main> :set -fprint-evld-with-show [qsort.hs:2:15-46] *Main> :print left left = (_t1::[a]) @@ -948,6 +949,13 @@ left = (_t1::[a]) underscore, in this case _t1. + The flag -fprint-evld-with-show instructs + :print to reuse + available Show instances when possible. This happens + only when the contents of the variable being inspected + are completely evaluated. + + If we aren't concerned about preserving the evaluatedness of a variable, we can use :force instead of :print. The :force command @@ -1017,6 +1025,7 @@ right :: [a] The execution continued at the point it previously stopped, and has now stopped at the breakpoint for a second time. + Setting breakpoints @@ -1106,10 +1115,14 @@ right :: [a] Single-stepping is a great way to visualise the execution of your program, and it is also a useful tool for identifying the source of a - bug. The concept is simple: single-stepping enables all the - breakpoints in the program and executes until the next breakpoint is - reached, at which point you can single-step again, or continue - normally. For example: + bug. GHCi offers two variants of stepping. Use + :step to enable all the + breakpoints in the program, and execute until the next breakpoint is + reached. Use :steplocal to limit the set + of enabled breakpoints to those in the current top level function. + Similarly, use :stepmodule to single step only on + breakpoints contained in the current module. + For example: *Main> :step main @@ -1118,10 +1131,11 @@ _result :: IO () The command :step - expr begins the evaluation of + expr begins the evaluation of expr in single-stepping mode. If - expr is ommitted, then it single-steps from - the current breakpoint. + expr is omitted, then it single-steps from + the current breakpoint. :stepover + works similarly. The :list command is particularly useful when single-stepping, to see where you currently are: @@ -1330,9 +1344,13 @@ a :: a :trace and :history to establish the context. However, head is in a library and we can't set a breakpoint on it directly. For this reason, GHCi - provides the flag -fbreak-on-exception which causes - the evaluator to stop when an exception is thrown, just as it does when - a breakpoint is hit. This is only really useful in conjunction with + provides the flags -fbreak-on-exception which causes + the evaluator to stop when an exception is thrown, and + -fbreak-on-error, which works similarly but stops only on + uncaught exceptions. When stopping at an exception, GHCi will act + just as it does when a breakpoint is hit, with the deviation that it + will not show you any source code location. Due to this, these + commands are only really useful in conjunction with :trace, in order to log the steps leading up to the exception. For example: @@ -1662,17 +1680,20 @@ $ ghci -lm - :browse *module ... + :browse *module ... :browse Displays the identifiers defined by the module module, which must be either - loaded into GHCi or be a member of a package. If the - * symbol is placed before the module - name, then all the identifiers defined - in module are shown; otherwise - the list is limited to the exports of + loaded into GHCi or be a member of a package. If + module is omitted, the most + recently-loaded module is used. + + If the * symbol is placed before + the module name, then all the + identifiers in scope in module are + shown; otherwise the list is limited to the exports of module. The *-form is only available for modules which are interpreted; for compiled modules (including @@ -1739,7 +1760,7 @@ $ ghci -lm Generates a “tags” file for Vi-style editors (:ctags) or Emacs-style editors (:etags). If - no filename is specified, the defaulit tags or + no filename is specified, the default tags or TAGS is used, respectively. Tags for all the functions, constructors and types in the currently loaded modules are created. All modules must @@ -1923,6 +1944,12 @@ Prelude> :. cmds.ghci 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. + For types and classes, GHCi also summarises instances that + mention them. To avoid showing irrelevant information, an instance + is shown only if (a) its head mentions name, + and (b) all the other things mentioned in the instance + are in scope (either qualified or otherwise) as a result of + a :load or :module commands. @@ -2584,7 +2611,19 @@ Prelude> :set -fno-glasgow-exts I can't use Control-C to interrupt computations in GHCi on Windows. - See + See . + + + + + The default buffering mode is different in GHCi to GHC. + + + In GHC, the stdout handle is line-buffered by default. + However, in GHCi we turn off the buffering on stdout, + because this is normally what you want in an interpreter: + output appears as it is generated. +