mirror of
https://github.com/sdiehl/write-you-a-haskell.git
synced 2024-09-11 19:47:31 +03:00
Some changes to the first three chapters.
This commit is contained in:
parent
1ede2bffd8
commit
d40f93d884
@ -199,10 +199,11 @@ large variety of program correctness properties.
|
||||
* Modeling and verifying theorems in mathematics and logic.
|
||||
* Preventing data races and deadlocks in concurrent systems.
|
||||
|
||||
Type systems can never capture all possible behavior of the program. Although
|
||||
more sophisticated type systems are increasingly able to model a large space of
|
||||
behavior and is one of the most exciting areas of modern computer science
|
||||
research. Put most bluntly, **static types let you be dumb** and offload the
|
||||
Even though type systems will never be able to capture all aspects of a
|
||||
program, more sophisticated type systems are increasingly able to model a large
|
||||
space of program behavior.
|
||||
They are one of the most exciting areas of modern computer science research.
|
||||
Put most bluntly, **static types let you be dumb** and offload the
|
||||
checking that you would otherwise have to do in your head to a system that can
|
||||
do the reasoning for you and work with you to interactively build your program.
|
||||
|
||||
|
@ -758,7 +758,8 @@ context. The primary function ``tell`` adds a value to the writer context.
|
||||
tell :: (Monoid w) => w -> Writer w ()
|
||||
```
|
||||
|
||||
The monad can be devalued with or without the collected values.
|
||||
The monad can be evaluated returning the collected writer context and
|
||||
optionally the returned value.
|
||||
|
||||
```haskell
|
||||
execWriter :: (Monoid w) => Writer w a -> w
|
||||
|
@ -40,8 +40,9 @@ the AST.
|
||||
~~~~ {.haskell slice="chapter3/parsec.hs" lower=8 upper=8}
|
||||
~~~~
|
||||
|
||||
Running the function will result in traversing the stream of characters yielding
|
||||
a resultant AST structure for the type variable ``a``, or failing with a parse
|
||||
Running the function will result in traversing the stream of characters
|
||||
yielding a value of type ``a`` that usually represents the AST for the
|
||||
parsed expression, or failing with a parse
|
||||
error for malformed input, or failing by not consuming the entire stream of
|
||||
input. A more robust implementation would track the position information of
|
||||
failures for error reporting.
|
||||
@ -70,7 +71,7 @@ it over the result of second parse function. Since the parser operation yields a
|
||||
list of tuples, composing a second parser function simply maps itself over the
|
||||
resulting list and concat's the resulting nested list of lists into a single
|
||||
flat list in the usual list monad fashion. The unit operation injects a single
|
||||
pure value into the parse stream.
|
||||
pure value as result without reading from the parse stream.
|
||||
|
||||
~~~~ {.haskell slice="chapter3/parsec.hs" lower=23 upper=28}
|
||||
~~~~
|
||||
|
Loading…
Reference in New Issue
Block a user