Let’s look at an example of a basic doctest.-- | 1 + 2 is 3.
-- >>> 1 + 2
-- 3
As you can see, Haskell doctests have three requirements:
Every doctest example should be placed within a valid piece of Haddock documentation, which is marked by either -- | or {- |.
Every doctest example should start with >>> and contain a valid Haskell expression that is in scope (sometimes you have to be explicit about the import statements – we’ll cover that further in the article).
Every doctest example should be followed by a line containing the expected result of evaluating the expression.
You can find additional info on doctest markup in the readme of the doctest library.Now, let’s create a project with doctests and go over Haskell libraries that you can use to run those doctests.