Skip to main content
Top

2019 | Book

Haskell Quick Syntax Reference

A Pocket Guide to the Language, APIs, and Library

Authors: Stefania Loredana Nita, Marius Mihailescu

Publisher: Apress

insite
SEARCH

About this book

This condensed code and syntax reference presents the essential Haskell syntax in a well-organized format that can be used as a quick and handy reference, including applications to cloud computing and data analysis. This book covers the functional programming features of Haskell as well as strong static typing, lazy evaluation, extensive parallelism, and concurrency
You won’t find any technical jargon, bloated samples, drawn out history lessons, or witty stories in this book. What you will find is a language reference that is concise, to the point and highly accessible. The Haskell Quick Syntax Reference is packed with useful information and is a must-have for any Haskell programmer working in big data, data science, and cloud computing.
What You Will Learn
Quickly and effectively use the Haskell programming language
Take advantage of strong static typing
Work with lazy evaluations
Harness concurrency and extensive parallelism using Haskell

Who This Book Is For
Experienced programmers who may be new to Haskell or have experience with Haskell and who just want a quick reference guide on it.

Table of Contents

Frontmatter
Chapter 1. Functional Programming
Abstract
Functional programming represents a programming paradigm in which the computations are evaluated by mathematical functions. The paradigm avoids changing states and using mutable data.
Stefania Loredana Nita, Marius Mihailescu
Chapter 2. Static Typing
Abstract
In Haskell, the type system is quite detailed. From a theoretical point of view, it comes from typed Lambda calculus, introduced in 1930 by Alfonso Church,, where the types are automatically deducted from the way the objects are processed. Such programming languages are statically typed. More precisely, the processing is enforced by and based on the rules of a mathematical type system.
Stefania Loredana Nita, Marius Mihailescu
Chapter 3. GHC
Abstract
GHC stands for Glasgow Haskell Compiler, which is the native code compiler for Haskell. It is open source and can be downloaded from https://www.haskell.org/ghc/ . It is also integrated into the Haskell Platform, available at https://www.haskell.org/downloads#platform . (We recommend you install the Haskell Platform because it contains the compiler, Cabal, and other tools you’ll use in this book.)
Stefania Loredana Nita, Marius Mihailescu
Chapter 4. Types
Abstract
In Chapter 3, you saw that GHC contains predefined functions, and you worked a little with the div function. In that example, we subtly introduced types, without a comprehensive discussion. It is time to discuss them now. So, in this chapter, you’ll learn about the main types in Haskell, how you can define your own types, and how the type system in Haskell works.
Stefania Loredana Nita, Marius Mihailescu
Chapter 5. Tuples
Abstract
Sometimes in your applications you’ll need to group elements. In this chapter, you will learn how to do this using tuples and what the main predefined functions for tuples are.
Stefania Loredana Nita, Marius Mihailescu
Chapter 6. Lists
Abstract
In this chapter, you’ll learn about lists and why are they so useful. You will learn what a list is, which basic functions there are for lists, which operations are faster, and in which context you might use lists.
Stefania Loredana Nita, Marius Mihailescu
Chapter 7. Functions
Abstract
In the previous chapters, you mainly worked with predefined functions from different libraries in Haskell. Now, it’s time to write your own functions. In this chapter, you will learn about pattern matching, guards, clauses, higher-order functions, and lambda expressions used in functions.
Stefania Loredana Nita, Marius Mihailescu
Chapter 8. Recursion
Abstract
In the previous chapter, you learned about functions in Haskell. Many times, in real-world applications you’ll work with functions that recall themselves, which is a process called recursion. In this chapter, you will learn what recursion is, see some concrete examples, and learn how you implement them in Haskell and how to apply recursion on lists.
Stefania Loredana Nita, Marius Mihailescu
Chapter 9. List Comprehension
Abstract
Chapter 6 introduced lists, and now you will learn another way to represent a list. Do you remember how sets are represented using mathematical symbols? Well, you will do that with lists. Further, you will learn more complex functions that you can apply on lists.
Stefania Loredana Nita, Marius Mihailescu
Chapter 10. Classes
Abstract
In the previous chapters, you created your own types. Now, it’s time to learn what classes are in Haskell and how to work with them. In this chapter, you’ll learn about the standard classes and then how to create your own classes.
Stefania Loredana Nita, Marius Mihailescu
Chapter 11. Pattern Matching
Abstract
In Chapter 7, you learned the basics of pattern matching, which is used with functions. In this chapter, you’ll learn more about the details of pattern matching.
Stefania Loredana Nita, Marius Mihailescu
Chapter 12. Monads
Abstract
Monads are important in Haskell, and they are used in many scenarios. The concept of monads can be confusing at first, but in this chapter, you will learn what monads are and how to use them in complex programs.
Stefania Loredana Nita, Marius Mihailescu
Chapter 13. Monad Transformers
Abstract
In the previous chapter, you saw how useful monads are. But what if you need operations from two different monads? In this chapter, you will learn how to proceed in such scenarios.
Stefania Loredana Nita, Marius Mihailescu
Chapter 14. Parsec
Abstract
Now that you know how to work with monads, let’s take a step further. In this chapter, you will learn how to use the Parsec library.
Stefania Loredana Nita, Marius Mihailescu
Chapter 15. Folds
Abstract
An important element in functional programming is the fold (also known as reduce). A fold represents a set of higher-order functions that operate on recursive data structures and take a combining operation as one of the parameters, recombining the results of recursive operations in order to build a return value. In this chapter, you will learn to use fold functions.
Stefania Loredana Nita, Marius Mihailescu
Chapter 16. Algorithms
Abstract
In this chapter, you’ll learn how to implement algorithms such as quicksort, mergesort, and bubblesort.
Stefania Loredana Nita, Marius Mihailescu
Chapter 17. Parsing
Abstract
Wikipedia defines the parsing process as follows:
Stefania Loredana Nita, Marius Mihailescu
Chapter 18. Parallelism and Concurrency
Abstract
Parallelism is a computing strategy that enables many computations (or the execution of processes) to be performed simultaneously. In this chapter, you will learn the basic elements of parallelism and concurrency in Haskell.
Stefania Loredana Nita, Marius Mihailescu
Chapter 19. Haskell Pipes
Abstract
Haskell streaming programs provide great features such as effects, streaming, and composability. In classical programming, you can choose just two of these features. In this chapter, you will learn how to use pipes to achieve all three.
Stefania Loredana Nita, Marius Mihailescu
Chapter 20. Lens
Abstract
In this chapter, you will learn about a particular type of functional reference. First, let’s see define functional reference: reference means you can access and/or modify part of the values, and functional means that the flexibility and composability of functions are assured while accessing these parts.
Stefania Loredana Nita, Marius Mihailescu
Chapter 21. Lazy Evaluation
Abstract
You already know that Haskell is based on lazy evaluation. This means that the expressions are evaluated only when it is necessary. But what is “necessary”? In this chapter, you will get an answer to that question, and you will take a deeper look at lazy evaluation in Haskell.
Stefania Loredana Nita, Marius Mihailescu
Chapter 22. Performance
Abstract
Sometimes your program will need to meet some requirements for space and time execution. It is really important to know how the data is represented, what lazy evaluation or strict evaluation involves, and how to control the space and time behavior. In this chapter, you will learn basic techniques to improve the performance of your programs.
Stefania Loredana Nita, Marius Mihailescu
Chapter 23. Haskell Stack
Abstract
Haskell Stack is a tool used to build Haskell projects and to handle its dependencies, including GHC, Cabal, a version of the Hackage repository, and a version of the Stackage package collection tool. In this chapter, you will learn the main uses of Haskell Stack.
Stefania Loredana Nita, Marius Mihailescu
Chapter 24. Yesod
Abstract
Yesod is a web framework based on Haskell for the professional development of type-safe, REST model–based, high-performance web applications.
Stefania Loredana Nita, Marius Mihailescu
Chapter 25. Haskell Libraries
Abstract
In programming, libraries are collections of precompiled routines that can be used in other programs. Usually, a library stores frequently used routines (for example, reading or printing an input), or it is specialized for a particular subject (for example, the libraries used in the statistics field). In this chapter, you will learn about the main libraries in Haskell and when you can use them to create powerful programs.
Stefania Loredana Nita, Marius Mihailescu
Chapter 26. Cabal
Abstract
Haskell includes a standard package system called Cabal, which is used to configure, build, install, and (re)distribute Haskell software. In this chapter, you will learn how to use Cabal to increase your productivity.
Stefania Loredana Nita, Marius Mihailescu
Backmatter
Metadata
Title
Haskell Quick Syntax Reference
Authors
Stefania Loredana Nita
Marius Mihailescu
Copyright Year
2019
Publisher
Apress
Electronic ISBN
978-1-4842-4507-1
Print ISBN
978-1-4842-4506-4
DOI
https://doi.org/10.1007/978-1-4842-4507-1

Premium Partner