In the acknowledgements, Vitaly Bragilevski's name is misspelled in one instance.
GHCi>simple^2
should be:
GHCI>simple 3
helloworld is misspelled. Re;lace code with the following:
$ghc hello.hs -o helloworld
[1 of 1] Compiling Main
Linking helloworld ....
Aside from their role as a theoretical corner store of functional programming, they provide practical benefits.
should be:
Aside from their role as a theoretical cornerstone of functional programming, they provide practical benefits.
In the second and last paragraph, change ifEveninc
to ifEvenInc
.
There is a function with the following definition right before listing 8.1:
myLength xs = 1 + length (tail xs)
The definition should be:
myLength xs = 1 + myLength (tail xs)
(This is correct in listing 8.1.)
Delete the second passed in the following sentence: The difference is that the function passed to `filter` must be passed a function that returns True or False. It should be: The difference is that the function passed to `filter` must be a function that returns True or False.
In the sidebar, "Creating types with newtype" the following sentence:
"Any type that you can define with newtype
, you can also define using data
.
The word "data" should be: in code font. This is also true of the last sentence:
"For simplicity, we'll stick to creating types with data
throughout this book."
Replace listing 15.2 with the following:
rotN :: (Bounded a, Enum a) => Int -> a -> a
rotN alphabetSize c = toEnum rotation
where halfAlphabet = alphabetSize `div` 2
offset = fromEnum c + halfAlphabet
rotation = offset `mod` alphabetSize
In listing 15.5
[FourLetterAlpha]
should be:
[FourLetterAlphabet]
rotEncoder function is misspelled.
This allows you to create a common interface for any new ciphers you may write, as well as making working with rotEncode and applyOTP easier.
should be:
This allows you to create a common interface for any new ciphers you may write, as well as making working with rotEncoder and applyOTP easier.
In this example, you can use two type constructors that can either be a Name consisting of two Strings or a NameWithMiddle consisting of three Strings.
The Book data type in listing 16.2 isn't a correct translation.
data Book = Author String String Int
should be:
data Book = Book AuthorName String String Int Double
In this example, you can use two type constructors that can either be a FirstName consisting of two Strings or a NameWithMiddle consisting of three Strings.
should be:
In this example, you can use two type constructors that can either be a Name consisting of two Strings or a NameWithMiddle consisting of three Strings.
This is arguably not really an error, but technically, in Consider this:
"this" ++ " " ++ "is" ++ " " ++ "a" ++ " " ++ "bit" ++ "much"
should be:
"this" ++ " " ++ "is" ++ " " ++ "a" ++ " " ++ "bit" ++ " " ++ "much"
Some missing back ticks snuck through here, as well as missing >s after the GHCi. After listing 17.7 we see the following code:
GHCi [1,2,3] ++ []
[1,2,3]
GHCi [1,2,3] <> []
[1,2,3]
GHCi [1,2,3] mappend mempty
[1,2,3]
The correct code follows:GHCi> [1,2,3] ++ []
[1,2,3]
GHCi> [1,2,3] <> []
[1,2,3]
GHCi> [1,2,3] `mappend` mempty
[1,2,3]
But they'll come up as you dive deeper into the more advanced types classes covered in unit 5 (Functor, Applicative, and Monad).
should be:
But they'll come up as you dive deeper into the more advanced type classes covered in unit 5 (Functor, Applicative, and Monad).
In GHCi, you use the :kind command to look up the kinds of any types you're unsure of
(make sure to import Data.Map):
should be:
In GHCi, you use the :kind command to look up the kinds of any types you're unsure of
(make sure to import Data.Map using a qualified import, see section 18.2.3):
The following code:
GHCi> :kind Map.Map Map.Map :: * -> * -> *
GHCi> :kind Map.Map
Map.Map :: * -> * -> *
The answer should be:
(,,) :: * -> * -> * -> *
Maybe is a great example of how powerful types make your code less erro- prone.
should be:
Maybe is a great example of how powerful types make your code less error-prone."
Create your own version of T.lines and T.unlines by using splitOn and T.intercalate.
should be:
Create your own version of T.lines and T.unlines by using T.splitOn and T.intercalate.
You can see that this code never closes the file handle, and just returns the results of hGetContent.
should be:
You can see that this code never closes the file handle, and just returns the results of hGetContents.
Listing 26.19 title references wrong type.
MarcDirectoryRaw
type synonym and dirEntryLength
should be:
MarcDirectoryEntryRaw
type synonym and dirEntryLength
There's a missing space after the CHCi> prompt at the end of the page. The following:
GHCi>Map.lookup 1 htmlPartsDB
should be:GHCi> Map.lookup 1 htmlPartsDB
Q27.1 When we introduced parameterized types in lesson 15, you used a minimal type Box as the example:
should be:
Q27.1 When we introduced parameterized types in lesson 18, you used a minimal type Box as the example:
In lesson 5, you learned that partial application means that calling a function with fewer functions that it requires results in a function waiting for the remaining arguments.
should be:
In lesson 5, you learned that partial application means that calling a function with fewer arguments that it requires results in a function waiting for the remaining arguments.
Then in section 10.2.2, you saw that all functions are functions of one argument.
should be:
Then in section 11.2.2, you saw that all functions are functions of one argument.
The commas in listing 29.10 should be aligned with the opening bracked ([) as in the other listings on this page.
Figure 31.1 on the right side.
putStrLn nameStatement
should be:
putStrLn (nameStatement name)
Because you want to see how well you can treat lists such as tables in a relational database, you'll use an example involving students, teachers, courses, and enrollments.
should be:
Because you want to see how well you can treat lists like tables in a relational database, you'll use an example involving students, teachers, courses, and enrollments.
Sophomore is misspelled in Listing 33.4
,(Student 5 Sophmore (Name "Jean" "Baudrillard"))
should be:
,(Student 5 Sophomore (Name "Jean" "Baudrillard"))
Change all instances of check the length of primes to getting the last prime.
| n >= length primes = Nothing
should be:
| n >= last primes = Nothing
For the property tests:
val >= length primes
should be:
val >= last primes
Listing 33.23 is missing a closing parenthesis in line 3:
(studentName st, course en))
should be:
(studentName st, course en)))
The command line misspells exec.
$ stack exe primes-exe
should be:
$ stack exec primes-exe
Instances of headaches.cabal should be palindrome-checker.cabal.
As a refresher from lesson 35, open the headaches.cabal file in the projects root directory, find the executable section of the .cabal file, and append -Wall
to the list of ghc- options as shown here:
executable headaches-exe
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
build-depends: base
, headaches
default-language: Haskell2010
should be:
As a refresher from lesson 35, open the palindrome-checker.cabal file in the projects root directory, find the executable section of the .cabal file, and append -Wall to the list of ghc- options as shown here:
executable palindrome-checker-exe
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
build-depends: base
, text
, palindrome-checker
default-language: Haskell2010
In Q31.1, remove the colon character at the end of line 17.
putStrLn (describePizza betterPizza):
should be:
putStrLn (describePizza betterPizza)