Skip to content

Instantly share code, notes, and snippets.

@kakkun61
Created November 19, 2025 12:14
Show Gist options
  • Select an option

  • Save kakkun61/c7abc3f149147116becbe565b415ad5e to your computer and use it in GitHub Desktop.

Select an option

Save kakkun61/c7abc3f149147116becbe565b415ad5e to your computer and use it in GitHub Desktop.
dist-newstyle
cabal-version: 3.0
name: cabal-doctest-tmp
version: 0
license: MIT
license-file: LICENSE
author: Kazuki Okamoto (岡本和樹)
maintainer: [email protected]
build-type: Custom
custom-setup
setup-depends:
base >= 4 && <5,
cabal-doctest >= 1 && <1.1
common warnings
ghc-options: -Wall
library
import: warnings
exposed-modules: MyLib
build-depends: base ^>=4.20.2.0
hs-source-dirs: .
default-language: Haskell2010
test-suite test
import: warnings
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: .
main-is: main.hs
build-depends:
base ^>=4.20.2.0,
cabal-doctest-tmp,
doctest
Copyright (c) 2025 Kazuki Okamoto (岡本和樹)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module Main where
import Build_test (flags, pkgs, module_sources)
import Data.Foldable (traverse_)
import System.Environment (unsetEnv)
import Test.DocTest (doctest)
main :: IO ()
main = do
traverse_ putStrLn args -- optionally print arguments
unsetEnv "GHC_ENVIRONMENT" -- see 'Notes'; you may not need this
doctest args
where
args = flags ++ pkgs ++ module_sources
module MyLib (someFunc) where
-- |
--
-- >>> someFunc
-- someFunc
someFunc :: IO ()
someFunc = putStrLn "someFunc"
module Main where
import Distribution.Extra.Doctest (defaultMainWithDoctests)
main :: IO ()
main = defaultMainWithDoctests "test"
@kakkun61
Copy link
Author

$ cabal test .
Build profile: -w ghc-9.10.3 -O1
In order, the following will be built (use -v for more details):
 - cabal-doctest-tmp-0 (file main.hs changed)
Preprocessing library for cabal-doctest-tmp-0...
Building library for cabal-doctest-tmp-0...
Preprocessing test suite 'test' for cabal-doctest-tmp-0...
Building test suite 'test' for cabal-doctest-tmp-0...
[1 of 1] Compiling Main             ( main.hs, dist-newstyle/build/aarch64-osx/ghc-9.10.3/cabal-doctest-tmp-0/build/test/test-tmp/Main.o ) [Source file changed]
main.hs:3:1: error: [GHC-87110]
    Could not find module ‘Build_test’.
    Use -v to see a list of the files searched for.
  |
3 | import Build_test (flags, pkgs, module_sources)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment