haskell-servant / haskell-servant/servant
show instance for Headers for debugging
- Dominant language
- Haskell
- Stars
- 2k
- Forks
- 427
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 5
Description
It would be great to have a `Show` instance for [`Headers`](https://hackage.haskell.org/package/servant-0.18.2/docs/Servant-API-ResponseHeaders.html#t: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`](https://hackage.haskell.org/package/servant-0.18.2/docs/Servant-API-ResponseHeaders.html#t:HList). It should probably look something like the following:
```haskell
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.
Contributor guide
Assessment
This issue has not been assessed yet.