haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
198 stars 50 forks source link

No parse when importing a module (with an import hook), which is using class hooks #155

Closed noughtmare closed 8 years ago

noughtmare commented 8 years ago

I have one file Types.chs with the code:

module Types where

data ExampleStruct
{#pointer *example_struct as exampleStructPtr -> exampleStruct#}
{#class exampleStructClass exampleStructPtr#}

data ChildStruct
{#pointer *child_struct as childStructPtr -> childStruct#}
{#class exampleStructClass => childStructClass childStructPtr#}

If I then import that file with {#import Types#} in a second file, c2hs gives me the error: "Prelude.read no parse".

ian-ross commented 8 years ago

@noughtmare Is this a real issue or not? I got an email comment from you saying that it wasn't, but that comment doesn't show up here, so I don't know if you deleted it... (If it is a real issue, I'll have a look at it on the weekend: I've blocked out some C2HS time for Sunday.)

noughtmare commented 8 years ago

Ah, yes I thought I had found the solution, but when I recompiled from scratch it didn't work anymore. So it is not fixed yet.

ian-ross commented 8 years ago

@noughtmare Thanks for confirming. I'll take a look on Sunday.

ian-ross commented 8 years ago

@noughtmare So, there was a bug in the handling of class definitions in CHS files imported into other files. However, you should probably also know that the example code you provided needs some changes to work, to do with language extensions needed for some of the instance definitions, and for lack of capitalisation on Haskell type names. You can see one working version in tests/bugs/issue-155/Types.chs.

noughtmare commented 8 years ago

Thank you!