Adding more `HasCallStack` s
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reviewing the non-Generic vector modules, especially the VU.(!) example, and compare them with Data/Vector/Generic.hs where VG.(!) already carries HasCallStack. Use the provided stack-script examples to inspect whether caller frames appear for selected functions. Done means agreeing on the functions that should gain constraints and confirming the resulting traces, including the open question about head.
Written by the indexing model from the issue text.
Description
I suggest adding more HasCallStack constraints.
1. Missing HasCallStack constraints
Some functions in non- Generic modules are missing HasCallStack constraints.
Example: VU.(!)
VU.(!) does not have HasCallStack constraint and we don't get full trace:
Example
{- stack script --resolver lts-22.24 --package vector -}
import Data.Vector.Unboxed qualified as VU
main :: IO ()
main = do
let !_ = (VU.fromList [0 :: Int]) VU.! 42
return ()
The call stack does not contain VU.(!) call from main:
$ stack example-u.hs
example-u.hs: index out of bounds (42,1)
CallStack (from HasCallStack):
error, called at src/Data/Vector/Internal/Check.hs:103:12 in vector-0.13.1.0-Aqc2YUE1Egs5WmXVMbcJ5T:Data.Vector.Internal.Check
checkError, called at src/Data/Vector/Internal/Check.hs:109:17 in vector-0.13.1.0-Aqc2YUE1Egs5WmXVMbcJ5T:Data.Vector.Internal.Check
check, called at src/Data/Vector/Internal/Check.hs:122:5 in vector-0.13.1.0-Aqc2YUE1Egs5WmXVMbcJ5T:Data.Vector.Internal.Check
checkIndex, called at src/Data/Vector/Generic.hs:235:11 in vector-0.13.1.0-Aqc2YUE1Egs5WmXVMbcJ5T:Data.Vector.Generic
!, called at src/Data/Vector/Unboxed.hs:297:7 in vector-0.13.1.0-Aqc2YUE1Egs5WmXVMbcJ5T:Data.Vector.Unboxed
VG.(!) has HasCallStack constraint and we get a full trace:
Example
{- stack script --resolver lts-22.24 --package vector -}
import Data.Vector.Unboxed qualified as VU
+import Data.Vector.Generic qualified as VG
main :: IO ()
main = do
- let !_ = (VU.fromList [0 :: Int]) VU.! 42
+ let !_ = (VU.fromList [0 :: Int]) VG.! 42
return ()
The call stack contains VG.(!) call from main:
$ stack example-g.hs
example-g.hs: index out of bounds (42,1)
CallStack (from HasCallStack):
error, called at src/Data/Vector/Internal/Check.hs:103:12 in vector-0.13.1.0-Aqc2YUE1Egs5WmXVMbcJ5T:Data.Vector.Internal.Check
checkError, called at src/Data/Vector/Internal/Check.hs:109:17 in vector-0.13.1.0-Aqc2YUE1Egs5WmXVMbcJ5T:Data.Vector.Internal.Check
check, called at src/Data/Vector/Internal/Check.hs:122:5 in vector-0.13.1.0-Aqc2YUE1Egs5WmXVMbcJ5T:Data.Vector.Internal.Check
checkIndex, called at src/Data/Vector/Generic.hs:235:11 in vector-0.13.1.0-Aqc2YUE1Egs5WmXVMbcJ5T:Data.Vector.Generic
!, called at /home/tbm/dev/hs/tmp/example-g.hs:8:37 in main:Main
2. head and more
I personally like to add HasCallStack to anywhere possible.
For example, the head function does not have HasCallStack constraint. But the list's head function in base doesn't have it either. What do you think? Thank you.
- Dominant language
- Haskell
- Stars
- 401
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from haskell/vector
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
enhancement tricorder
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
zip-archive-0.5 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
commercialhaskell/stackage#8124 · 1 comment ·
-
chore
Difficulty 1/5 Under an hour Newbie friendliness 91/100
alunduil/alunduil-chezmoi#792 ·