Question

I'm trying to write a test using quickcheck for a simple lexer i've written. However, I seem to be falling foul of some sort of link error

I've building using cabal-dev

my .cabal file is building a library "mylib" The library section has under its exposed modules section Lexical.Token and under the test-suite I have "mylib" listed under build_depends, and I also have Lexical.token listed under other modules.

What am I missing? The error I get out of ghc (7.4.1) is as follows:

Couldn't match expected type `Token'
            with actual type `mylib-0.0.0.1:Lexical.Token.Token'
Expected type: [Token]
Actual type: [mylib-0.0.0.1:Lexical.Token.Token]
Was it helpful?

Solution

Cabal is conflicted over two locations for the "Lexical.Token" module. Confusingly, they're both the same file.

  1. It's resolving mylib-0.0.0.1 from your build-depends to the "locally installed and registered" version of mylib.
  2. It's resolving Lexical.Token in the source as an other-modules entry, something that should be exposed through your test suite.

Fix it be removing Lexical.Token from other-modules, I imagine. Your test suite should not share code with your tested code, but instead import all the modules as if your tested code were an external library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top