kowainik / stan

🕵️ Haskell STatic ANalyser
https://kowainik.github.io/projects/stan
Mozilla Public License 2.0
565 stars 48 forks source link

Clarify solution wording for STAN-0208 #366

Open dpwiz opened 4 years ago

dpwiz commented 4 years ago

Possible solutions {Extra dependency} Switch to 'ByteString' from 'bytestring'

I get that Text.length is O(n), however applying the suggestion will yield incorrect results for characters wider than 1 byte (even assuming there's only UTF8). Basically, you can not get the length of the textual value by measuring it's memory footprint.

chshersh commented 4 years ago

Hi @dpwiz, all solutions are possible solutions. They are to inform developers about different ways to solve the problem, but then it is up to developers to decide how to fix the problem. If you work only with ASCII text, then replacing Text with ByteString is an entirely valid solution. If there's a Haskell library that provides constant-time size for characters and not bytes, with the interface similar to text, I'm happy to add it as a possible solution :slightly_smiling_face: But probably we can improve the wording of this solution to make it more clear when to apply it.

dpwiz commented 4 years ago

Technical correctness aside, reducing the whole Text domain to a tiny ASCII subset just feels... gross. Dishing such an advice in a world where people still can't spell their names proper even in 32-bit characters is adding an insult to their injury.

I think lack of suggestions is better than "consider switching to bytestring" and no wording can change the fact that ByteString is not for textual values. Let's not add to the "muh-uh, haskell has so many string types" trope and, please, don't go back to "text is whatever US had on their typewriters 50 years ago" bog.