servant icon indicating copy to clipboard operation
servant copied to clipboard

show instance for Headers for debugging

Open cdepillabout opened this issue 4 years ago • 1 comments

It would be great to have a Show instance for Headers.

I imagine this would generally be used during debugging while writing tests.

The only slightly difficult thing here would be writing the Show instance for HList. It should probably look something like the following:

instance Show (HList '[]) where
  show HNil = "HNil"

instance (Show x, Show (HList xs)) => Show (HList (Header h x ': xs)) where
  show (HCons responseHeader hlist) = "HCons (" <> show responseHeader <> ") (" <> show hlist <> ")"

(Although in practice, it should be written using showsPrec so that parenthesis are inserted correctly.)

If this would be accepted, I'd be happy to send a PR adding this.

cdepillabout avatar Mar 12 '21 04:03 cdepillabout

@cdepillabout Hey, sorry for the delay. I'd happily accept such a PR. :)

tchoutri avatar Jul 11 '24 16:07 tchoutri