Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with StablePtr #11

Open
W4RH4WK opened this issue Jun 28, 2017 · 1 comment
Open

Working with StablePtr #11

W4RH4WK opened this issue Jun 28, 2017 · 1 comment

Comments

@W4RH4WK
Copy link

W4RH4WK commented Jun 28, 2017

This package is great, it really makes working with structs over the FFI easier. In my use-case I want to put a StablePtr inside a struct and return the struct over the FFI. Unfortunately this does not work, as StablePtr a does not instantiate Generic. It results in the following error message if want to create an (orphan) instance.

instance CStorable (StablePtr a)
    /home/alex/allscale/insieme/code/analysis/src/cba/haskell/insieme-hat/src/Insieme/Adapter.hs:253:10: error:
        • No instance for (Generic (StablePtr a))
            arising from a use of ‘c-storable-deriving-0.1.2:Foreign.CStorable.TypeClass.$dmcPeek’
        • In the expression:
            c-storable-deriving-0.1.2:Foreign.CStorable.TypeClass.$dmcPeek
              @StablePtr a
          In an equation for ‘cPeek’:
              cPeek
                = c-storable-deriving-0.1.2:Foreign.CStorable.TypeClass.$dmcPeek
                    @StablePtr a
          In the instance declaration for ‘CStorable (StablePtr a)’

Since Ptr a is an instance of Generic I can cast the StablePtr Ctx.Context to Ptr () and us this as a workaround.

Do you have an idea how I could get a StablePtr into my struct?

@W4RH4WK
Copy link
Author

W4RH4WK commented Jun 28, 2017

Just saw your TODO note in the source file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant