{-# LANGUAGE DataKinds #-}
-- Flexible instances is necessary on GHC 8.4 and earlier
{-# LANGUAGE FlexibleInstances #-}
module Servant.API.Status where

import Network.HTTP.Types.Status
import GHC.TypeLits

-- | Witness that a type-level natural number corresponds to a HTTP status code
class KnownNat n => KnownStatus n where
  statusVal :: proxy n -> Status

instance KnownStatus 100 where
  statusVal :: proxy 100 -> Status
statusVal proxy 100
_ = Status
status100

instance KnownStatus 101 where
  statusVal :: proxy 101 -> Status
statusVal proxy 101
_ = Status
status101

instance KnownStatus 200 where
  statusVal :: proxy 200 -> Status
statusVal proxy 200
_ = Status
status200

instance KnownStatus 201 where
  statusVal :: proxy 201 -> Status
statusVal proxy 201
_ = Status
status201

instance KnownStatus 202 where
  statusVal :: proxy 202 -> Status
statusVal proxy 202
_ = Status
status202

instance KnownStatus 203 where
  statusVal :: proxy 203 -> Status
statusVal proxy 203
_ = Status
status203

instance KnownStatus 204 where
  statusVal :: proxy 204 -> Status
statusVal proxy 204
_ = Status
status204

instance KnownStatus 205 where
  statusVal :: proxy 205 -> Status
statusVal proxy 205
_ = Status
status205

instance KnownStatus 206 where
  statusVal :: proxy 206 -> Status
statusVal proxy 206
_ = Status
status206

instance KnownStatus 300 where
  statusVal :: proxy 300 -> Status
statusVal proxy 300
_ = Status
status300

instance KnownStatus 301 where
  statusVal :: proxy 301 -> Status
statusVal proxy 301
_ = Status
status301

instance KnownStatus 302 where
  statusVal :: proxy 302 -> Status
statusVal proxy 302
_ = Status
status302

instance KnownStatus 303 where
  statusVal :: proxy 303 -> Status
statusVal proxy 303
_ = Status
status303

instance KnownStatus 304 where
  statusVal :: proxy 304 -> Status
statusVal proxy 304
_ = Status
status304

instance KnownStatus 305 where
  statusVal :: proxy 305 -> Status
statusVal proxy 305
_ = Status
status305

instance KnownStatus 307 where
  statusVal :: proxy 307 -> Status
statusVal proxy 307
_ = Status
status307

instance KnownStatus 308 where
  statusVal :: proxy 308 -> Status
statusVal proxy 308
_ = Status
status308

instance KnownStatus 400 where
  statusVal :: proxy 400 -> Status
statusVal proxy 400
_ = Status
status400

instance KnownStatus 401 where
  statusVal :: proxy 401 -> Status
statusVal proxy 401
_ = Status
status401

instance KnownStatus 402 where
  statusVal :: proxy 402 -> Status
statusVal proxy 402
_ = Status
status402

instance KnownStatus 403 where
  statusVal :: proxy 403 -> Status
statusVal proxy 403
_ = Status
status403

instance KnownStatus 404 where
  statusVal :: proxy 404 -> Status
statusVal proxy 404
_ = Status
status404

instance KnownStatus 405 where
  statusVal :: proxy 405 -> Status
statusVal proxy 405
_ = Status
status405

instance KnownStatus 406 where
  statusVal :: proxy 406 -> Status
statusVal proxy 406
_ = Status
status406

instance KnownStatus 407 where
  statusVal :: proxy 407 -> Status
statusVal proxy 407
_ = Status
status407

instance KnownStatus 408 where
  statusVal :: proxy 408 -> Status
statusVal proxy 408
_ = Status
status408

instance KnownStatus 409 where
  statusVal :: proxy 409 -> Status
statusVal proxy 409
_ = Status
status409

instance KnownStatus 410 where
  statusVal :: proxy 410 -> Status
statusVal proxy 410
_ = Status
status410

instance KnownStatus 411 where
  statusVal :: proxy 411 -> Status
statusVal proxy 411
_ = Status
status411

instance KnownStatus 412 where
  statusVal :: proxy 412 -> Status
statusVal proxy 412
_ = Status
status412

instance KnownStatus 413 where
  statusVal :: proxy 413 -> Status
statusVal proxy 413
_ = Status
status413

instance KnownStatus 414 where
  statusVal :: proxy 414 -> Status
statusVal proxy 414
_ = Status
status414

instance KnownStatus 415 where
  statusVal :: proxy 415 -> Status
statusVal proxy 415
_ = Status
status415

instance KnownStatus 416 where
  statusVal :: proxy 416 -> Status
statusVal proxy 416
_ = Status
status416

instance KnownStatus 417 where
  statusVal :: proxy 417 -> Status
statusVal proxy 417
_ = Status
status417

instance KnownStatus 418 where
  statusVal :: proxy 418 -> Status
statusVal proxy 418
_ = Status
status418

instance KnownStatus 422 where
  statusVal :: proxy 422 -> Status
statusVal proxy 422
_ = Status
status422

instance KnownStatus 426 where
  statusVal :: proxy 426 -> Status
statusVal proxy 426
_ = Status
status426

instance KnownStatus 428 where
  statusVal :: proxy 428 -> Status
statusVal proxy 428
_ = Status
status428

instance KnownStatus 429 where
  statusVal :: proxy 429 -> Status
statusVal proxy 429
_ = Status
status429

instance KnownStatus 431 where
  statusVal :: proxy 431 -> Status
statusVal proxy 431
_ = Status
status431

instance KnownStatus 500 where
  statusVal :: proxy 500 -> Status
statusVal proxy 500
_ = Status
status500

instance KnownStatus 501 where
  statusVal :: proxy 501 -> Status
statusVal proxy 501
_ = Status
status501

instance KnownStatus 502 where
  statusVal :: proxy 502 -> Status
statusVal proxy 502
_ = Status
status502

instance KnownStatus 503 where
  statusVal :: proxy 503 -> Status
statusVal proxy 503
_ = Status
status503

instance KnownStatus 504 where
  statusVal :: proxy 504 -> Status
statusVal proxy 504
_ = Status
status504

instance KnownStatus 505 where
  statusVal :: proxy 505 -> Status
statusVal proxy 505
_ = Status
status505

instance KnownStatus 511 where
  statusVal :: proxy 511 -> Status
statusVal proxy 511
_ = Status
status511