Skip to content

Commit 189717f

Browse files
committed
Edit Chapter 1
- Edit out use of first person singular - Clean up phrasing to make things flow better - Update text to reflect the chapter being broken up into subchapters - Introduce more structured formatting to some section - Clean up links to pages on the Idris2 github wiki that no longer exist - Add link to pack-db to the getting help section
1 parent 8de2760 commit 189717f

File tree

8 files changed

+113
-72
lines changed

8 files changed

+113
-72
lines changed

conversion-todo.org

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
1-
* DONE Get CI up and running
2-
* DONE Fix that whole extra line breaks bug
3-
* DONE Rewrite README
4-
** DONE Link to SUMMARY.md
5-
** DONE Document building mdbook
6-
** DONE Move some of the existing prose to a preface chapter
7-
* DONE Build docker container locally instead of using one from my personal forgejo
8-
* DONE Add links from github to mdbook and from mdbook to github
1+
* Conversion tasks and initial editing
2+
** DONE Get CI up and running
3+
** DONE Fix that whole extra line breaks bug
4+
** DONE Rewrite README
5+
*** DONE Link to SUMMARY.md
6+
*** DONE Document building mdbook
7+
*** DONE Move some of the existing prose to a preface chapter
8+
** DONE Build docker container locally instead of using one from my personal forgejo
9+
** DONE Add links from github to mdbook and from mdbook to github
910
This one's best done after migrating to the community project so we can have the correct url
10-
* DONE Organize ipkg modules in chapter order
11-
* DONE Break Chapters into sub-chapters as appropriate
12-
* DONE Configure mdformat
13-
* DONE Audit links
14-
* DONE Figure out exercise solutions situation
11+
** DONE Organize ipkg modules in chapter order
12+
** DONE Break Chapters into sub-chapters as appropriate
13+
** DONE Configure mdformat
14+
** DONE Audit links
15+
** DONE Figure out exercise solutions situation
1516
Will probably want to either convert the solutions files to markdown with katla or manually, and add them in a an appendex. Will need to go back and insert links/references.
16-
* STRT Rewrite prose to remove use of first person
17-
As this is becoming a community maintained tutorial, the prose should reflect the collective ownership and avoid the use of first person pronouns.
18-
* TODO Cleanup Imports and Exports
19-
* TODO Clean up fixity declarations
20-
* TODO Consistent on summary vs conclusion
21-
* TODO Place modules and visibility primer upfront
22-
* TODO Cleanup references to outdated sources
17+
** DONE Consistent on summary vs conclusion
18+
** STRT Clean Up Prose
19+
Need to:
20+
+ Remove use of first person singular, to reflect the collective ownership
21+
+ Update prose to reflect the new sub-chapter structure
22+
+ Update links and clean up broken ones
23+
+ Other minor editing changes to make the text flow better
24+
** TODO Cleanup Imports and Exports
25+
** TODO Clean up fixity declarations
26+
** TODO Place modules and visibility primer upfront
27+
** TODO Cleanup references to outdated sources
2328
Like the wiki library page
24-
* TODO Clean up exercise titling
29+
** TODO Clean up exercise titling
2530
Make sure section names match up with headers in solutions
26-
* TODO Inject highlighted repl output
27-
** TODO Actual test injection
31+
** TODO Inject highlighted repl output
32+
*** TODO Actual test injection
2833
Thread local IDEMode?
29-
** TODO Golden Tests
34+
*** TODO Golden Tests
3035
Should golden test the repl outputs to detect breakage
3136

3237
These should also be compared in a whitespace insensitive way, im thinking, like:
@@ -40,10 +45,12 @@ These should also be compared in a whitespace insensitive way, im thinking, like
4045
#+end_src
4146

4247
This keeps it readable as a raw markdown document, but provides easy processing for extraction and injection of the /actual/ repl output complete with highlighting.
43-
** TODO Special Handling for exec
44-
* TODO Selenized custom themes
48+
*** TODO Special Handling for exec
49+
** TODO Selenized custom themes
4550
Because I love myself
46-
* IDEA Standard library types
51+
** IDEA Standard library types
4752
When a subchapter reimplements a standard library type, we should maybe call this out and use the standard library type in future subchapters to decrease cross dependencies
48-
* IDEA Rename Modules To Chapter/Subchapter number?
53+
** IDEA Rename Modules To Chapter/Subchapter number?
4954
Could also potentially insert automatic linking?
55+
* New sections
56+
** TODO Property based testing

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- [A First Idris Program](./Tutorial/Intro/FirstIdrisProgram.md)
1111
- [The Shape of an Idris Definition](./Tutorial/Intro/ShapeOfADef.md)
1212
- [Where to Get Help](./Tutorial/Intro/WhereToGetHelp.md)
13-
- [Summary](./Tutorial/Intro/Summary.md)
13+
- [Conclusion](./Tutorial/Intro/Conclusion.md)
1414
- [Functions Part 1](./Tutorial/Functions1.md)
1515
- [Functions With More Than One Argument](./Tutorial/Functions1/FunctionsWithMultipleArguments.md)
1616
- [Function Composition](./Tutorial/Functions1/FunctionComposition.md)
Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,50 @@
11
# About the Idris Programming Language
22

3-
Idris is a *pure*, *dependently typed*, *total* *functional* programming language. I'll quickly explain each of these adjectives in this section.
3+
Idris is a *pure*, *dependently typed*, *total* *functional* programming language.
4+
5+
Lets break that down and explore what each of those terms means on their own.
46

57
## Functional Programming
68

7-
In functional programming languages, functions are first-class constructs, meaning that they can be assigned to variables, passed as arguments to other functions, and returned as results from functions. Unlike for instance in object-oriented programming languages, in functional programming, functions are the main form of abstraction. This means that whenever we find a common pattern or (almost) identical code in several parts of a project, we try to abstract over this in order to have to write the corresponding code only once. We do this by introducing one or more new functions implementing this behavior. Doing so, we often try to be as general as possible to make our functions as versatile to use as possible.
9+
In functional programming languages, functions are *first-class constructs*, meaning that they can be assigned to variables, passed as arguments to other functions, and returned as results from functions, just like any other value in the language. Unlike in, for instance, object-oriented languages, functions are the main form of abstraction in functional programming.
10+
11+
Whenever we find a common pattern or (almost) identical code in several parts of a project, we try to implement an abstraction over it to avoid write the same code multiple times. In functional programming, we do this by introducing one or more new functions implementing the required behavior, often trying to be as general as possible to maximize the versatility and re-usability of our functions.
812

9-
Functional programming languages are concerned with the evaluation of functions, unlike classical imperative languages, which are concerned with the execution of statements.
13+
Functional programming languages are concerned with the evaluation of functions, unlike imperative languages, which are concerned with the execution of statements.
1014

1115
## Pure Functional Programming
1216

13-
Pure functional programming languages come with an additional important guarantee: Functions don't have side effects like writing to a file or mutating global state. They can only compute a result from their arguments possibly by invoking other pure functions, *and nothing else*. As a consequence, given the same input, they will *always* generate the same output. This property is known as [referential transparency](https://en.wikipedia.org/wiki/Referential_transparency).
17+
*Pure* functional programming languages come with an additional important guarantee:
18+
19+
Functions don't have side effects, like writing to a file or mutating global state. They can only compute a result from their arguments possibly by invoking other pure functions, *and nothing else*. Given the same input, a pure function will *always* generate the same output, this property is known as [referential transparency](https://en.wikipedia.org/wiki/Referential_transparency).
1420

1521
Pure functions have several advantages:
1622

17-
- They can easily be tested by specifying (possibly randomly generated) sets of input arguments together with the expected results.
23+
- They are easy to test by specifying (possibly randomly generated) sets of input arguments alongside the expected results.
1824

19-
- They are thread-safe, since they don't mutate global state, and as such can be freely used in several computations running in parallel.
25+
- They are thread-safe. Since they don't mutate global state, they be used in several computations running in parallel without interfering with each other.
2026

2127
There are, of course, also some disadvantages:
2228

23-
- Some algorithms are hard to implement efficiently using only pure functions.
29+
- Some algorithms are hard to implement efficiently with only pure functions.
2430

25-
- Writing programs that actually *do* something (have some observable effect) is a bit trickier but certainly possible.
31+
- Writing programs that actually *do* something (have some observable effect) is a bit tricky, but certainly possible.
2632

2733
## Dependent Types
2834

29-
Idris is a strongly, statically typed programming language. This means that every Idris expression is given a *type* (for instance: integer, list of strings, boolean, function from integer to boolean, etc.) and types are verified at compile time to rule out certain common programming errors.
35+
Idris is a strongly, statically typed programming language. Every expression is given a *type* (for instance: integer, list of strings, boolean, function from integer to boolean, etc.), and types are verified at compile time to rule out certain common programming errors.
3036

31-
For instance, if a function expects an argument of type `String` (a sequence of unicode characters, such as `"Hello123"`), it is a *type error* to invoke this function with an argument of type `Integer`, and the Idris compiler will refuse to generate an executable from such an ill-typed program.
37+
For instance, if a function expects an argument of type `String` (a sequence of unicode characters, such as `"Hello123"`), it is a *type error* to invoke this function with an argument of type `Integer`, and Idris will refuse to compile such an ill-typed program.
3238

33-
Being *statically typed* means that the Idris compiler will catch type errors at *compile time*, that is, before it generates an executable program that can be run. The opposite to this are *dynamically typed* languages such as Python, which check for type errors at *runtime*, that is, when a program is being executed. It is the philosophy of statically typed languages to catch as many type errors as possible before there even is a program that can be run.
39+
Being *statically typed* means that Idris will catch type errors at *compile time*, before it generates an executable program that can be run. This stands in contrast with *dynamically typed* languages such as Python, which check for type errors at *runtime*, while a program is already being executed. It is the goal of statically typed languages to catch as many type errors as possible before there even is a program that can be run.
3440

35-
Even more, Idris is *dependently typed*, which is one of its most characteristic properties in the landscape of programming languages. In Idris, types are *first class*: Types can be passed as arguments to functions, and functions can return types as their results. Even more, types can *depend* on other *values*. What this means, and why this is incredibly useful, we'll explore in due time.
41+
Furthermore, Idris is *dependently typed*, which is one of its most characteristic properties in comparison to other programming languages. In Idris, types are *first class*: Types can be passed as arguments to functions, and functions can return types as their results. Types can also *depend* on other *values*, as one example, the return type of a function can depend on the value of one of its arguments. This is a quite abstract statement that may be difficult to grasp at first, but we will be exploring its meaning and the profound impact it has on programming through example as we move through this book.
3642

3743
## Total Functions
3844

39-
A *total* function is a pure function, that is guaranteed to return a value of the expected return type for every possible input in a finite number of computational steps. A total function will never fail with an exception or loop infinitely, although it can still take arbitrarily long to compute its result
45+
A *total* function is a pure function which is guaranteed to return a value of its return type for every possible set of inputs in a finite number of computational steps. A total function will never fail with an exception or loop infinitely, although it can still take arbitrarily long to compute its result.
4046

41-
Idris comes with a totality checker built-in, which enables us to verify the functions we write to be provably total. Totality in Idris is opt-in, as in general, checking the totality of an arbitrary computer program is undecidable (see also the [halting problem](https://en.wikipedia.org/wiki/Halting_problem)). However, if we annotate a function with the `total` keyword, Idris will fail with a type error, if its totality checker cannot verify that the function in question is indeed total.
47+
Idris comes with a totality checker built-in, which allows us to verify that the functions we write are provably total. Totality in Idris is opt-in, as checking the totality of an arbitrary computer program is undecidable in the general case (a dilemma you may recognize as the [halting problem](https://en.wikipedia.org/wiki/Halting_problem)). However, if we annotate a function with the `total` keyword, and the totality checker is unable to verify that the function is, indeed, total, Idris will fail with a type error. Notably, failing to determine a function is total is not the same as judging the function to be non-total.
4248

4349
<!-- vi: filetype=idris2:syntax=markdown
4450
-->
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Summary
1+
# Conclusion
22

33
In this introduction we learned about the most basic features of the Idris programming language. We used the REPL to tinker with our ideas and inspect the types of things in our code, and we used the Idris compiler to compile an Idris source file to an executable.
44

src/Tutorial/Intro/FirstIdrisProgram.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,42 @@
44
module Tutorial.Intro.FirstIdrisProgram
55
```
66

7-
We will often start up a REPL for tinkering with small parts of the Idris language, for reading some documentation, or for inspecting the content of an Idris module, but now we will write a minimal Idris program to get started with the language. Here comes the mandatory *Hello World*:
7+
While we will often start with the REPL for tinkering with small parts of the Idris language, for reading some documentation, or for inspecting the content of an Idris module, lets go ahead and will write a minimal Idris program to get started with the language.
8+
9+
Here comes the mandatory *Hello World*:
810

911
```idris
1012
main : IO ()
1113
main = putStrLn "Hello World!"
1214
```
1315

14-
We will inspect the code above in some detail in a moment, but first we'd like to compile and run it. From this project's root directory, run the following:
16+
We will inspect the code above in some detail in a moment, but first we'd like to compile and run it. If you have checked out this books source code, you can run the following from the root directory:
1517

1618
```sh
17-
pack -o hello exec src/Tutorial/Intro.md
19+
pack -o hello exec src/Tutorial/Intro/FirstIdrisProgram.md
1820
```
1921

20-
This will create executable `hello` in directory `build/exec`, which can be invoked from the command-line like so (without the dollar prefix; this is used here to distinguish the terminal command from its output):
22+
This will create an executable called `hello` in the `build/exec` directory, which can be invoked from the command-line like so (without the dollar prefix; this is used here to distinguish the terminal command from its output):
2123

2224
```sh
2325
$ build/exec/hello
2426
Hello World!
2527
```
2628

27-
The pack program requires an `.ipkg` to be in scope (in the current directory or one of its parent directories) from which it will get other settings like the source directory to use (`src` in our case). The optional `-o` option gives the name of the executable to be generated. Pack comes up with a name of its own it this is missing. Type `pack help` for a list of available command-line options and commands, and `pack help <cmd>` for getting help for a specific command.
29+
The pack program requires an `.ipkg` to be in scope (in the current directory or one of its parent directories), which provides other settings like the source directory to use (`src` in our case). The optional `-o` option provides a name to use for the executable to be generated. Pack comes up with a name of its own it this is not provided. Type `pack help` for a list of available command-line options and commands, and `pack help <cmd>` for help with a specific command.
2830

29-
As an alternative, you can also load this source file in a REPL session and invoke function `main` from there:
31+
You can also load this source file in a REPL session and invoke function `main` from there:
3032

3133
```sh
32-
pack repl src/Tutorial/Intro.md
34+
pack repl src/Tutorial/Intro/FirstIdrisProgram.md
3335
```
3436

3537
```repl
3638
Tutorial.Intro> :exec main
3739
Hello World!
3840
```
3941

40-
Go ahead and try both ways of building and running function `main` on your system!
42+
Go ahead and try both ways of building and running `main` on your system!
4143

4244
<!-- vi: filetype=idris2:syntax=markdown
4345
-->

0 commit comments

Comments
 (0)