-
Notifications
You must be signed in to change notification settings - Fork 49
Rethrow Haskell exceptions #95
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
Conversation
- Removes instances Eq CppException, Ord CppException because those can not be implemented for the CppHaskellException SomeException constructor. - Currently requires significant boilerplate to actually throw a Haskell exception, but at least it can be done.
71981bb
to
18cdcb0
Compare
@roberth thanks for the contribution! However, it's not entirely clear to me what this is for. From the PR title I'd have expected it to be some code related to the handling of Haskell exceptions thrown in Haskell code being called by C++, but it seems to be about being able to explicitly throwing Haskell exceptions from C++. Can you clarify the kind of situations where this is useful? |
BTW, I've pushed a cleaned-up version of your branch to |
@bitonic Indeed it doesn't implement the "throwing" side of the feature. It currently needs a custom wrapper to achieve this. We're having some trouble building C++ projects on darwin like #64 so we can't really implement a generic solution for the wrappers / funPtr until that's solved. The reason we built this is because we need to propagate a specific exception that we throw to all |
I see. From a first review, these are the things to do to get it merged:
|
I don't think the Haskell code can know when to free the stable pointer. If the exception is caught in C++, Haskell will never see it again, causing a leak. I'll document how to use it. |
@roberth can't the Haskell code just unconditionally free the stable pointer once the C++ code has finished executing? In any case, if it must be from C++, explain why in a comment. |
e05e396
to
70d1825
Compare
This is for passing Haskell functions to C++ code that we don't control (technically passing a manually written wrapper to the C++ code, but that doesn't change anything). (This is now reflected in the inline doc on the |
Like with #83 (comment) , I got busy and I completely forgot about these two not-obvious PRs. I've now merged this and released it as |
This adds the ability to throw any Haskell exception from C++ code.
Eq CppException
,Ord CppException
because those cannot be implemented for the CppHaskellException SomeException
constructor.
exception, but at least it can be done.
Functions to make the throwing easier/automatic can be built on top of this.