|
| 1 | +{-# LANGUAGE DataKinds #-} |
| 2 | +-- Flexible instances is necessary on GHC 8.4 and earlier |
| 3 | +{-# LANGUAGE FlexibleInstances #-} |
| 4 | +module Servant.API.Status where |
| 5 | + |
| 6 | +import Network.HTTP.Types.Status |
| 7 | +import GHC.TypeLits |
| 8 | + |
| 9 | +-- | Witness that a type-level natural number corresponds to a HTTP status code |
| 10 | +class KnownNat n => KnownStatus n where |
| 11 | + statusVal :: proxy n -> Status |
| 12 | + |
| 13 | +instance KnownStatus 100 where |
| 14 | + statusVal _ = status100 |
| 15 | + |
| 16 | +instance KnownStatus 101 where |
| 17 | + statusVal _ = status101 |
| 18 | + |
| 19 | +instance KnownStatus 200 where |
| 20 | + statusVal _ = status200 |
| 21 | + |
| 22 | +instance KnownStatus 201 where |
| 23 | + statusVal _ = status201 |
| 24 | + |
| 25 | +instance KnownStatus 202 where |
| 26 | + statusVal _ = status202 |
| 27 | + |
| 28 | +instance KnownStatus 203 where |
| 29 | + statusVal _ = status203 |
| 30 | + |
| 31 | +instance KnownStatus 204 where |
| 32 | + statusVal _ = status204 |
| 33 | + |
| 34 | +instance KnownStatus 205 where |
| 35 | + statusVal _ = status205 |
| 36 | + |
| 37 | +instance KnownStatus 206 where |
| 38 | + statusVal _ = status206 |
| 39 | + |
| 40 | +instance KnownStatus 300 where |
| 41 | + statusVal _ = status300 |
| 42 | + |
| 43 | +instance KnownStatus 301 where |
| 44 | + statusVal _ = status301 |
| 45 | + |
| 46 | +instance KnownStatus 302 where |
| 47 | + statusVal _ = status302 |
| 48 | + |
| 49 | +instance KnownStatus 303 where |
| 50 | + statusVal _ = status303 |
| 51 | + |
| 52 | +instance KnownStatus 304 where |
| 53 | + statusVal _ = status304 |
| 54 | + |
| 55 | +instance KnownStatus 305 where |
| 56 | + statusVal _ = status305 |
| 57 | + |
| 58 | +instance KnownStatus 307 where |
| 59 | + statusVal _ = status307 |
| 60 | + |
| 61 | +instance KnownStatus 308 where |
| 62 | + statusVal _ = status308 |
| 63 | + |
| 64 | +instance KnownStatus 400 where |
| 65 | + statusVal _ = status400 |
| 66 | + |
| 67 | +instance KnownStatus 401 where |
| 68 | + statusVal _ = status401 |
| 69 | + |
| 70 | +instance KnownStatus 402 where |
| 71 | + statusVal _ = status402 |
| 72 | + |
| 73 | +instance KnownStatus 403 where |
| 74 | + statusVal _ = status403 |
| 75 | + |
| 76 | +instance KnownStatus 404 where |
| 77 | + statusVal _ = status404 |
| 78 | + |
| 79 | +instance KnownStatus 405 where |
| 80 | + statusVal _ = status405 |
| 81 | + |
| 82 | +instance KnownStatus 406 where |
| 83 | + statusVal _ = status406 |
| 84 | + |
| 85 | +instance KnownStatus 407 where |
| 86 | + statusVal _ = status407 |
| 87 | + |
| 88 | +instance KnownStatus 408 where |
| 89 | + statusVal _ = status408 |
| 90 | + |
| 91 | +instance KnownStatus 409 where |
| 92 | + statusVal _ = status409 |
| 93 | + |
| 94 | +instance KnownStatus 410 where |
| 95 | + statusVal _ = status410 |
| 96 | + |
| 97 | +instance KnownStatus 411 where |
| 98 | + statusVal _ = status411 |
| 99 | + |
| 100 | +instance KnownStatus 412 where |
| 101 | + statusVal _ = status412 |
| 102 | + |
| 103 | +instance KnownStatus 413 where |
| 104 | + statusVal _ = status413 |
| 105 | + |
| 106 | +instance KnownStatus 414 where |
| 107 | + statusVal _ = status414 |
| 108 | + |
| 109 | +instance KnownStatus 415 where |
| 110 | + statusVal _ = status415 |
| 111 | + |
| 112 | +instance KnownStatus 416 where |
| 113 | + statusVal _ = status416 |
| 114 | + |
| 115 | +instance KnownStatus 417 where |
| 116 | + statusVal _ = status417 |
| 117 | + |
| 118 | +instance KnownStatus 418 where |
| 119 | + statusVal _ = status418 |
| 120 | + |
| 121 | +instance KnownStatus 422 where |
| 122 | + statusVal _ = status422 |
| 123 | + |
| 124 | +instance KnownStatus 426 where |
| 125 | + statusVal _ = status426 |
| 126 | + |
| 127 | +instance KnownStatus 428 where |
| 128 | + statusVal _ = status428 |
| 129 | + |
| 130 | +instance KnownStatus 429 where |
| 131 | + statusVal _ = status429 |
| 132 | + |
| 133 | +instance KnownStatus 431 where |
| 134 | + statusVal _ = status431 |
| 135 | + |
| 136 | +instance KnownStatus 500 where |
| 137 | + statusVal _ = status500 |
| 138 | + |
| 139 | +instance KnownStatus 501 where |
| 140 | + statusVal _ = status501 |
| 141 | + |
| 142 | +instance KnownStatus 502 where |
| 143 | + statusVal _ = status502 |
| 144 | + |
| 145 | +instance KnownStatus 503 where |
| 146 | + statusVal _ = status503 |
| 147 | + |
| 148 | +instance KnownStatus 504 where |
| 149 | + statusVal _ = status504 |
| 150 | + |
| 151 | +instance KnownStatus 505 where |
| 152 | + statusVal _ = status505 |
| 153 | + |
| 154 | +instance KnownStatus 511 where |
| 155 | + statusVal _ = status511 |
0 commit comments