X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fghci.xml;h=9ec07c355e0ab68f1bae0f660e33a9f5ab23ee73;hb=143f4381d242e4a1c3174e8a0732a1e48f00a1aa;hp=929e9dd37686c87d65e4e4c38809978e9507c994;hpb=0583778f773db20f20c547aa67abe59dfc77b875;p=ghc-hetmet.git diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index 929e9dd..9ec07c3 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -604,6 +604,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 @@ -612,6 +618,34 @@ Prelude IO> qualified declaration for every module in every package, and every module currently loaded into GHCi. + + + The <literal>:main</literal> command + + + 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"] + + + @@ -764,22 +798,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> @@ -852,10 +879,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. @@ -1053,6 +1078,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