haskell / primitive

This package provides various primitive memory-related operations.
Other
114 stars 58 forks source link

Get rid of fromList in all Show instances #388

Closed andrewthad closed 1 year ago

andrewthad commented 1 year ago

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

chessai commented 1 year ago

What do you intend to replace it with?

treeowl commented 1 year ago

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

andrewthad commented 1 year ago

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.

chessai commented 1 year ago

SGTM