X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fghci.xml;h=76d4972edf316e8fb1a8672346bea381a9b6e476;hb=939ce676b146713bbe0de42dec6c30da2c948049;hp=e79fb46c3f3df2c7164201b2a0edb22aea3bd6d7;hpb=72eb3683f8a5a50588df662f9ba77d1d01f05cef;p=ghc-hetmet.git diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index e79fb46..76d4972 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -402,7 +402,7 @@ hello - + Using <literal>do-</literal>notation at the prompt do-notationin GHCi statementsin GHCi @@ -444,7 +444,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 +610,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 @@ -873,10 +885,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. @@ -1003,6 +1013,21 @@ 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. + + + + + :help :help @@ -1074,6 +1099,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