haskell/primitive

Get rid of fromList in all Show instances

Closed this issue · 4 comments

I just noticed that fromListN is used in the Show instance for SmallArray. I'd like to get rid of this everywhere.

What do you intend to replace it with?

I guess the other option is to expect someone copying and pasting the output to use OverloadedLists.

Yes, I had the OverloadedLists syntax in mind. This is what vector and text do (well, text assumes OverloadedStrings) and the result is nicer for the user. I have unit tests in the http-interchange library that uses Show and pretty-show to create an expected output. Here is one of them:

Response
  { statusLine =
      StatusLine
        { versionMajor = 1
        , versionMinor = 1
        , statusCode = 400
        , statusReason = "Bad Request"
        }
  , headers =
      fromListN
        2
        [ Header { name = "Content-Type" , value = "application/json" }
        , Header { name = "Content-Length" , value = "100" }
        ]
  }

The way headers is rendered is needlessly tedious. If we change the Show instance, then it becomes more useful in this context.

SGTM