cabal-doctest: A Setup.hs helper for doctests running

[ bsd3, distribution, library ] [ Propose Tags ]

Currently (beginning of 2017), there isn't cabal doctest command. Yet, to properly work doctest needs plenty of configuration. This library provides the common bits for writing custom Setup.hs See Cabal/2327 for the progress of cabal doctest, i.e. whether this library is obsolete.

[Skip to Readme]
Versions [faq] 1, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8
Change log
Dependencies base (>=4.3 && <4.11), Cabal (>=1.10 && <2.0), directory, filepath [details]
License BSD-3-Clause
Copyright (c) 2017 Oleg Grenrus
Author Oleg Grenrus <>
Maintainer Oleg Grenrus <>
Revised Revision 1 made by phadej at 2017-06-03T21:05:04Z
Category Distribution
Home page
Source repo head: git clone
Uploaded by phadej at 2017-01-31T17:30:44Z
Distributions Arch:1.0.8, Debian:1.0.6, Fedora:1.0.8, LTSHaskell:1.0.8, NixOS:1.0.8, Stackage:1.0.8, openSUSE:1.0.8
Downloads 80397 total (904 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2017-01-31 [all 1 reports]




Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees

Readme for cabal-doctest-1

[back to package description]


Hackage Build Status

A Setup.hs helper for running doctests.

Example Usage

To use this library in your Setup.hs, you should specify a custom-setup section in your .cabal file. For example:

   base >= 4 && <5,
   cabal-doctest >= 1 && <1.1

You'll also need to specify build-type: Custom at the top of the .cabal file. Now put this into your Setup.hs file:

module Main where

import Distribution.Extra.Doctest (defaultMainWithDoctests)

main :: IO ()
main = defaultMainWithDoctests "doctests"

When you build your project, this Setup will generate a Build_doctests module. To use it in a testsuite, simply do this:

module Main where

import Build_doctests (flags, pkgs, module_sources)
import Data.Foldable (traverse_)
import Test.Doctest (doctest)

main :: IO ()
main = do
    traverse_ putStrLn args -- optionally print arguments
    doctest args
    args = flags ++ pkgs ++ module_sources


  • custom-setup section is supported starting from cabal-install-1.24. For older cabal-install's you have to install custom setup dependencies manually.

  • stack respects custom-setup starting from version 1.3.3. Before that you have to use explicit-setup-deps setting in your stack.yaml. (stack/GH-2094)

  • There is [an issue in the Cabal issue tracker]( Cabal/2327) about adding cabal doctest command. After that command is implemented, this library will be deprecated.


Copyright 2017 Oleg Grenrus.

Available under the BSD 3-clause license.