-
Notifications
You must be signed in to change notification settings - Fork 7
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
refcount: define macro-constraint HasCallStackIfDebug
#495
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,9 +200,9 @@ class RefCounted obj where | |
getRefCounter :: obj -> RefCounter (FinaliserM obj) | ||
|
||
#ifdef NO_IGNORE_ASSERTS | ||
#define HAS_CALL_STACK => HasCallStack | ||
#define HasCallStackIfDebug HasCallStack | ||
#else | ||
#define HAS_CALL_STACK | ||
#define HasCallStackIfDebug () | ||
#endif | ||
|
||
-- GHC says specialising is too complicated! But it's ok, each of these can | ||
|
@@ -219,7 +219,7 @@ class RefCounted obj where | |
-- | ||
newRef :: | ||
(RefCounted obj, FinaliserM obj ~ m, PrimMonad m) | ||
HAS_CALL_STACK | ||
=> HasCallStackIfDebug | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason that this does not throw a warning? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the looks of it, GHC combines successive constraint arrows, so by the time it reaches the warning subsystem, |
||
=> m () | ||
-> (RefCounter m -> obj) | ||
-> m (Ref obj) | ||
|
@@ -234,7 +234,7 @@ newRef finaliser mkObject = do | |
-- | ||
releaseRef :: | ||
(RefCounted obj, FinaliserM obj ~ m, PrimMonad m, MonadMask m) | ||
HAS_CALL_STACK | ||
=> HasCallStackIfDebug | ||
=> Ref obj | ||
-> m () | ||
releaseRef ref@Ref{refobj} = do | ||
|
@@ -268,7 +268,7 @@ deRef ref@Ref{refobj} = | |
withRef :: | ||
forall m obj a. | ||
PrimMonad m | ||
HAS_CALL_STACK | ||
=> HasCallStackIfDebug | ||
=> Ref obj | ||
-> (obj -> m a) | ||
-> m a | ||
|
@@ -280,7 +280,7 @@ withRef ref@Ref{refobj} f = do | |
-- | ||
dupRef :: | ||
(RefCounted obj, FinaliserM obj ~ m, PrimMonad m) | ||
HAS_CALL_STACK | ||
=> HasCallStackIfDebug | ||
=> Ref obj | ||
-> m (Ref obj) | ||
dupRef ref@Ref{refobj} = do | ||
|
@@ -313,7 +313,7 @@ mkWeakRefFromRaw obj = WeakRef obj | |
-- | ||
deRefWeak :: | ||
(RefCounted obj, FinaliserM obj ~ m, PrimMonad m) | ||
HAS_CALL_STACK | ||
=> HasCallStackIfDebug | ||
=> WeakRef obj | ||
-> m (Maybe (Ref obj)) | ||
deRefWeak (WeakRef obj) = do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the all-caps macros because it makes it clear that it is not actual haskell syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you feel that with the all-caps name, this is an improvement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is, of course, the risk that this is highly dependent on what is arguably a GHC bug.