In the previous video, we looked at infinite lists. We can define an infinite list of consecutive integers as follows: [1..] We can evaluate this list, but it won’t print …
Laziness is a key feature of the Haskell programming language. The main idea is that we only evaluate expressions when they are actually needed. Unlike Haskell, most programming languages implement …
Function types describe the types of arguments and return value of a function. The type of an argument can be a type variable, in which case we call the function …
Type inference is the process by which Haskell ‘guesses’ the types for variables and functions, without you needing to specify these types explicitly. Many functional languages feature type inference. There …
Partial Application and Currying Currying Consider a type signature of a function with three arguments: f :: X -> Y -> Z -> A The arrow “->” is right-associative, so …
Function types Ordinary data types are for primitive data (like (Int) and (Char)) and basic data structures (like ([Int]) and ([Char])). Algebraic data types are types that combine other types …
Professor Graham Hutton from Nottingham University recently visited us at Glasgow. In fact, Graham got his PhD at Glasgow — many years ago. He runs a Functional Programming research lab …
Now let’s have a go at using QuickCheck for ourselves. We presume you have already watched the video about QuickCheck in the previous step. We’ll run this session in GHCi …
QuickCheck is a useful tool for automatically generating test cases for your Haskell programs. It’s widely used in industrial settings. In this video, Jeremy is checking his Caesar’s Cipher implementation. …
What do we do when computations fail to generate results? Examples include taking the head of an empty list, or finding the minimum value of a tree which turns out …
Haskell provides a notation for defining functions based on predicate values. f x | predicate1 = expression1 | predicate2 = expression2 | predicate3 = expression3 For instance, the absolute value …
Scoping is an important way to keep your programs tidy. It involves limiting the region of the program in which names ‘exist’ and can be used. In Haskell, a let …
Parsing text is a very common and important operation. Monadic parser combinators are a convenient mechanism to build parsers by combining building blocks, and a good illustration of the practical …
The aim of this tutorial is to explain step by step how to build a simple parser using the Parsec library. The source code can be found on GitHub Parsing …
The Parsing Problem Parsing is the mechanism we use to make sense of structured information, e.g. written or spoken language. In the case of written language, it involves several steps: …