Exception Improvements and other changes #5

merged 5 commits into from Sep 8, 2011


None yet
2 participants

dagit commented Sep 8, 2011


Thanks for creating the OpenCLRaw bindings. They make an excellent starting point for me to experiment with OpenCL using Haskell. This is a pull request based on some improvements that I made. I realize that my "improvements" may not be seen as such by everyone, so allow me to justify them.

I tried using OpenCLRaw but I kept running into heavily nested exception checking like this:

case foo of
  Left err -> ...
  Right val -> ...

I talked the design over with a bunch of Haskell programmers at work and we came to the conclusion that throwing extensible exceptions would be the best approach for FFI wrappers such as this. Two guys commented that they tried the IO (Either Error a) style in the past and that switching it to extensible exceptions made coding easier and safer (with the exception style the API forces the check on the return code of each C function and the code is shorter with less emphasis on the exceptional/rare execution paths).

I started a branch to do the conversion and while I was at it I also cleaned up all the warnings, found a few typos (functions that weren't exported, calling the wrong C function inside the Haskell wrapper, cabal syntax tweaks, see the diffs for details).

I also noticed that in some cases I could remove explicit alloca/peek usages by adding the function fetchPtr. I probably haven't found all the places to start using it, but in the few places I did add it I think it simplifies things a bit. I also made the wrap* functions more general.

Are you still actively maintaining OpenCLRaw? If so, are you interested in the changes in my exceptions branch? If you're not actively maintaining it, would it be okay with you if I uploaded newer versions of the package to Hackage? I'm okay with uploading my changes as a different package, but my preference would be to reuse the existing OpenCLRaw name, assuming you are okay with that. If I don't hear from you within a few weeks I'll just upload my own OpenCLRaw based on your code base.

Thanks for writing this package, it makes it possible for me to learn OpenCL while sticking with my favorite host programming language (Haskell!).

Please let me know if you have any questions and I look forward to collaborating with you.

Thank you,

jeffersonheard added a commit that referenced this pull request Sep 8, 2011

Merge pull request #5 from dagit/exceptions
Exception Improvements and other changes

@jeffersonheard jeffersonheard merged commit 107f02a into jeffersonheard:master Sep 8, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment