X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fghci.xml;h=bde1648d1d1090c1615c125ca7a0e5f8234341e3;hb=e6b66d7de77488cbd1852a86cfe135a07e80616f;hp=059b52c629f532f522d16f85fadd2fbc3e497208;hpb=05db902f49dab5d7aabf67747997c9064d3b92e1;p=ghc-hetmet.git diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index 059b52c..bde1648 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -219,19 +219,17 @@ Ok, modules loaded: Main. Prelude> :! ghc -c D.hs Prelude> :load A -Skipping D ( D.hs, D.o ) -Compiling C ( C.hs, interpreted ) Compiling B ( B.hs, interpreted ) +Compiling C ( C.hs, interpreted ) Compiling A ( A.hs, interpreted ) Ok, modules loaded: A, B, C, D. *Main> - In the messages from the compiler, we see that it skipped D, - and used the object file D.o. The message - Skipping module - indicates that compilation for module - isn't necessary, because the source and everything it depends on + In the messages from the compiler, we see that there is no line + for D. This is because + it isn't necessary to compile D, + because the source and everything it depends on is unchanged since the last compilation. At any time you can use the command @@ -247,7 +245,7 @@ B ( B.hs, interpreted ) A ( A.hs, interpreted ) *Main> - If we now modify the source of D (or pretend to: using Unix + If we now modify the source of D (or pretend to: using the Unix command touch on the source file is handy for this), the compiler will no longer be able to use the object file, because it might be out of date: @@ -256,9 +254,6 @@ A ( A.hs, interpreted ) *Main> :! touch D.hs *Main> :reload Compiling D ( D.hs, interpreted ) -Skipping C ( C.hs, interpreted ) -Skipping B ( B.hs, interpreted ) -Skipping A ( A.hs, interpreted ) Ok, modules loaded: A, B, C, D. *Main> @@ -274,8 +269,8 @@ Ok, modules loaded: A, B, C, D. *Main> :! ghc -c C.hs *Main> :load A Compiling D ( D.hs, interpreted ) -Compiling C ( C.hs, interpreted ) Compiling B ( B.hs, interpreted ) +Compiling C ( C.hs, interpreted ) Compiling A ( A.hs, interpreted ) Ok, modules loaded: A, B, C, D. @@ -298,8 +293,6 @@ Ok, modules loaded: A, B, C, D. *Main> :load A -Skipping D ( D.hs, D.o ) -Skipping C ( C.hs, C.o ) Compiling B ( B.hs, interpreted ) Compiling A ( A.hs, interpreted ) Ok, modules loaded: A, B, C, D. @@ -310,7 +303,7 @@ Ok, modules loaded: A, B, C, D. when working on a large program is to occasionally run 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 + interpreter. As you modify code, the changed modules will be interpreted, but the rest of the project will remain compiled. @@ -571,7 +564,7 @@ Prelude IO> 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 . + then GHCi will expand it to “Just ”. @@ -722,7 +715,7 @@ it <- e At the GHCi prompt, or with GHC if the - -fextended-default-rules flag is given, + -XExtendedDefaultRules flag is given, the following additional differences apply: @@ -771,8 +764,8 @@ def = toEnum 0 instance that returns IO a. However, it is only able to return undefined - (the reason for the instance having this type is to not require - extensions to the class system), so if the type defaults to + (the reason for the instance having this type is so that printf + doesn't require extensions to the class system), so if the type defaults to Integer then ghci gives an error when running a printf. @@ -795,7 +788,7 @@ def = toEnum 0 The debugger provides the following: - The abilty to set a breakpoint on a + The ability to set a breakpoint on a function definition or expression in the program. When the function is called, or the expression evaluated, GHCi suspends execution and returns to the prompt, where you can inspect the @@ -1024,7 +1017,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 Breakpoints can be set in various ways. Perhaps the easiest way to @@ -1087,7 +1080,7 @@ right :: [a] Listing and deleting breakpoints The list of breakpoints currently enabled can be displayed using - :show breaks: + :show breaks: *Main> :show breaks [0] Main qsort.hs:1:11-12 @@ -1495,7 +1488,7 @@ Just 20 Implicit parameters (see ) are only available - at the scope of a breakpoint if there is a explicit type signature. + at the scope of a breakpoint if there is an explicit type signature. @@ -1523,9 +1516,7 @@ $ ghci Main.hs Most of the command-line options accepted by GHC (see ) also make sense in interactive mode. The ones - that don't make sense are mostly obvious; for example, GHCi - doesn't generate interface files, so options related to interface - file generation won't have any effect. + that don't make sense are mostly obvious. Packages @@ -1541,12 +1532,7 @@ $ ghci Main.hs $ ghci -package readline - ___ ___ _ - / _ \ /\ /\/ __(_) - / /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98. -/ /_\\/ __ / /___| | http://www.haskell.org/ghc/ -\____/\/ /_/\____/|_| Type :? for help. - +GHCi, version 6.8.1: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Loading package readline-1.0 ... linking ... done. Prelude> @@ -1718,16 +1704,6 @@ $ ghci -lm - :continue - :continue - - Continue the current evaluation, when stopped at a - breakpoint. - - - - - :cmd expr :cmd @@ -1742,6 +1718,16 @@ $ ghci -lm + :continue + :continue + + Continue the current evaluation, when stopped at a + breakpoint. + + + + + :ctags filename :etags filename :etags @@ -1751,7 +1737,8 @@ $ ghci -lm Generates a “tags” file for Vi-style editors - (:ctags) or Emacs-style editors (etags). If + (:ctags) or + Emacs-style editors (:etags). If no filename is specified, the defaulit tags or TAGS is used, respectively. Tags for all the functions, constructors and @@ -1859,6 +1846,15 @@ Prelude> :. cmds.ghci + :etags + + + See :ctags. + + + + + :force identifier ... :force @@ -1927,6 +1923,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. @@ -1995,7 +1997,7 @@ Prelude> :. cmds.ghci 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. + arguments directly. @@ -2040,7 +2042,7 @@ Prelude> :main foo bar Prints a value without forcing its evaluation. :print may be used on values whose types are - unkonwn or partially known, which might be the case for local + unknown or partially known, which might be the case for local variables with polymorphic types at a breakpoint. While inspecting the runtime value, :print attempts to reconstruct the type of the value, and will elaborate the type in @@ -2060,7 +2062,7 @@ Prelude> :main foo bar :quit - Quits GHCi. You can also quit by typing a control-D + Quits GHCi. You can also quit by typing control-D at the prompt. @@ -2205,7 +2207,7 @@ Prelude> :main foo bar :show modules - Show the list of modules currently load. + Show the list of modules currently loaded. @@ -2316,7 +2318,7 @@ Prelude> :main foo bar The :set command sets two types of options: GHCi options, which begin with - ‘+” and “command-line” + ‘+’, and “command-line” options, which begin with ‘-’. NOTE: at the moment, the :set command @@ -2428,9 +2430,10 @@ Prelude> :set -fno-glasgow-exts startupfiles, GHCi - When it starts, GHCi always reads and executes commands from - $HOME/.ghci, followed by - ./.ghci. + When it starts, unless the -ignore-dot-ghci + flag is given, GHCi reads and executes commands from + ./.ghci, followed by + $HOME/.ghci. The .ghci in your home directory is most useful for turning on favourite options (eg. :set @@ -2439,7 +2442,7 @@ Prelude> :set -fno-glasgow-exts project is a useful way to set certain project-wide options so you don't have to type them everytime you start GHCi: eg. if your project uses GHC extensions and CPP, and has source files in three - subdirectories A B and C, you might put the following lines in + subdirectories A, B and C, you might put the following lines in .ghci: @@ -2587,7 +2590,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. +