Setup doesn't work properly / parse error on input 'import'
k-bx opened this issue · comments
Hi. Not sure if I'm doing something wrong or not. I've created a very small repo where you can reproduce the error https://github.com/k-bx/docbug
The library code is as simple as:
module SomeLib where
-- $setup
-- let x = 1
import Data.Monoid
-- |
-- >>> add 1 1
-- 2
add :: Int -> Int -> Int
add x y = x + y
When I run stack test
, I get:
$ stack test
docbug-0.1.0.0: test (suite: doctests)
src/SomeLib.hs:5:1: error: parse error on input ‘import’
Test suite failure for package docbug-0.1.0.0
doctests: exited with: ExitFailure 1
Logs printed to console
@k-bx This is a limitation of GHC's parser. The import has to go before the $setup
-chunk.
I just stumbled upon this issue. Let us maybe make some appropriate corrections to README so that less people have to rediscover this ticket?
Yes, can you do this?