2019-06-30 17:50:58 +03:00
|
|
|
Type Driven Development with Idris
|
|
|
|
==================================
|
|
|
|
|
|
|
|
The code in the book "Type Driven Development with Idris" by Edwin Brady,
|
|
|
|
published by Manning, will mostly work in Idris 2, with some small changes
|
|
|
|
as detailed in this document. The updated code is also [going to be] part
|
2019-07-01 14:43:02 +03:00
|
|
|
of the test suite (see tests/typedd-book).
|
2019-06-30 17:50:58 +03:00
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 1
|
2019-06-30 17:50:58 +03:00
|
|
|
---------
|
|
|
|
|
|
|
|
No changes necessary
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 2
|
2019-06-30 17:50:58 +03:00
|
|
|
---------
|
|
|
|
|
|
|
|
The Prelude is smaller than Idris 1, and many functions have been moved to
|
|
|
|
the base libraries instead. So:
|
|
|
|
|
|
|
|
In `Average.idr`, add:
|
|
|
|
|
2019-06-30 19:38:40 +03:00
|
|
|
import Data.Strings -- for `words`
|
|
|
|
import Data.List -- for `length` on lists
|
2019-06-30 17:50:58 +03:00
|
|
|
|
|
|
|
In `AveMain.idr` and `Reverse.idr` add:
|
|
|
|
|
2019-06-30 19:38:40 +03:00
|
|
|
import System.REPL -- for 'repl'
|
2019-06-30 17:50:58 +03:00
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 3
|
2019-06-30 17:50:58 +03:00
|
|
|
---------
|
|
|
|
|
2019-06-30 19:38:40 +03:00
|
|
|
Unbound implicits have multiplicity 0, so we can't match on them at run-time.
|
|
|
|
Therefore, in `Matrix.idr`, we need to change the type of `createEmpties`
|
|
|
|
and `transposeMat` so that the length of the inner vector is available to
|
|
|
|
match on:
|
|
|
|
|
|
|
|
createEmpties : {n : _} -> Vect n (Vect 0 elem)
|
|
|
|
transposeMat : {n : _} -> Vect m (Vect n elem) -> Vect n (Vect m elem)
|
2019-06-30 17:50:58 +03:00
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 4
|
2019-06-30 17:50:58 +03:00
|
|
|
---------
|
|
|
|
|
2019-07-01 23:35:19 +03:00
|
|
|
For the reasons described above:
|
|
|
|
|
|
|
|
In `DataStore.idr`, add `import System.REPL` and `import Data.Strings`
|
|
|
|
In `SumInputs.idr`, add `import System.REPL`
|
|
|
|
In `TryIndex.idr`, add an implicit argument:
|
2019-06-30 17:50:58 +03:00
|
|
|
|
2019-07-01 23:35:19 +03:00
|
|
|
tryIndex : {n : _} -> Integer -> Vect n a -> Maybe a
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 5
|
2019-06-30 17:50:58 +03:00
|
|
|
---------
|
|
|
|
|
2019-07-03 15:04:25 +03:00
|
|
|
There is no longer a `Cast` instance from `String` to `Nat`, because its
|
|
|
|
behaviour of returing Z if the `String` wasn't numeric was thought to be
|
|
|
|
confusing. Instead, there is `stringToNatOrZ` in `Data.Strings` which at least
|
|
|
|
has a clearer name. So:
|
|
|
|
|
|
|
|
In `Loops.idr` and `ReadNum.idr` add `import Data.Strings` and change `cast` to
|
|
|
|
`stringToNatOrZ`
|
2019-06-30 17:50:58 +03:00
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 6
|
2019-06-30 17:50:58 +03:00
|
|
|
---------
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 7
|
2019-06-30 17:50:58 +03:00
|
|
|
---------
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 8
|
2019-06-30 17:50:58 +03:00
|
|
|
---------
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 9
|
2019-06-30 17:50:58 +03:00
|
|
|
---------
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 10
|
2019-06-30 17:50:58 +03:00
|
|
|
----------
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 11
|
2019-06-30 17:50:58 +03:00
|
|
|
----------
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 12
|
2019-06-30 17:50:58 +03:00
|
|
|
----------
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 13
|
2019-06-30 17:50:58 +03:00
|
|
|
----------
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 14
|
2019-06-30 17:50:58 +03:00
|
|
|
----------
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
2019-07-01 02:23:19 +03:00
|
|
|
Chapter 15
|
2019-06-30 17:50:58 +03:00
|
|
|
----------
|
|
|
|
|
|
|
|
TODO
|