You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a bunch of places, we currently use format from Data.Text.Format to produce strings (e.g. for posting comments, but also log messages). This function is partial: if the format string doesn't have a matching amount of parameters, it fails with an error. Moreover, there's at least one non-obvious way this can happen: in a call like format "x = {}" (show x), the formatting parameters aren't understood as the single string show x, but all of its individual characters because of the infamous type String = [Char] design error. (The fix here is writing [show x] or Only (show x) instead.)
There's some possible alternatives:
Use good old-fashioned concatenation of Texts. More foolproof, but cumbersome to read and write, and in principle less efficient.
Use a more type-safe formatting library like formatting.
In case of logging: use a structured logging library instead of putting contextual data into strings.
In case of comments: introduce a sum type of possible comments, and format them centrally (using one of the aforementioned approaches). This has the added benefit of making tests more concise - no need to copy-paste & update similar strings everywhere.
The text was updated successfully, but these errors were encountered:
In a bunch of places, we currently use
format
fromData.Text.Format
to produce strings (e.g. for posting comments, but also log messages). This function is partial: if the format string doesn't have a matching amount of parameters, it fails with an error. Moreover, there's at least one non-obvious way this can happen: in a call likeformat "x = {}" (show x)
, the formatting parameters aren't understood as the single stringshow x
, but all of its individual characters because of the infamoustype String = [Char]
design error. (The fix here is writing[show x]
orOnly (show x)
instead.)There's some possible alternatives:
Text
s. More foolproof, but cumbersome to read and write, and in principle less efficient.formatting
.The text was updated successfully, but these errors were encountered: