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

    import GHC.TypeLits (KnownNat, natVal)
    import Network.HTTP.Types.Status

    -- | Retrieve a known or unknown Status from a KnownNat
    statusFromNat :: forall a proxy. KnownNat a => proxy a -> Status
    statusFromNat :: forall (a :: Nat) (proxy :: Nat -> Type).
    KnownNat a =>
    proxy a -> Status
    statusFromNat = Int -> Status
    forall a. Enum a => Int -> a
    toEnum (Int -> Status) -> (proxy a -> Int) -> proxy a -> Status
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Int
    forall a. Num a => Integer -> a
    fromInteger (Integer -> Int) -> (proxy a -> Integer) -> proxy a -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . proxy a -> Integer
    forall (n :: Nat) (proxy :: Nat -> Type).
    KnownNat n =>
    proxy n -> Integer
    natVal

    -- | 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 :: forall (proxy :: Nat -> Type). proxy 100 -> Status
    statusVal proxy 100
    _ = Status
    status100

    instance KnownStatus 101 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 101 -> Status
    statusVal proxy 101
    _ = Status
    status101

    instance KnownStatus 200 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 200 -> Status
    statusVal proxy 200
    _ = Status
    status200

    instance KnownStatus 201 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 201 -> Status
    statusVal proxy 201
    _ = Status
    status201

    instance KnownStatus 202 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 202 -> Status
    statusVal proxy 202
    _ = Status
    status202

    instance KnownStatus 203 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 203 -> Status
    statusVal proxy 203
    _ = Status
    status203

    instance KnownStatus 204 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 204 -> Status
    statusVal proxy 204
    _ = Status
    status204

    instance KnownStatus 205 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 205 -> Status
    statusVal proxy 205
    _ = Status
    status205

    instance KnownStatus 206 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 206 -> Status
    statusVal proxy 206
    _ = Status
    status206

    instance KnownStatus 300 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 300 -> Status
    statusVal proxy 300
    _ = Status
    status300

    instance KnownStatus 301 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 301 -> Status
    statusVal proxy 301
    _ = Status
    status301

    instance KnownStatus 302 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 302 -> Status
    statusVal proxy 302
    _ = Status
    status302

    instance KnownStatus 303 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 303 -> Status
    statusVal proxy 303
    _ = Status
    status303

    instance KnownStatus 304 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 304 -> Status
    statusVal proxy 304
    _ = Status
    status304

    instance KnownStatus 305 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 305 -> Status
    statusVal proxy 305
    _ = Status
    status305

    instance KnownStatus 307 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 307 -> Status
    statusVal proxy 307
    _ = Status
    status307

    instance KnownStatus 308 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 308 -> Status
    statusVal proxy 308
    _ = Status
    status308

    instance KnownStatus 400 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 400 -> Status
    statusVal proxy 400
    _ = Status
    status400

    instance KnownStatus 401 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 401 -> Status
    statusVal proxy 401
    _ = Status
    status401

    instance KnownStatus 402 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 402 -> Status
    statusVal proxy 402
    _ = Status
    status402

    instance KnownStatus 403 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 403 -> Status
    statusVal proxy 403
    _ = Status
    status403

    instance KnownStatus 404 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 404 -> Status
    statusVal proxy 404
    _ = Status
    status404

    instance KnownStatus 405 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 405 -> Status
    statusVal proxy 405
    _ = Status
    status405

    instance KnownStatus 406 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 406 -> Status
    statusVal proxy 406
    _ = Status
    status406

    instance KnownStatus 407 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 407 -> Status
    statusVal proxy 407
    _ = Status
    status407

    instance KnownStatus 408 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 408 -> Status
    statusVal proxy 408
    _ = Status
    status408

    instance KnownStatus 409 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 409 -> Status
    statusVal proxy 409
    _ = Status
    status409

    instance KnownStatus 410 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 410 -> Status
    statusVal proxy 410
    _ = Status
    status410

    instance KnownStatus 411 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 411 -> Status
    statusVal proxy 411
    _ = Status
    status411

    instance KnownStatus 412 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 412 -> Status
    statusVal proxy 412
    _ = Status
    status412

    instance KnownStatus 413 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 413 -> Status
    statusVal proxy 413
    _ = Status
    status413

    instance KnownStatus 414 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 414 -> Status
    statusVal proxy 414
    _ = Status
    status414

    instance KnownStatus 415 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 415 -> Status
    statusVal proxy 415
    _ = Status
    status415

    instance KnownStatus 416 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 416 -> Status
    statusVal proxy 416
    _ = Status
    status416

    instance KnownStatus 417 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 417 -> Status
    statusVal proxy 417
    _ = Status
    status417

    instance KnownStatus 418 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 418 -> Status
    statusVal proxy 418
    _ = Status
    status418

    instance KnownStatus 422 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 422 -> Status
    statusVal proxy 422
    _ = Status
    status422

    instance KnownStatus 426 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 426 -> Status
    statusVal proxy 426
    _ = Status
    status426

    instance KnownStatus 428 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 428 -> Status
    statusVal proxy 428
    _ = Status
    status428

    instance KnownStatus 429 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 429 -> Status
    statusVal proxy 429
    _ = Status
    status429

    instance KnownStatus 431 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 431 -> Status
    statusVal proxy 431
    _ = Status
    status431

    instance KnownStatus 500 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 500 -> Status
    statusVal proxy 500
    _ = Status
    status500

    instance KnownStatus 501 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 501 -> Status
    statusVal proxy 501
    _ = Status
    status501

    instance KnownStatus 502 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 502 -> Status
    statusVal proxy 502
    _ = Status
    status502

    instance KnownStatus 503 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 503 -> Status
    statusVal proxy 503
    _ = Status
    status503

    instance KnownStatus 504 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 504 -> Status
    statusVal proxy 504
    _ = Status
    status504

    instance KnownStatus 505 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 505 -> Status
    statusVal proxy 505
    _ = Status
    status505

    instance KnownStatus 511 where
      statusVal :: forall (proxy :: Nat -> Type). proxy 511 -> Status
    statusVal proxy 511
    _ = Status
    status511