[Haskell-cafe] problem with happy and type identity

Richard Cobbe cobbe at ccs.neu.edu
Sun Feb 2 21:32:19 UTC 2014


I'm working on a small project that involves an Alex scanner and a Happy
parser, and I'm getting an error from the type-checker that I do not
understand.  Can anyone help shed some light on what's going on?

I'm running Haskell Platform 2013.2.0.0, on MacOS 10.8.5 with XCode 4.6.3.

I've reduced the problem to a very small example, which I've attached as a
tar file.  It's a cabal package, and it contains a library with some test
cases.

If I run "cabal configure && cabal build" then the library builds with no
problems whatsoever.

But if I run

    cabal clean && cabal configure --enable-tests && cabal build

then I get the following error message:

    RunTests.hs:16:27:
        Couldn't match expected type `sample-0.4:Ast.Entry'
                    with actual type `Entry'
        In the return type of a call of `Entry'
        In the second argument of `(~?=)', namely `Entry "mumble"'
        In the expression: parse "entry" ~?= Entry "mumble"

And this doesn't make any sense to me, because the two types are supposed
to be the same.

If I take Happy and Alex out of the picture by replacing the Parser module
with a hand-written parser, the error goes away.  This is hardly feasible
in the actual project, of course :-) so I'm hoping someone can shed some
light on what I'm doing wrong here.

Thanks!

Richard

(I apologize for the attachment, by the way, but since filesystem layout is
potentially important here, and since it's only slightly larger than 1K, I
figured it was the best way.  If there's a better way to do this in the
future (which doesn't assume I can throw it on the web somewhere), then I'd
love to hear about it.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample.tgz
Type: application/x-tar-gz
Size: 1106 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140202/1d10fcae/attachment.bin>


More information about the Haskell-Cafe mailing list