Haskell in Depth
Vitaly Bragilevsky
- 664 páginas
- English
- ePUB (apto para móviles)
- Disponible en iOS y Android
Haskell in Depth
Vitaly Bragilevsky
Información del libro
Haskell in Depth unlocks a new level of skill with this challenging language. Going beyond the basics of syntax and structure, this book opens up critical topics like advanced types, concurrency, and data processing. Summary Turn the corner from "Haskell student" to "Haskell developer." Haskell in Depth explores the important language features and programming skills you'll need to build production-quality software using Haskell. And along the way, you'll pick up some interesting insights into why Haskell looks and works the way it does. Get ready to go deep! Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the technology Software for high-precision tasks like financial transactions, defense systems, and scientific research must be absolutely, provably correct. As a purely functional programming language, Haskell enforces a mathematically rigorous approach that can lead to concise, efficient, and bug-free code. To write such code you'll need deep understanding. You can get it from this book! About the book Haskell in Depth unlocks a new level of skill with this challenging language. Going beyond the basics of syntax and structure, this book opens up critical topics like advanced types, concurrency, and data processing. You'll discover key parts of the Haskell ecosystem and master core design patterns that will transform how you write software. What's inside Building applications, web services, and networking apps
Using sophisticated libraries like lens, singletons, and servant
Organizing projects with Cabal and Stack
Error-handling and testing
Pure parallelism for multicore processors About the reader For developers familiar with Haskell basics. About the author Vitaly Bragilevsky has been teaching Haskell and functional programming since 2008. He is a member of the GHC Steering Committee. Table of Contents PART 1 CORE HASKELL
1 Functions and types
2 Type classes
3 Developing an application: Stock quotes
PART 2 INTRODUCTION TO APPLICATION DESIGN
4 Haskell development with modules, packages, and projects
5 Monads as practical functionality providers
6 Structuring programs with monad transformers
PART 3 QUALITY ASSURANCE
7 Error handling and logging
8 Writing tests
9 Haskell data and code at run time
10 Benchmarking and profiling
PART 4 ADVANCED HASKELL
11 Type system advances
12 Metaprogramming in Haskell
13 More about types
PART 5 HASKELL TOOLKIT
14 Data-processing pipelines
15 Working with relational databases
16 Concurrency
Preguntas frecuentes
Información
Part 1. Core Haskell
Text
instead of String
and looking for help to the pragmatics of using abstractions in Haskell. In the last chapter of this part, we’ll apply all the essential Haskell components to develop a standalone application that reports stock quote data.1 Functions and types
- Using the Glasgow Haskell Compiler (GHC) interpreter to solve problems
- Writing simple functional programs with pure functions and I/O actions
- Using a type-based approach to design programs
- Using GHC extensions for greater code readability
- Efficient processing of text data
- By using GHCi REPL (read-evaluate-print-loop) without writing a program
- By writing functions properly
- By keeping pure functions separate from the I/O actions that communicate to users
- By expressing ideas with types
1.1 Solving problems in the GHCi REPL with functions
- Extract all the words from the given text file.
- Count the number of unique words used (size of the vocabulary).
- Find the most frequently used words.
hid-examples
package), import a couple of modules for processing lists and characters, read the given file into a String
, and then manipulate its content, as shown in the next code:$ ghci ghci> :module + Data.List Data.Char ghci> text <- readFile "data/texts/hamlet.txt" ghci> ws = map head $ group $ sort $ words $ map toLower text ghci> take 7 ws ["&","'em?","'gainst","'tane","'tis","'tis,","'twas"]
ghci> :type toLower toLower :: Char -> Char ghci> :type map map :: (a -> b) -> [a] -> [b] ghci> :type words words :: String -> [String] ghci> :type sort sort :: Ord a => [a] -> [a] ghci> :type group group :: Eq a => [a] -> [[a]] ghci> :type head head :: [a] -> a
map
head
$
group
$
sort
$
words
$
map
toLower
text
expression, I’d advise writing out the specific types in place of the type variables in the type signatures. I’ll start here:text :: String = [Char] toLower :: Char -> Char map :: (a -> b) -> [a] -> [b]
map
has the following type:map :: (Char -> Char) -> [Char] -> [Char]
map toLower text :: [Char]