-
Notifications
You must be signed in to change notification settings - Fork 162
Closed
Labels
Description
While reading some unrelated code I got distracted by this:
Lines 634 to 638 in 1be3f68
| -- | /O(1)/ Tests whether a 'Text' contains exactly one character. | |
| isSingleton :: Text -> Bool | |
| isSingleton (Text arr off len) = | |
| len == utf8LengthByLeader (A.unsafeIndex arr off) | |
| {-# INLINE isSingleton #-} |
(introduced in acf18b6)
Now it's currently only used in places where the input can never be zero length + it's not exported. I still see the risk that someone will use this without being aware of the unsafe nature at some point (or even worse, export it).
So maybe:
- rename this to
unsafeIsSingleton? - remove the Haddocks to emphasize that this is an internal function
- maybe even add a comment that states that the input must be non-zero length, but then again it's pretty obvious from the implementation, so maybe skip that