Fix some typos in the tutorial

This commit is contained in:
Kamil Shakirov 2020-04-09 13:48:12 +06:00
parent 211fc359ca
commit 0ea595817a
2 changed files with 8 additions and 10 deletions

View File

@ -282,11 +282,13 @@ which reads a number from the console, returning a value of the form
.. code-block:: idris
import Data.Strings
readNumber : IO (Maybe Nat)
readNumber = do
input <- getLine
if all isDigit (unpack input)
then pure (Just (cast input))
then pure (Just (stringToNatOrZ input))
else pure Nothing
If we then use it to write a function to read two numbers, returning
@ -325,9 +327,9 @@ case back as follows:
readNumbers : IO (Maybe (Nat, Nat))
readNumbers
= do Just x_ok <- readNumber
= do Just x_ok <- readNumber
| Nothing => pure Nothing
Just y_ok <- readNumber
Just y_ok <- readNumber
| Nothing => pure Nothing
pure (Just (x_ok, y_ok))

View File

@ -221,12 +221,12 @@ of how this works in practice:
odd : Nat -> Bool
odd Z = False
odd (S k) = even k
test : List Nat
test = [c (S 1), c Z, d (S Z)]
where c : Nat -> Nat
c x = 42 + x
d : Nat -> Nat
d y = c (y + 1 + z y)
where z : Nat -> Nat
@ -753,12 +753,8 @@ For more details of the functions available on ``List`` and
- ``libs/base/Data/List.idr``
- ``libs/base/Data/List.idr``
- ``libs/base/Data/Vect.idr``
- ``libs/base/Data/VectType.idr``
Functions include filtering, appending, reversing, and so on.
Aside: Anonymous functions and operator sections
@ -1052,7 +1048,7 @@ name. For example, a pair type could be defined as follows:
fst : a
snd : b
Using the ``class`` record from earlier, the size of the class can be
Using the ``Class`` record from earlier, the size of the class can be
restricted using a ``Vect`` and the size included in the type by parameterising
the record with the size. For example: