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

Consider attaching CallStack to functions from Unsafe #222

Open
Martoon-00 opened this issue Apr 29, 2020 · 0 comments · May be fixed by #261
Open

Consider attaching CallStack to functions from Unsafe #222

Martoon-00 opened this issue Apr 29, 2020 · 0 comments · May be fixed by #261
Labels
type:breaking Breaking change (removal, renaming, semantic change, etc.)
Milestone

Comments

@Martoon-00
Copy link
Member

Martoon-00 commented Apr 29, 2020

For instance, have

-- | Extract the first element of a list, which must be non-empty.
head :: HasCallStack => [a] -> a
head = \case
  [] -> error "..."
  x : _ -> x

Motivation: Universum is primarily designed to be used in business logic, if someone needs advanced and lightweight manipulation with lists, he better import Data.List or some library with special data structures as Universum provides far not all possible useful functions anyway.

Pros:

  • Easer to debug.

Cons:

  • Error messages will differ.
  • Slightly less performant (carrying call stack has its costs, some rewrite rules will probably get lost).
  • Attempt to import head both from our Unsafe module and Data.List module simultaneously will now fail, though this is minor as Unsafe module should be imported qualified.
@Martoon-00 Martoon-00 added the type:breaking Breaking change (removal, renaming, semantic change, etc.) label Apr 29, 2020
@dcastro dcastro added this to the v1.8.0 milestone Apr 7, 2022
DK318 added a commit that referenced this issue Apr 16, 2022
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.
@DK318 DK318 linked a pull request Apr 16, 2022 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:breaking Breaking change (removal, renaming, semantic change, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants