Megaparsec tutorial. Published on February 23, 2019, last updated September 21, 2020 This is the Megaparsec tutorial which originally was written as a chapter for the Intermediate Haskell book.
Due to lack of progress with the book in the last year, other authors agreed to let me publish the text as a standalone tutorial so people can benefit at least from this part of our work. Japanese translation, Chinese translation. The toy parser combinators developed in chapter “An Example: Writing Your Own Parser Combinators” are not suitable for real-world use, so let us continue by taking a look at the libraries in the Haskell ecosystem that solve the same problem, and note various trade-offs they make: parsec has been the “default” parsing library in Haskell for a long time. It would be impractical to try to cover all these libraries, and so we will focus on megaparsec. ParsecT and Parsec monads ParsecT is the main parser monad transformer and the central data type in megaparsec.
Character and binary streams Lexing. Exceptions tutorial. Published on March 3, 2019 This text originally was written as a chapter for the Intermediate Haskell book.
Due to lack of progress with the book in the last year, other authors agreed to let me publish the text as a standalone tutorial so people can benefit at least from this part of our work. Motivation for exceptions It is not uncommon to hear the opinion that exceptions are ugly and hard to work with.
Getting Started. Monads. Functional Programming Fundamentals. Haskell Notes And Examples - Albert Y. C. Lai. Anat category theory teki con. Tutorials. Introductions to Haskell These are the recommended places to start learning, short of buying a textbook. See also Meta-tutorial, another, shorter overview of tutorials aimed at helping you find the right one. Best places to start Introduction to Haskell (Spring 2013) An excellent tutorial to Haskell for beginners given as a course at UPenn by the author of the Typeclassopedia and Diagrams, Brent Yorgey. Learn You a Haskell for Great Good! Nicely illustrated tutorial showing Haskell concepts while interacting in GHCi. Real World Haskell (RWH) A free online version of the complete book, with numerous reader-submitted comments. Yet Another Haskell Tutorial (YAHT) By Hal Daume III et al. Happy Learn Haskell Tutorial (HLHT) Illustrated total beginner tutorial with fun, example-driven learning.
Haskell Wikibook A communal effort by several authors to produce the definitive Haskell textbook. Write Yourself a Scheme in 48 Hours in Haskell A Haskell Tutorial, by Jonathan Tang. Category Theory, The essence of interface-based design - Erik Meijer. A QuickCheck Tutorial: Generators. QuickCheck is a Haskell library for testing properties using randomly generated values.
It's one of the most popular Haskell libraries and part of the reason why functional programming has mattered. In short, we can use functions to express properties about our programs and QuickCheck to test that such properties hold for large numbers of random cases. For example, given a function to reverse the elements of a list: reverse :: [a] -> [a] reverse [] = [] reverse (x:xs) = reverse xs ++ [x] We can define a property to check whether reversing a list (of integers) yields the same list or not: prop_ReverseReverseId :: [Integer] -> Boolprop_ReverseReverseId xs = reverse (reverse xs) == xs And QuickCheck will generate 100 lists and test that the property holds for all of them: ghci> quickCheck prop_ReverseReverseId +++ OK, passed 100 tests.
If we define a property to check whether reversing a list once yields the same list or not (which holds only for some lists): generate :: Gen a -> IO a And roll it: