質問

I have a module which binds to a C function using the FFI. How can I make this module use doctest?

The error I get when running doctest Foo.hs is something like this:

ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
  bar
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-haskell-bugs@haskell.org

### Failure in Foo.hs:41: expression `foo'
expected: [42]
 but got: 
          <interactive>:24:1: Not in scope: `bar'
Examples: 2  Tried: 2  Errors: 0  Failures: 1
役に立ちましたか?

解決

Doctest accepts arbitrary GHC flags. If you want to run Doctest with FFI code you need to pass the exact same flags that you would need to run a GHCi session with that code. Have e.g. a look at the Doctest driver of unix-time.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top