-
Notifications
You must be signed in to change notification settings - Fork 28
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
[#222] CallStack
attach
#261
base: master
Are you sure you want to change the base?
Conversation
Problem: functions from `Universum.Unsafe` don't carry `CallStack`. Sometimes it is hard to debug when you don't have stack trace. Solution: attached `CallStack` to all functions from `Universum.Unsafe` by copying them from `base` and replacing `errorWithoutStackTrace` with `error` function.
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.
What if we define
head :: HasCallStack => [a] -> a
head = Prelude.head
?
(probably with INLINE
)
AFAIU the call stack will contain a reference to Universum.Unsafe
, which is what we want, and at the same time we won't have to copy-paste code from base
.
import Data.Maybe (fromJust) | ||
|
||
import Universum.Base (Int) | ||
( head |
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 see that all files use 7-space indentation for exports, let's keep it consistent throughout the repo and not change it.
I've looked through |
Ah, ok, I get it. Well, looks sad, it's something that wasn't considered in the issue description, I mean the fact of copy-paste wasn't mentioned in "Cons". |
That's a good point :/ Would you still say this is worth pursuing, despite the cons? Or do you think we shouldn't do this? |
I personally don't remember much suffering from lack of |
Fair, I didn't mention that this issue will require copy-paste. And the fact that we have to copy stuff like Though nevertheless, I think this change is important. Not having a callstack seems innocent until the moment when it actually fires, and then it would be extremely hard to debug given a large project. Imagine, I used Coming to think about it, I would consider 3 alternatives:
And 2nd option seems the worst here, because having an unsafe function without a callstack, if I understand it correctly, can be treated as an anti-pattern. We better enforce the user to use a safe function + explicit |
at n xs = xs !! n | ||
|
||
errorEmptyList :: HasCallStack => String -> a |
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.
Btw, written this way we will see at least two entries in each callstack - the one containing the target function (like head
) and the one with errorEmptyList
. I think there is no reason to include the latter, and probably freezeCallStack
will help here.
Though this is subject to discussion too.
Description
Problem
Functions from
Universum.Unsafe
don't carryCallStack
.Sometimes it is hard to debug when you don't have stack trace.
Solution
Attached
CallStack
to all functions fromUniversum.Unsafe
by copying them from
base
and replacingerrorWithoutStackTrace
witherror
function.Related issues(s)
✓ Checklist for your Pull Request
Ideally a PR has all of the checkmarks set.
If something in this list is irrelevant to your PR, you should still set this
checkmark indicating that you are sure it is dealt with (be that by irrelevance).
are inextricably linked. Otherwise I should open multiple PR's.
reference this issue. See also auto linking on
github.
Related changes (conditional)
Tests
silently reappearing again.
Documentation
I checked whether I should update the docs and did so if necessary:
Record your changes
and
Stylistic guide (mandatory)
My commit history is clean (only contains changes relating to my
issue/pull request and no reverted-my-earlier-commit changes) and commit
messages start with identifiers of related issues in square brackets.
Example:
[#42] Short commit description
If necessary both of these can be achieved even after the commits have been
made/pushed using rebase and squash.