@@ -103,28 +103,28 @@ Having defined `Day`, we can write functions that operate on days.
103
103
Type the following:
104
104
105
105
```idris
106
- nextWeekday : Day -> Day
106
+ nextWeekday : Day -> Day
107
107
```
108
108
109
109
Then with point on `nextWeekday`, call \gls{idris-add-clause}.
110
110
111
111
```idris
112
- nextWeekday : Day -> Day
113
- nextWeekday x = ?nextWeekday_rhs
112
+ nextWeekday : Day -> Day
113
+ nextWeekday x = ?nextWeekday_rhs
114
114
```
115
115
116
116
With the point on `day`, call \mintinline[]{elisp}{idris-case-split}
117
117
(\mintinline[]{elisp}{M-RET c } in Spacemacs ).
118
118
119
119
```idris
120
- nextWeekday : Day -> Day
121
- nextWeekday Monday = ?nextWeekday_rhs_1
122
- nextWeekday Tuesday = ?nextWeekday_rhs_2
123
- nextWeekday Wednesday = ?nextWeekday_rhs_3
124
- nextWeekday Thursday = ?nextWeekday_rhs_4
125
- nextWeekday Friday = ?nextWeekday_rhs_5
126
- nextWeekday Saturday = ?nextWeekday_rhs_6
127
- nextWeekday Sunday = ?nextWeekday_rhs_7
120
+ nextWeekday : Day -> Day
121
+ nextWeekday Monday = ?nextWeekday_rhs_1
122
+ nextWeekday Tuesday = ?nextWeekday_rhs_2
123
+ nextWeekday Wednesday = ?nextWeekday_rhs_3
124
+ nextWeekday Thursday = ?nextWeekday_rhs_4
125
+ nextWeekday Friday = ?nextWeekday_rhs_5
126
+ nextWeekday Saturday = ?nextWeekday_rhs_6
127
+ nextWeekday Sunday = ?nextWeekday_rhs_7
128
128
```
129
129
130
130
Fill in the proper `Day` constructors and align whitespace as you like.
@@ -213,17 +213,17 @@ In a similar way, we can define the standard type `Bool` of booleans, with
213
213
members `False` and `True`.
214
214
215
215
```idris
216
- ||| Boolean Data Type
217
- data Bool = True | False
216
+ ||| Boolean Data Type
217
+ data Bool = True | False
218
218
```
219
219
220
220
This definition is written in the simplified style , similar to `Day`. It can
221
221
also be written in the verbose style:
222
222
223
223
```idris
224
- data Bool : Type where
225
- True : Bool
226
- False : Bool
224
+ data Bool : Type where
225
+ True : Bool
226
+ False : Bool
227
227
```
228
228
229
229
The verbose style is more powerful because it allows us to assign precise
@@ -385,9 +385,9 @@ way of defining a type is to give a collection of _inductive rules_ describing
385
385
its elements . For example , we can define the natural numbers as follows :
386
386
387
387
```idris
388
- data Nat : Type where
389
- Z : Nat
390
- S : Nat -> Nat
388
+ data Nat : Type where
389
+ Z : Nat
390
+ S : Nat -> Nat
391
391
```
392
392
393
393
The clauses of this definition can be read :
@@ -519,9 +519,9 @@ can be written together. In the following definition, `(n, m : Nat)` means just
519
519
the same as if we had written `(n : Nat) -> (m : Nat)`.
520
520
521
521
```idris
522
- mult : (n, m : Nat) -> Nat
523
- mult Z = Z
524
- mult (S k ) = plus m (mult k m)
522
+ mult : (n, m : Nat) -> Nat
523
+ mult Z = Z
524
+ mult (S k ) = plus m (mult k m)
525
525
```
526
526
527
527
> testMult1 : (mult 3 3) = 9
@@ -530,10 +530,10 @@ mult (S k) = plus m (mult k m)
530
530
You can match two expressions at once:
531
531
532
532
```idris
533
- minus : (n, m : Nat) -> Nat
534
- minus Z _ = Z
535
- minus n Z = n
536
- minus (S k ) (S j ) = minus k j
533
+ minus : (n, m : Nat) -> Nat
534
+ minus Z _ = Z
535
+ minus n Z = n
536
+ minus (S k ) (S j ) = minus k j
537
537
```
538
538
539
539
\todo[inline]{Verify this .}
@@ -578,9 +578,9 @@ We can make numerical expressions a little easier to read and write by
578
578
introducing _syntax_ for addition , multiplication, and subtraction .
579
579
580
580
```idris
581
- syntax [x] "+" [y] = plus x y
582
- syntax [x] "-" [y] = minus x y
583
- syntax [x] "*" [y] = mult x y
581
+ syntax [x] "+" [y] = plus x y
582
+ syntax [x] "-" [y] = minus x y
583
+ syntax [x] "*" [y] = mult x y
584
584
```
585
585
586
586
```idris
@@ -723,7 +723,7 @@ is pronounced "implies."
723
723
As before , we need to be able to reason by assuming the existence of some
724
724
numbers `n` and `m`. We also need to assume the hypothesis `n = m`.
725
725
726
- -- FIXME
726
+ \todo[inline]{Edit.}
727
727
The `intros` tactic will serve to move all three of these from the goal into
728
728
assumptions in the current context.
729
729
0 commit comments