Pattern synonym for empty bytestring
- Dominant language
- Haskell
- Stars
- 301
- Forks
- 144
- Avg merge
- 7d 22h
- Merged PRs (30d)
- 1
Description
It would occasionally be useful have a pattern synonym for the empty bytestring:
pattern Empty :: ByteString
pattern Empty <- (ByteString.null -> True)
where
Empty = ByteString.empty
This makes it possible to rewrite guards like:
| Just (a',extra) <- BC8.readInt a, BC8.null extra, a' >= 0 -> ...
to
| Just (a',Empty) <- BC8.readInt a, a' >= 0 -> ...
The second form is more clear, and it avoids leaving the `extra` binding in scope for an entire clause that doesn't need it. I've already written this synonym in a project at work, and it works well. What are the maintainers thoughts on including this in `bytestring` itself.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.