Closed Bodigrim closed 4 years ago
I think you mean that the possible suggestion is questionable. There are no questions that Text.length
is running in linear time. We will improve the suggestion message in here.
Edit: added "running in linear time" due to the misinterpretation of my message.
There is no questions that
Text.length
is inefficient.
Could you please elaborate? Inefficiency is a relative characteristic, and it is a bit weird to claim that something is inefficient in the absense of a semantically-equivalent substitute. Are we calling every non-constant-time function inefficient just because there could (but does not) exist another package, which pre-evaluates this function and caches the result for immediate access?
The inspection says everything, and you have quoted it yourself in this issue. To clarify: Usage of 'length' for 'Text' that runs in linear time
.
It is not an obvious fact, and I am sure, not that many people know text
internals to say that length
could be a non-constant operation, especially for users coming from other languages, where this operation runs in constant time. The suggestion is here to point out this fact and let people think more carefully about their code.
If you don't want to see this particular inspection, there are several ways, described in the documentation, how you can turn it off. But, again, it could help some people to reason more about their code, and it is not fair to remove it just because some users are aware of this fact.
It is not an obvious fact, and I am sure, not that many people know
text
internals to say thatlength
could be a non-constant operation
This fact is plainly stated in haddocks for Data.Text.length
: http://hackage.haskell.org/package/text-1.2.4.0/docs/Data-Text.html#v:length. This is a rare case, when Haskell documentation is not that bad.
Again, it is possible to turn off inspections that you personally don't like and don't find useful for yourself :slightly_smiling_face: That is plainly stated in the docs.
It seems like the possible suggestion improvement is not the point of the issue at all. The point is in removing this particular inspection. As I already mentioned, this is not a healthy decision, and I don't see this happening without strong basis against the inspection (case when the inspection is harmful, that is not true in here).
I am closing this issue because this inspection is not going to be removed.
I'm probably missing something, but, putting everything else aside, it does not seem to be a valid suggestion:
ByteString
length counts bytes, whileText
length counts Unicode characters: