Idris2-boot/TypeDD.md

111 lines
2.0 KiB
Markdown
Raw Normal View History

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
of the test suite (see tests/typedd-book).
2019-07-01 02:23:19 +03:00
Chapter 1
---------
No changes necessary
2019-07-01 02:23:19 +03:00
Chapter 2
---------
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
In `AveMain.idr` and `Reverse.idr` add:
2019-06-30 19:38:40 +03:00
import System.REPL -- for 'repl'
2019-07-01 02:23:19 +03:00
Chapter 3
---------
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-07-01 02:23:19 +03:00
Chapter 4
---------
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-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
---------
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-07-01 02:23:19 +03:00
Chapter 6
---------
TODO
2019-07-01 02:23:19 +03:00
Chapter 7
---------
TODO
2019-07-01 02:23:19 +03:00
Chapter 8
---------
TODO
2019-07-01 02:23:19 +03:00
Chapter 9
---------
TODO
2019-07-01 02:23:19 +03:00
Chapter 10
----------
TODO
2019-07-01 02:23:19 +03:00
Chapter 11
----------
TODO
2019-07-01 02:23:19 +03:00
Chapter 12
----------
TODO
2019-07-01 02:23:19 +03:00
Chapter 13
----------
TODO
2019-07-01 02:23:19 +03:00
Chapter 14
----------
TODO
2019-07-01 02:23:19 +03:00
Chapter 15
----------
TODO