Skip to content

Commit

Permalink
Merge pull request #13 from bwignall/sync_upstream
Browse files Browse the repository at this point in the history
Sync upstream
  • Loading branch information
bwignall authored Dec 19, 2019
2 parents b30c0c8 + c88d662 commit 13254da
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions 12-barcode-recognition.org
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ image when we converted it from colour to monochrome. Here's an
image captured from a VGA-resolution camera. All we've done is
crop it down to the barcode.

[[file:figs/ch12-barcode-photo.jpg]]
[[file:ch12-barcode-photo.jpg]]

The encoded digit string, 9780132114677, is printed below the
barcode. The left group encodes the digits 780132, with 9 encoded
Expand All @@ -647,14 +647,14 @@ the final 7 is the check digit. Here's a clean encoding of this
barcode, from one of the many web sites that offer barcode image
generation for free.

[[file:figs/ch12-barcode-generated.png]]
[[file:ch12-barcode-generated.png]]

We've chosen a row from the captured image, and stretched it out
vertically to make it easier to see. We've superimposed this on
top of the perfect image, and stretched it out so that the two are
aligned.

[[file:figs/ch12-barcode-example.png]]
[[file:ch12-barcode-example.png]]

The luminance-converted row from the photo is in the dark grey
band. It is low in contrast and poor in quality, with plenty of
Expand Down
2 changes: 1 addition & 1 deletion 19-error-handling.org
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ handling.
#+BEGIN_EXAMPLE
newtype Parser a = P {
runP :: ErrorT ParseError (State B.ByteString) a
} deriving (Monad, MonadError ParseError)
} deriving (Functor, Applicative, Monad, MonadError ParseError)
#+END_EXAMPLE

As usual, we have wrapped our monad stack in a ~newtype~. This
Expand Down
16 changes: 8 additions & 8 deletions 2-types-and-functions.org
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ expressions as valid than a stronger type system.

For example, in Perl, the expression ~"foo" + 2~ evaluates to the
number 2, but the expression ~"13foo" + 2~ evaluates to the number
15. Haskell rejects both expressions as invalid, because the ~(+)~
~15~. Haskell rejects both expressions as invalid, because the ~(+)~
operator requires both of its operands to be numeric. Because
Perl's type system is more permissive than Haskell's, we say that
it is weaker under this narrow technical interpretation.
Expand Down Expand Up @@ -226,7 +226,7 @@ will end up greater than the sum of its parts.

** Some common basic types

In [[file:1-getting-started.org::*First steps with types][the section called "First steps with types"]]
In [[file:getting-started.html#starting.types][the section called "First steps with types"]], we introduced a
few types. Here are several more of the most common base types.

- A ~Char~ value represents a Unicode character.
Expand All @@ -253,7 +253,7 @@ few types. Here are several more of the most common base types.
~Float~ is much slower.)

We have already briefly seen Haskell's notation for types in
[[file:1-getting-started.org::*First steps with types][the section called "First steps with types"]]
[[file:getting-started.html#starting.types][the section called "First steps with types"]]. When we write a type
explicitly, we use the notation ~expression :: MyType~ to say that
~expression~ has the type ~MyType~. If we omit the ~::~ and the
type that follows, a Haskell compiler will infer the type of the
Expand Down Expand Up @@ -339,7 +339,7 @@ A composite data type is constructed from other types. The most
common composite data types in Haskell are lists and tuples.

We've already seen the list type mentioned in
[[file:1-getting-started.org::*Strings and characters][the section called "Strings and characters"]]
[[file:getting-started.html#starting.string][the section called "Strings and characters"]], where we found that
Haskell represents a text string as a list of ~Char~ values, and
that the type "list of ~Char~" is written ~[Char]~.

Expand All @@ -364,7 +364,7 @@ ghci> tail [True,False]
ghci> tail "list"
"ist"
ghci> tail []
*** Exception: Prelude.tail: empty list
,*** Exception: Prelude.tail: empty list
#+END_SRC

As you can see, we can apply ~head~ and ~tail~ to lists of
Expand Down Expand Up @@ -1281,7 +1281,7 @@ return to the subject in [[file:6-using-typeclasses.org][Chapter 6, Using Type

*** Reasoning about polymorphic functions

In [[file:2-types-and-functions.org::*Function types and purity][the section called "Function types and purity"]]
In [[file:types-and-functions.html#funcstypes.sigs][the section called "Function types and purity"]], we talked about
figuring out the behaviour of a function based on its type
signature. We can apply the same kind of reasoning to polymorphic
functions. Let's look again at ~fst~.
Expand Down Expand Up @@ -1339,7 +1339,7 @@ returns a list of the same type as its result.

This is correct, but it's not easy to see what its consequences
might be. We'll return to this topic in
[[file:4-functional-programming.org::*Partial function application and currying][the section called "Partial function application and currying"]]
[[file:functional-programming.html#fp.partialapp][the section called "Partial function application and currying"]],
once we've spent a bit of time writing functions. For now, we can
treat the type following the last ~->~ as being the function's
return type, and the preceding types to be those of the function's
Expand Down Expand Up @@ -1435,7 +1435,7 @@ let's call it a duck."
information to help it to make a choice in understanding our code.

[fn:3] We'll talk more about polymorphism in
[[file:2-types-and-functions.org::*Polymorphism in Haskell][the section called "Polymorphism in Haskell"]]
[[file:types-and-functions.html#funcstypes.polymorphism][the section called "Polymorphism in Haskell"]].

[fn:4] The environment in which ~ghci~ operates is called the IO
monad. In [[file:7-io.org][Chapter 7, /I/O/]], we will cover the IO
Expand Down
16 changes: 8 additions & 8 deletions 9-a-library-for-searching-the-file-system.org
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ that could cause spurious failures elsewhere in our program.

#+CAPTION: BetterPredicate.hs
#+BEGIN_SRC haskell
getFileSize path = handle (\_ -> return Nothing) :: IOError -> IO (Maybe Integer)) $
getFileSize path = handle ((\_ -> return Nothing) :: IOError -> IO (Maybe Integer)) $
bracket (openFile path ReadMode) hClose $ \h -> do
size <- hFileSize h
return (Just size)
Expand Down Expand Up @@ -1353,15 +1353,15 @@ badWhere = -- legal, but ugly and hard to read

** Exercises

1. Port the code from this chapter to your platform's native API,
either ~System.Posix~ or ~System.Win32~.
2. Add the ability to find out who owns a directory entry to your
code. Make this information available to predicates.

** Footnotes

Although the file finding code we described in this chapter is a
good vehicle for learning, it's not ideal for real systems
programming tasks, because Haskell's portable I/O libraries don't
expose enough information to let us write interesting and
complicated queries.

** Footnotes

1. Port the code from this chapter to your platform's native API,
either ~System.Posix~ or ~System.Win32~.
2. Add the ability to find out who owns a directory entry to your
code. Make this information available to predicates.

0 comments on commit 13254da

Please sign in to comment.