diff options
author | Takenobu Tani <takenobu.hs@gmail.com> | 2017-08-17 10:28:01 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-08-17 16:42:55 -0400 |
commit | 3385669683b8bc150c6df3cb43320dfc6f80fcd9 (patch) | |
tree | ed14e3808a9c5aeece7a145ace4e707398864765 /docs | |
parent | 0e1b6f85c69834e907ebcb9fcb5c94e6a2fb3287 (diff) | |
download | haskell-3385669683b8bc150c6df3cb43320dfc6f80fcd9.tar.gz |
user-guide: fix examples of ghci commands
Fix examples of ghci commands:
* correct typos
* add top-level binding without let statement
* modify Time.getClockTime to Data.Time.getZonedTime
* modify Directory.setCurrentDirectory
* modify ghc version number
Test Plan: build
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3852
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/ghci.rst | 29 | ||||
-rw-r--r-- | docs/users_guide/using.rst | 4 |
2 files changed, 21 insertions, 12 deletions
diff --git a/docs/users_guide/ghci.rst b/docs/users_guide/ghci.rst index fe481ae799..52fbf6e323 100644 --- a/docs/users_guide/ghci.rst +++ b/docs/users_guide/ghci.rst @@ -37,7 +37,7 @@ command ``ghci``: .. code-block:: none $ ghci - GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help + GHCi, version 8.y.z: http://www.haskell.org/ghc/ :? for help Prelude> There may be a short pause while GHCi loads the prelude and standard @@ -69,6 +69,15 @@ GHCi, since the expression can also be interpreted in the ``IO`` monad, a ``let`` binding with no accompanying ``in`` statement can be signalled by an empty line, as in the above example. +Since GHC 8.0.1, you can bind values and functions to names without ``let`` statement: + +.. code-block:: none + + Prelude> x = 42 + Prelude> x + 42 + Prelude> + .. _loading-source-files: Loading source files @@ -987,10 +996,10 @@ of type ``a``. eg.: .. code-block:: none - Prelude> Time.getClockTime - Wed Mar 14 12:23:13 GMT 2001 + Prelude> Data.Time.getZonedTime + 2017-04-10 12:34:56.93213581 UTC Prelude> print it - Wed Mar 14 12:23:13 GMT 2001 + 2017-04-10 12:34:56.93213581 UTC The corresponding translation for an IO-typed ``e`` is @@ -1162,7 +1171,7 @@ printed value. Running GHCi with the command: .. code-block:: none - ghci -interactive-print=SpecPrinter.sprinter SpecPrinter + ghci -interactive-print=SpecPrinter.sprint SpecPrinter will start an interactive session where values with be printed using ``sprint``: @@ -1971,7 +1980,7 @@ by using the :ghc-flag:`-package ⟨pkg⟩` flag: .. code-block:: none $ ghci -package readline - GHCi, version 6.8.1: http://www.haskell.org/ghc/ :? for help + GHCi, version 8.y.z: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Loading package readline-1.0 ... linking ... done. Prelude> @@ -2238,17 +2247,17 @@ commonly used commands. .. code-block:: none - Prelude> let date _ = Time.getClockTime >>= print >> return "" + Prelude> let date _ = Data.Time.getZonedTime >>= print >> return "" Prelude> :def date date Prelude> :date - Fri Mar 23 15:16:40 GMT 2001 + 2017-04-10 12:34:56.93213581 UTC Here's an example of a command that takes an argument. It's a re-implementation of :ghci-cmd:`:cd`: .. code-block:: none - Prelude> let mycd d = Directory.setCurrentDirectory d >> return "" + Prelude> let mycd d = System.Directory.setCurrentDirectory d >> return "" Prelude> :def mycd mycd Prelude> :mycd .. @@ -2745,7 +2754,7 @@ commonly used commands. *X> :type +v length length :: forall (t :: * -> *). Foldable t => forall a. t a -> Int -.. ghci-cmd:: :type +d ⟨expression⟩ +.. ghci-cmd:: :type +d; ⟨expression⟩ Infers and prints the type of ⟨expression⟩, defaulting type variables if possible. In this mode, if the inferred type is constrained by diff --git a/docs/users_guide/using.rst b/docs/users_guide/using.rst index dff9603b66..6dde0ee423 100644 --- a/docs/users_guide/using.rst +++ b/docs/users_guide/using.rst @@ -636,8 +636,8 @@ messages and in GHCi: .. code-block:: none ghci> :set -fprint-unicode-syntax - ghci> :t (>>) - (>>) :: ∀ (m :: * → *) a b. Monad m ⇒ m a → m b → m b + ghci> :t +v (>>) + (>>) ∷ Monad m ⇒ ∀ a b. m a → m b → m b .. _pretty-printing-types: |