haskell-servant / haskell-servant/servant
Indent/Style Servant APIs
- Dominant language
- Haskell
- Stars
- 2k
- Forks
- 427
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 5
Description
Sorry for the somewhat mondane topic :)
I find it hard to indent nicely Servant APIs...
I would like to indent the code so the API structure is visible, and also to align operations.
Any suggestion on style?
For example here is an extract of my API:
```
type AuthAPI =
"auth" :> (
"permissions" :> Header "Authorization" Token :> Get '[JSON] [Perm]
:<|> "token" :> ReqBody '[JSON] AuthBody :> Post '[PlainText] Token
)
-- * Sensors
type SensorsAPI = Flat (
"sensors" :> Header "Authorization" Token :> (
QueryParam "q" SensorsQuery :> QueryParam "limit" SensorsLimit :> QueryParam "offset" SensorsOffset :> Get '[JSON] [Sensor]
:<|> ReqBody '[JSON] Sensor :> PostNoContent '[JSON] NoContent
:<|> SensorAPI
))
type SensorAPI = Flat (
Capture "id" Text :> ( Get '[JSON] Sensor
:<|> DeleteNoContent '[JSON] NoContent
:<|> "name" :> ReqBody '[PlainText] SensorName :> PutNoContent '[JSON] NoContent
:<|> "location" :> ReqBody '[JSON] Location :> PutNoContent '[JSON] NoContent
:<|> "gateway_id" :> ReqBody '[PlainText] GatewayId :> PutNoContent '[JSON] NoContent
:<|> "visibility" :> ReqBody '[PlainText] Visibility :> PutNoContent '[JSON] NoContent
:<|> MeasurementsAPI
))
type MeasurementsAPI = (
Capture "measurements" Text :> ( Get '[JSON] [Measurement]
:<|> ReqBody '[JSON] Measurement :> PostNoContent '[JSON] NoContent
:<|> MeasurementAPI
))
type MesurementAPI = Flat (
Capture "id" Text :> ( Get '[JSON] Measurement
:<|> DeleteNoContent '[JSON] NoContent
:<|> "name" :> ReqBody '[PlainText] MeasName :> PutNoContent '[JSON] NoContent
))
```
But I don't find it very readable. Operations land on the far right, however as they are important it would be better to have them on the left. Furthermore it leave big holes.
Contributor guide
Assessment
This issue has not been assessed yet.