forked from ruuda/hoff
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels