summaryrefslogtreecommitdiff
path: root/docs/users_guide/ghci.rst
diff options
context:
space:
mode:
authorRoman Shatsov <roshats@gmail.com>2015-11-21 15:58:34 +0100
committerBen Gamari <ben@smart-cactus.org>2015-11-21 11:15:09 -0500
commitb98ff3ccb14e36145404f075349c8689762a2913 (patch)
tree06eb4336d7637d5ecaa0bc68ae047eb524a3b03d /docs/users_guide/ghci.rst
parent2325bd4e0fad0e5872556c5a78d1a6a1873e7201 (diff)
downloadhaskell-b98ff3ccb14e36145404f075349c8689762a2913.tar.gz
Function definition in GHCi
This patch allows define and re-define functions in ghci. `let` is not required anymore (but can be used). Idea: If ghci input string can be parsed as statement then run it as statement else run it as declaration. Reviewers: mpickering, bgamari, austin Reviewed By: mpickering, bgamari, austin Subscribers: hvr, mpickering, dterei, thomie Differential Revision: https://phabricator.haskell.org/D1299 GHC Trac Issues: #7253
Diffstat (limited to 'docs/users_guide/ghci.rst')
-rw-r--r--docs/users_guide/ghci.rst23
1 files changed, 11 insertions, 12 deletions
diff --git a/docs/users_guide/ghci.rst b/docs/users_guide/ghci.rst
index 0cb3a713e2..beb946ee2d 100644
--- a/docs/users_guide/ghci.rst
+++ b/docs/users_guide/ghci.rst
@@ -462,12 +462,11 @@ with the ``let`` form, the expression isn't evaluated immediately:
Note that ``let`` bindings do not automatically print the value bound,
unlike monadic bindings.
-You can also use ``let``-statements to define functions at the
-prompt:
+You can also define functions at the prompt:
::
- Prelude> let add a b = a + b
+ Prelude> add a b = a + b
Prelude> add 1 2
3
Prelude>
@@ -479,7 +478,7 @@ instead of layout:
::
- Prelude> let f op n [] = n ; f op n (h:t) = h `op` f op n t
+ Prelude> f op n [] = n ; f op n (h:t) = h `op` f op n t
Prelude> f (+) 0 [1..3]
6
Prelude>
@@ -491,8 +490,8 @@ own):
::
Prelude> :{
- Prelude| let g op n [] = n
- Prelude| g op n (h:t) = h `op` g op n t
+ Prelude| g op n [] = n
+ Prelude| g op n (h:t) = h `op` g op n t
Prelude| :}
Prelude> g (*) 1 [1..3]
6
@@ -877,7 +876,7 @@ arguments, e.g.:
::
- Prelude> let main = System.Environment.getArgs >>= print
+ Prelude> main = System.Environment.getArgs >>= print
Prelude> :main foo bar
["foo","bar"]
@@ -897,8 +896,8 @@ flag or the ``:run`` command:
::
- Prelude> let foo = putStrLn "foo" >> System.Environment.getArgs >>= print
- Prelude> let bar = putStrLn "bar" >> System.Environment.getArgs >>= print
+ Prelude> foo = putStrLn "foo" >> System.Environment.getArgs >>= print
+ Prelude> bar = putStrLn "bar" >> System.Environment.getArgs >>= print
Prelude> :set -main-is foo
Prelude> :main foo "bar baz"
foo
@@ -2318,7 +2317,7 @@ commonly used commands.
::
- Prelude> let main = System.Environment.getArgs >>= print
+ Prelude> main = System.Environment.getArgs >>= print
Prelude> :main foo bar
["foo","bar"]
@@ -2338,8 +2337,8 @@ commonly used commands.
::
- Prelude> let foo = putStrLn "foo" >> System.Environment.getArgs >>= print
- Prelude> let bar = putStrLn "bar" >> System.Environment.getArgs >>= print
+ Prelude> foo = putStrLn "foo" >> System.Environment.getArgs >>= print
+ Prelude> bar = putStrLn "bar" >> System.Environment.getArgs >>= print
Prelude> :set -main-is foo
Prelude> :main foo "bar baz"
foo