From 96eacc3ba05b523cd1816fc38c3c041b867dc043 Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Mon, 2 Dec 2024 12:37:47 -0600 Subject: [PATCH] wip: typed headerss --- spago.lock | 49 ++ spago.yaml | 59 +- src/.Axon.Request.purs.kak.E6dWQg | 211 ++++++ src/Axon.Header.Typed.purs | 1045 +++++++++++++++++++++++++++++ src/Axon.Request.Method.purs | 22 +- src/Type.MIME.purs | 732 ++++++++++++++++++++ 6 files changed, 2078 insertions(+), 40 deletions(-) create mode 100644 src/.Axon.Request.purs.kak.E6dWQg create mode 100644 src/Axon.Header.Typed.purs create mode 100644 src/Type.MIME.purs diff --git a/spago.lock b/spago.lock index 0d2667c..409fc13 100644 --- a/spago.lock +++ b/spago.lock @@ -23,6 +23,9 @@ { "bifunctors": ">=6.0.0 <7.0.0" }, + { + "console": ">=6.1.0 <7.0.0" + }, { "control": ">=6.0.0 <7.0.0" }, @@ -65,6 +68,7 @@ { "ordered-collections": ">=3.2.0 <4.0.0" }, + "parsing", { "prelude": ">=6.0.1 <7.0.0" }, @@ -99,6 +103,7 @@ "arrays", "b64", "bifunctors", + "console", "const", "contravariant", "control", @@ -142,6 +147,7 @@ "ordered-collections", "orders", "parallel", + "parsing", "partial", "prelude", "profunctor", @@ -158,6 +164,7 @@ "type-equality", "typelevel-prelude", "unfoldable", + "unicode", "unsafe-coerce", "url-immutable", "variant", @@ -1642,6 +1649,38 @@ "transformers" ] }, + "parsing": { + "type": "registry", + "version": "10.2.0", + "integrity": "sha256-ZDIdMFAKkst57x6BVa1aUWJnS8smoZnXsZ339Aq1mPA=", + "dependencies": [ + "arrays", + "control", + "effect", + "either", + "enums", + "foldable-traversable", + "functions", + "identity", + "integers", + "lazy", + "lists", + "maybe", + "newtype", + "nullable", + "numbers", + "partial", + "prelude", + "st", + "strings", + "tailrec", + "transformers", + "tuples", + "unfoldable", + "unicode", + "unsafe-coerce" + ] + }, "partial": { "type": "registry", "version": "4.0.0", @@ -1922,6 +1961,16 @@ "tuples" ] }, + "unicode": { + "type": "registry", + "version": "6.0.0", + "integrity": "sha256-QJnTVZpmihEAUiMeYrfkusVoziJWp2hJsgi9bMQLue8=", + "dependencies": [ + "foldable-traversable", + "maybe", + "strings" + ] + }, "unsafe-coerce": { "type": "registry", "version": "6.0.0", diff --git a/spago.yaml b/spago.yaml index 39bb19e..b04defa 100644 --- a/spago.yaml +++ b/spago.yaml @@ -1,35 +1,36 @@ package: name: axon dependencies: - - aff: '>=8.0.0 <9.0.0' - - argonaut-codecs: '>=9.1.0 <10.0.0' - - argonaut-core: '>=7.0.0 <8.0.0' - - arraybuffer-types: '>=3.0.2 <4.0.0' - - arrays: '>=7.3.0 <8.0.0' - - bifunctors: '>=6.0.0 <7.0.0' - - console: '>=6.1.0 <7.0.0' - - control: '>=6.0.0 <7.0.0' - - effect: '>=4.0.0 <5.0.0' - - either: '>=6.1.0 <7.0.0' - - exceptions: '>=6.1.0 <7.0.0' - - ezfetch: '>=1.1.0 <2.0.0' - - foldable-traversable: '>=6.0.0 <7.0.0' - - integers: '>=6.0.0 <7.0.0' - - maybe: '>=6.0.0 <7.0.0' - - newtype: '>=5.0.0 <6.0.0' - - node-buffer: '>=9.0.0 <10.0.0' - - node-net: '>=5.1.0 <6.0.0' - - node-streams: '>=9.0.0 <10.0.0' - - nullable: '>=6.0.0 <7.0.0' - - ordered-collections: '>=3.2.0 <4.0.0' - - prelude: '>=6.0.1 <7.0.0' - - refs: '>=6.0.0 <7.0.0' - - strings: '>=6.0.1 <7.0.0' - - transformers: '>=6.1.0 <7.0.0' - - tuples: '>=7.0.0 <8.0.0' - - typelevel-prelude: '>=7.0.0 <8.0.0' - - url-immutable: '>=1.0.0 <2.0.0' - - web-streams: '>=4.0.0 <5.0.0' + - parsing + - aff: ">=8.0.0 <9.0.0" + - argonaut-codecs: ">=9.1.0 <10.0.0" + - argonaut-core: ">=7.0.0 <8.0.0" + - arraybuffer-types: ">=3.0.2 <4.0.0" + - arrays: ">=7.3.0 <8.0.0" + - bifunctors: ">=6.0.0 <7.0.0" + - console: ">=6.1.0 <7.0.0" + - control: ">=6.0.0 <7.0.0" + - effect: ">=4.0.0 <5.0.0" + - either: ">=6.1.0 <7.0.0" + - exceptions: ">=6.1.0 <7.0.0" + - ezfetch: ">=1.1.0 <2.0.0" + - foldable-traversable: ">=6.0.0 <7.0.0" + - integers: ">=6.0.0 <7.0.0" + - maybe: ">=6.0.0 <7.0.0" + - newtype: ">=5.0.0 <6.0.0" + - node-buffer: ">=9.0.0 <10.0.0" + - node-net: ">=5.1.0 <6.0.0" + - node-streams: ">=9.0.0 <10.0.0" + - nullable: ">=6.0.0 <7.0.0" + - ordered-collections: ">=3.2.0 <4.0.0" + - prelude: ">=6.0.1 <7.0.0" + - refs: ">=6.0.0 <7.0.0" + - strings: ">=6.0.1 <7.0.0" + - transformers: ">=6.1.0 <7.0.0" + - tuples: ">=7.0.0 <8.0.0" + - typelevel-prelude: ">=7.0.0 <8.0.0" + - url-immutable: ">=1.0.0 <2.0.0" + - web-streams: ">=4.0.0 <5.0.0" test: main: Test.Main dependencies: diff --git a/src/.Axon.Request.purs.kak.E6dWQg b/src/.Axon.Request.purs.kak.E6dWQg new file mode 100644 index 0000000..d9d9ac6 --- /dev/null +++ b/src/.Axon.Request.purs.kak.E6dWQg @@ -0,0 +1,211 @@ +module Axon.Request (Request, Body(..), BodyReadableError(..), BodyStringError(..), BodyJSONError(..), BodyBufferError(..), bodyReadable, bodyString, bodyJSON, bodyBuffer, headers, method, address, url, contentType, accept, contentLength, lookupHeader, make) where + +import Prelude + +import Axon.Request.Method (Method) +import Control.Monad.Error.Class (throwError, try) +import Control.Monad.Except (ExceptT(..), runExceptT) +import Control.Monad.Trans.Class (lift) +import Data.Argonaut.Core (Json) +import Data.Argonaut.Core (stringify) as JSON +import Data.Argonaut.Parser (jsonParser) as JSON +import Data.Bifunctor (lmap) +import Data.Either (Either) +import Data.FoldableWithIndex (foldlWithIndex) +import Data.Generic.Rep (class Generic) +import Data.Int as Int +import Data.MIME (MIME) +import Data.MIME as MIME +import Data.Map (Map) +import Data.Map as Map +import Data.Maybe (Maybe) +import Data.Show.Generic (genericShow) +import Data.String.Lower (StringLower) +import Data.String.Lower as String.Lower +import Data.URL (URL) +import Effect (Effect) +import Effect.Aff (Aff) +import Effect.Aff.Class (liftAff) +import Effect.Class (liftEffect) +import Effect.Exception (Error) +import Effect.Exception as Error +import Effect.Ref (Ref) as Effect +import Effect.Ref as Ref +import Node.Buffer (Buffer) +import Node.Buffer as Buffer +import Node.Encoding (Encoding(..)) +import Node.Net.Types (IPv4, IPv6, SocketAddress) +import Node.Stream as Stream +import Node.Stream.Aff as Stream.Aff + +data BodyReadableError + = BodyReadableErrorHasBeenConsumed + | BodyReadableErrorEmpty + +derive instance Generic BodyReadableError _ +derive instance Eq BodyReadableError +instance Show BodyReadableError where + show = genericShow + +data BodyBufferError + = BodyBufferErrorReadable BodyReadableError + | BodyBufferErrorReading Error + +derive instance Generic BodyBufferError _ +instance Eq BodyBufferError where + eq (BodyBufferErrorReadable a) (BodyBufferErrorReadable b) = a == b + eq (BodyBufferErrorReading a) (BodyBufferErrorReading b) = Error.message a == Error.message b + eq _ _ = false +instance Show BodyBufferError where + show = genericShow + +data BodyStringError + = BodyStringErrorBuffer BodyBufferError + | BodyStringErrorNotUTF8 + +derive instance Generic BodyStringError _ +derive instance Eq BodyStringError +instance Show BodyStringError where + show = genericShow + +data BodyJSONError + = BodyJSONErrorString BodyStringError + | BodyJSONErrorParsing String + +derive instance Generic BodyJSONError _ +derive instance Eq BodyJSONError +instance Show BodyJSONError where + show = genericShow + +data Body + = BodyEmpty + | BodyReadable (Stream.Readable ()) + | BodyReadableConsumed + | BodyCached Buffer + | BodyCachedString String + | BodyCachedJSON Json + +data Request = + Request + { headers :: Map StringLower String + , address :: Either (SocketAddress IPv4) (SocketAddress IPv6) + , url :: URL + , method :: Method + , bodyRef :: Effect.Ref Body + } + +make :: { headers :: Map String String + , address :: Either (SocketAddress IPv4) (SocketAddress IPv6) + , url :: URL + , method :: Method + , body :: Body + } -> Effect Request +make a = do + bodyRef <- Ref.new a.body + pure $ Request {bodyRef: bodyRef, headers: foldlWithIndex (\k m v -> Map.insert (String.Lower.fromString k) v m) Map.empty a.headers, address: a.address, url: a.url, method: a.method} + +headers :: Request -> Map StringLower String +headers (Request a) = a.headers + +lookupHeader :: String -> Request -> Maybe String +lookupHeader k (Request a) = Map.lookup (String.Lower.fromString k) a.headers + +contentType :: Request -> Maybe MIME +contentType = lookupHeader "content-type" >>> map MIME.fromString + +accept :: Request -> Maybe MIME +accept = lookupHeader "accept" >>> map MIME.fromString + +contentLength :: Request -> Maybe Int +contentLength = lookupHeader "content-length" >=> Int.fromString + +method :: Request -> Method +method (Request a) = a.method + +address :: Request -> Either (SocketAddress IPv4) (SocketAddress IPv6) +address (Request a) = a.address + +url :: Request -> URL +url (Request a) = a.url + +bodyReadable :: Request -> Effect (Either BodyReadableError (Stream.Readable ())) +bodyReadable (Request {bodyRef}) = runExceptT do + body <- liftEffect $ Ref.read bodyRef + case body of + BodyEmpty -> throwError BodyReadableErrorEmpty + BodyReadableConsumed -> throwError BodyReadableErrorHasBeenConsumed + BodyReadable r -> + Ref.write BodyReadableConsumed bodyRef $> r # lift + BodyCached buf -> Stream.readableFromBuffer buf # lift + BodyCachedString str -> Stream.readableFromString str UTF8 # lift + BodyCachedJSON json -> json # JSON.stringify # flip Buffer.fromString UTF8 >>= Stream.readableFromBuffer # lift + +bodyBuffer :: Request -> Aff (Either BodyBufferError Buffer) +bodyBuffer r@(Request {bodyRef}) = + let + stream = + bodyReadable r + # liftEffect + <#> lmap BodyBufferErrorReadable + # ExceptT + readAll s = + Stream.Aff.readAll s + # liftAff + # try + <#> lmap BodyBufferErrorReading + # ExceptT + >>= (liftEffect <<< Buffer.concat) + in + runExceptT do + body <- Ref.read bodyRef # liftEffect + case body of + BodyCached buf -> pure buf + BodyCachedString str -> Buffer.fromString str UTF8 # liftEffect + BodyCachedJSON json -> Buffer.fromString (JSON.stringify json) UTF8 # liftEffect + _ -> do + buf <- stream >>= readAll + Ref.write (BodyCached buf) bodyRef $> buf # liftEffect + +bodyString :: Request -> Aff (Either BodyStringError String) +bodyString r@(Request {bodyRef}) = + let + buf = + bodyBuffer r + <#> lmap BodyStringErrorBuffer + # ExceptT + bufString b = + Buffer.toString UTF8 b + # liftEffect + # try + <#> lmap (const BodyStringErrorNotUTF8) + # ExceptT + in + runExceptT do + body <- Ref.read bodyRef # liftEffect + case body of + BodyCachedString str -> pure str + BodyCachedJSON json -> JSON.stringify json # pure + _ -> do + str <- buf >>= bufString + Ref.write (BodyCachedString str) bodyRef $> str # liftEffect + +bodyJSON :: Request -> Aff (Either BodyJSONError Json) +bodyJSON r@(Request {bodyRef}) = + let + str = + bodyString r + <#> lmap BodyJSONErrorString + # ExceptT + parse s = + JSON.jsonParser s + # lmap BodyJSONErrorParsing + # pure + # ExceptT + in + runExceptT do + body <- Ref.read bodyRef # liftEffect + case body of + BodyCachedJSON j -> pure j + _ -> do + j <- str >>= parse + Ref.write (BodyCachedJSON j) bodyRef $> j # liftEffect diff --git a/src/Axon.Header.Typed.purs b/src/Axon.Header.Typed.purs new file mode 100644 index 0000000..10b3a16 --- /dev/null +++ b/src/Axon.Header.Typed.purs @@ -0,0 +1,1045 @@ +module Axon.Header.Typed where + +import Prelude + +import Axon.Request.Method (Method) +import Axon.Request.Method as Method +import Control.Alt ((<|>)) +import Data.Array as Array +import Data.Array.NonEmpty (NonEmptyArray) +import Data.Array.NonEmpty as Array.NonEmpty +import Data.Bifunctor (lmap) +import Data.DateTime (DateTime) +import Data.Either (Either(..)) +import Data.Either.Nested (type (\/)) +import Data.Either.Nested as Either.Nested +import Data.Int as Int +import Data.MIME as MIME +import Data.Map as Map +import Data.Maybe (Maybe(..), fromMaybe, isJust) +import Data.Newtype (class Newtype, unwrap, wrap) +import Data.String as String +import Data.String.Base64 as String.Base64 +import Data.String.CodeUnits as String.CodeUnit +import Data.String.Lower (StringLower) +import Data.String.Lower as String.Lower +import Data.String.Regex.Flags as Regex.Flags +import Data.Tuple (fst) +import Data.Tuple.Nested (type (/\), (/\)) +import Effect.Exception as Error +import Parsing (Parser) +import Parsing as Parse +import Parsing.Combinators as Parse.Combine +import Parsing.String as Parse.String +import Parsing.String.Basic as Parse.String.Basic +import Partial.Unsafe (unsafePartial) +import Prim.Row (class Nub, class Union) +import Record as Record +import Type.MIME as Type.MIME + +data Wildcard = Wildcard + +commas :: forall a. Parser String a -> Parser String (Array a) +commas p = Parse.Combine.sepBy p (Parse.String.Basic.whiteSpace <* Parse.String.string "," <* Parse.String.Basic.whiteSpace) <#> Array.fromFoldable + +commas1 :: forall a. Parser String a -> Parser String (NonEmptyArray a) +commas1 p = Parse.Combine.sepBy1 p (Parse.String.Basic.whiteSpace <* Parse.String.string "," <* Parse.String.Basic.whiteSpace) <#> Array.NonEmpty.fromFoldable1 + +wildcardParser :: Parser String Wildcard +wildcardParser = Parse.String.string "*" $> Wildcard + +mimeParser :: Parser String MIME.MIME +mimeParser = Parse.String.anyTill Parse.String.Basic.space <#> fst <#> MIME.fromString + +headerNameRegexParser :: Parser String String +headerNameRegexParser = unsafePartial $ (\(Right a) -> a) $ Parse.String.regex "[\\w-]+" Regex.Flags.noFlags + +headerNameParser :: Parser String StringLower +headerNameParser = headerNameRegexParser <#> String.Lower.fromString + +methodParser :: Parser String Method +methodParser = Parse.Combine.many Parse.String.Basic.alphaNum <#> Array.fromFoldable <#> String.CodeUnit.fromCharArray >>= (\a -> Parse.liftMaybe (const $ "invalid method " <> a) $ Method.fromString a) + +directiveParser :: Parser String (String /\ Maybe String) +directiveParser = + let + boundary = Parse.String.string ";" <|> Parse.String.string "," <|> (Parse.String.eof *> pure "") + kvParser = do + k /\ stop <- Parse.String.anyTill (Parse.String.string "=" <|> boundary) + when (stop /= "=") $ Parse.fail "" + v <- Parse.String.anyTill boundary <#> fst + pure $ String.trim k /\ Just (String.trim v) + kParser = Parse.String.anyTill boundary <#> fst <#> String.trim <#> (\k -> k /\ Nothing) + in + kvParser <|> kParser + +class TypedHeader a where + headerName :: String + headerValueParser :: Parser String a + headerValueEncode :: a -> String + +newtype Accept a = Accept a +derive instance Newtype (Accept a) _ + +data AccessControlAllowCredentials = AccessControlAllowCredentials + +newtype AccessControlAllowHeaders = AccessControlAllowHeaders (Wildcard \/ NonEmptyArray StringLower) +derive instance Newtype (AccessControlAllowHeaders) _ + +newtype AccessControlAllowMethods = AccessControlAllowMethods (Wildcard \/ NonEmptyArray Method) +derive instance Newtype (AccessControlAllowMethods) _ + +newtype AccessControlAllowOrigin = AccessControlAllowOrigin (Wildcard \/ String) +derive instance Newtype (AccessControlAllowOrigin) _ + +newtype AccessControlExposeHeaders = AccessControlExposeHeaders (Wildcard \/ Array StringLower) +derive instance Newtype (AccessControlExposeHeaders) _ + +newtype AccessControlMaxAge = AccessControlMaxAge Int +derive instance Newtype (AccessControlMaxAge) _ + +newtype AccessControlRequestHeaders = AccessControlRequestHeaders (NonEmptyArray StringLower) +derive instance Newtype (AccessControlRequestHeaders) _ + +newtype AccessControlRequestMethod = AccessControlRequestMethod Method +derive instance Newtype (AccessControlRequestMethod) _ + +newtype Age = Age Int +derive instance Newtype (Age) _ + +newtype Allow = Allow (NonEmptyArray Method) +derive instance Newtype (Allow) _ + +newtype AuthScheme = AuthScheme String +derive instance Newtype (AuthScheme) _ + +data Authorization = Authorization AuthScheme String + +newtype BearerAuth = BearerAuth String +derive instance Newtype (BearerAuth) _ + +newtype BasicAuth = BasicAuth {username :: String, password :: String} +derive instance Newtype (BasicAuth) _ + +newtype ByteRangeStart = ByteRangeStart Int +derive instance Newtype (ByteRangeStart) _ + +newtype ByteRangeEnd = ByteRangeEnd Int +derive instance Newtype (ByteRangeEnd) _ + +newtype ByteRangeLength = ByteRangeLength Int +derive instance Newtype (ByteRangeLength) _ + +type CacheControl' = + ( maxAge :: Maybe Int + , maxStale :: Maybe Int + , minFresh :: Maybe Int + , sMaxAge :: Maybe Int + , noCache :: Boolean + , noStore :: Boolean + , noTransform :: Boolean + , onlyIfCached :: Boolean + , mustRevalidate :: Boolean + , mustUnderstand :: Boolean + , proxyRevalidate :: Boolean + , private :: Boolean + , public :: Boolean + , immutable :: Boolean + , staleWhileRevalidate :: Boolean + , staleIfError :: Boolean + ) + +newtype CacheControl = CacheControl (Record CacheControl') +derive instance Newtype (CacheControl) _ + +data CloseConnection = CloseConnection + +newtype Connection = Connection (CloseConnection \/ NonEmptyArray StringLower) +derive instance Newtype (Connection) _ + +newtype ContentDisposition = ContentDisposition (ContentDispositionInline \/ ContentDispositionAttachment \/ ContentDispositionFormData) +derive instance Newtype (ContentDisposition) _ + +data ContentDispositionInline = ContentDispositionInline + +newtype ContentDispositionAttachment = ContentDispositionAttachment {filename :: Maybe {language :: Maybe String, encoding :: Maybe String, value :: String}} +derive instance Newtype (ContentDispositionAttachment) _ + +newtype ContentDispositionFormData = ContentDispositionFormData {filename :: Maybe String, name :: Maybe String} +derive instance Newtype (ContentDispositionFormData) _ + +newtype ContentEncoding = ContentEncoding (NonEmptyArray String) +derive instance Newtype (ContentEncoding) _ + +newtype ContentLength = ContentLength Int +derive instance Newtype (ContentLength) _ + +newtype ContentLocation = ContentLocation String +derive instance Newtype (ContentLocation) _ + +newtype ContentRange = ContentRange ((ByteRangeStart /\ ByteRangeEnd /\ ByteRangeLength) \/ (ByteRangeStart /\ ByteRangeEnd) \/ ByteRangeLength) +derive instance Newtype (ContentRange) _ + +newtype ContentType a = ContentType a +derive instance Newtype (ContentType a) _ + +newtype Cookie = Cookie String +derive instance Newtype (Cookie) _ + +newtype Date = Date DateTime +derive instance Newtype (Date) _ + +newtype ETag = ETag String +derive instance Newtype (ETag) _ + +data ExpectContinue = ExpectContinue +newtype Expires = Expires DateTime +derive instance Newtype (Expires) _ + +newtype Host = Host String +derive instance Newtype (Host) _ + +newtype IfMatch = IfMatch (Wildcard \/ NonEmptyArray MatchETag) +derive instance Newtype (IfMatch) _ + +newtype IfNoneMatch = IfNoneMatch (Wildcard \/ NonEmptyArray MatchETag) +derive instance Newtype (IfNoneMatch) _ + +newtype IfModifiedSince = IfModifiedSince DateTime +derive instance Newtype (IfModifiedSince) _ + +newtype IfRange = IfRange (DateTime \/ String) +derive instance Newtype (IfRange) _ + +newtype IfUnmodifiedSince = IfUnmodifiedSince DateTime +derive instance Newtype (IfUnmodifiedSince) _ + +newtype LastModified = LastModified DateTime +derive instance Newtype (LastModified) _ + +data MatchETag = MatchETag String | MatchETagWeak String + +newtype Origin = Origin String +derive instance Newtype (Origin) _ + +data ProxyAuthorization = ProxyAuthorization AuthScheme String + +type RangeSpecifier = ByteRangeStart \/ (ByteRangeStart /\ ByteRangeEnd) \/ ByteRangeLength + +newtype Range = Range (RangeSpecifier \/ Array RangeSpecifier) +derive instance Newtype (Range) _ + +newtype Referer = Referer String +derive instance Newtype (Referer) _ + +data ReferrerPolicy + = ReferrerPolicyNoReferrer + | ReferrerPolicyNoReferrerWhenDowngrade + | ReferrerPolicySameOrigin + | ReferrerPolicyOrigin + | ReferrerPolicyOriginWhenCrossOrigin + | ReferrerPolicyUnsafeURL + | ReferrerPolicyStrictOrigin + | ReferrerPolicyStrictOriginWhenCrossOrigin + +newtype RetryAfter = RetryAfter (DateTime \/ Int) +derive instance Newtype (RetryAfter) _ + +newtype SecWebsocketKey = SecWebsocketKey String +derive instance Newtype (SecWebsocketKey) _ + +newtype SecWebsocketAccept = SecWebsocketAccept SecWebsocketKey +derive instance Newtype (SecWebsocketAccept) _ + +newtype SecWebsocketVersion = SecWebsocketVersion (String \/ NonEmptyArray String) +derive instance Newtype (SecWebsocketVersion) _ + +newtype Server = Server String +derive instance Newtype (Server) _ + +newtype SetCookie = SetCookie String +derive instance Newtype (SetCookie) _ + +newtype StrictTransportSecurity = StrictTransportSecurity {maxAge :: Int, includeSubdomains :: Boolean, preload :: Boolean} +derive instance Newtype (StrictTransportSecurity) _ + +newtype TE = TE String +derive instance Newtype (TE) _ + +newtype TransferEncoding = TransferEncoding String +derive instance Newtype (TransferEncoding) _ + +newtype Upgrade = Upgrade (NonEmptyArray String) +derive instance Newtype (Upgrade) _ + +newtype UserAgent = UserAgent String +derive instance Newtype (UserAgent) _ + +newtype Vary = Vary (Wildcard \/ NonEmptyArray StringLower) +derive instance Newtype (Vary) _ + +cacheControlDefaults :: Record CacheControl' +cacheControlDefaults = + { maxAge: Nothing + , maxStale: Nothing + , minFresh: Nothing + , sMaxAge: Nothing + , noCache: false + , noStore: false + , noTransform: false + , onlyIfCached: false + , mustRevalidate: false + , mustUnderstand: false + , proxyRevalidate: false + , private: false + , public: false + , immutable: false + , staleWhileRevalidate: false + , staleIfError: false + } + +cacheControl :: forall missing r withDefaults. Nub withDefaults CacheControl' => Union r CacheControl' withDefaults => Union missing r CacheControl' => Record r -> CacheControl +cacheControl a = CacheControl $ Record.merge a cacheControlDefaults + +instance TypedHeader (Accept String) where + headerName = "Accept" + headerValueParser = Parse.String.rest <#> Accept + headerValueEncode = unwrap +instance TypedHeader (Accept MIME.MIME) where + headerName = "Accept" + headerValueParser = mimeParser <#> Accept + headerValueEncode = MIME.toString <<< unwrap +instance TypedHeader (Accept Type.MIME.Aac) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Aac)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Aac) +instance TypedHeader (Accept Type.MIME.Abw) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Abw)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Abw) +instance TypedHeader (Accept Type.MIME.Arc) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Arc)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Arc) +instance TypedHeader (Accept Type.MIME.Avif) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Avif)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Avif) +instance TypedHeader (Accept Type.MIME.Avi) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Avi)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Avi) +instance TypedHeader (Accept Type.MIME.Azw) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Azw)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Azw) +instance TypedHeader (Accept Type.MIME.Bin) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Bin)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Bin) +instance TypedHeader (Accept Type.MIME.Bmp) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Bmp)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Bmp) +instance TypedHeader (Accept Type.MIME.Bz) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Bz)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Bz) +instance TypedHeader (Accept Type.MIME.Bz2) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Bz2)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Bz2) +instance TypedHeader (Accept Type.MIME.Cda) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Cda)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Cda) +instance TypedHeader (Accept Type.MIME.Csh) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Csh)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Csh) +instance TypedHeader (Accept Type.MIME.Css) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Css)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Css) +instance TypedHeader (Accept Type.MIME.Csv) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Csv)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Csv) +instance TypedHeader (Accept Type.MIME.Doc) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Doc)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Doc) +instance TypedHeader (Accept Type.MIME.Docx) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Docx)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Docx) +instance TypedHeader (Accept Type.MIME.Eot) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Eot)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Eot) +instance TypedHeader (Accept Type.MIME.Epub) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Epub)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Epub) +instance TypedHeader (Accept Type.MIME.Gz) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Gz)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Gz) +instance TypedHeader (Accept Type.MIME.Gif) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Gif)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Gif) +instance TypedHeader (Accept Type.MIME.Html) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Html)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Html) +instance TypedHeader (Accept Type.MIME.Ico) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ico)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ico) +instance TypedHeader (Accept Type.MIME.Ics) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ics)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ics) +instance TypedHeader (Accept Type.MIME.Jar) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Jar)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Jar) +instance TypedHeader (Accept Type.MIME.Jpeg) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Jpeg)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Jpeg) +instance TypedHeader (Accept Type.MIME.Js) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Js)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Js) +instance TypedHeader (Accept Type.MIME.Json) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Json)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Json) +instance TypedHeader (Accept Type.MIME.Jsonld) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Jsonld)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Jsonld) +instance TypedHeader (Accept Type.MIME.Midi) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Midi)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Midi) +instance TypedHeader (Accept Type.MIME.Mjs) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Mjs)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Mjs) +instance TypedHeader (Accept Type.MIME.Mp3) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Mp3)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Mp3) +instance TypedHeader (Accept Type.MIME.Mp4) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Mp4)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Mp4) +instance TypedHeader (Accept Type.MIME.Mpeg) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Mpeg)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Mpeg) +instance TypedHeader (Accept Type.MIME.Mpkg) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Mpkg)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Mpkg) +instance TypedHeader (Accept Type.MIME.Odp) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Odp)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Odp) +instance TypedHeader (Accept Type.MIME.Ods) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ods)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ods) +instance TypedHeader (Accept Type.MIME.Odt) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Odt)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Odt) +instance TypedHeader (Accept Type.MIME.Oga) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Oga)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Oga) +instance TypedHeader (Accept Type.MIME.Ogv) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ogv)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ogv) +instance TypedHeader (Accept Type.MIME.Ogx) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ogx)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ogx) +instance TypedHeader (Accept Type.MIME.Opus) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Opus)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Opus) +instance TypedHeader (Accept Type.MIME.Otf) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Otf)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Otf) +instance TypedHeader (Accept Type.MIME.Png) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Png)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Png) +instance TypedHeader (Accept Type.MIME.Pdf) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Pdf)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Pdf) +instance TypedHeader (Accept Type.MIME.Php) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Php)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Php) +instance TypedHeader (Accept Type.MIME.Ppt) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ppt)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ppt) +instance TypedHeader (Accept Type.MIME.Pptx) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Pptx)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Pptx) +instance TypedHeader (Accept Type.MIME.Rar) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Rar)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Rar) +instance TypedHeader (Accept Type.MIME.Rtf) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Rtf)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Rtf) +instance TypedHeader (Accept Type.MIME.Sh) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Sh)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Sh) +instance TypedHeader (Accept Type.MIME.Svg) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Svg)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Svg) +instance TypedHeader (Accept Type.MIME.Tar) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Tar)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Tar) +instance TypedHeader (Accept Type.MIME.Tif) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Tif)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Tif) +instance TypedHeader (Accept Type.MIME.Ts) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ts)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ts) +instance TypedHeader (Accept Type.MIME.Ttf) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ttf)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ttf) +instance TypedHeader (Accept Type.MIME.Txt) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Txt)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Txt) +instance TypedHeader (Accept Type.MIME.Vsd) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Vsd)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Vsd) +instance TypedHeader (Accept Type.MIME.Wav) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Wav)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Wav) +instance TypedHeader (Accept Type.MIME.Weba) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Weba)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Weba) +instance TypedHeader (Accept Type.MIME.Webm) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Webm)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Webm) +instance TypedHeader (Accept Type.MIME.Webp) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Webp)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Webp) +instance TypedHeader (Accept Type.MIME.Woff) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Woff)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Woff) +instance TypedHeader (Accept Type.MIME.Woff2) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Woff2)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Woff2) +instance TypedHeader (Accept Type.MIME.Xhtml) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Xhtml)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Xhtml) +instance TypedHeader (Accept Type.MIME.Xls) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Xls)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Xls) +instance TypedHeader (Accept Type.MIME.Xlsx) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Xlsx)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Xlsx) +instance TypedHeader (Accept Type.MIME.Xml) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Xml)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Xml) +instance TypedHeader (Accept Type.MIME.Xul) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Xul)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Xul) +instance TypedHeader (Accept Type.MIME.Zip) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Zip)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Zip) +instance TypedHeader (Accept Type.MIME.Video3gp) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Video3gp)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Video3gp) +instance TypedHeader (Accept Type.MIME.Video3g2) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Video3g2)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Video3g2) +instance TypedHeader (Accept Type.MIME.Archive7z) where + headerName = "Accept" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Archive7z)) <<< Type.MIME.fromValue) <#> Accept + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Archive7z) + +instance TypedHeader (ContentType String) where + headerName = "Content-Type" + headerValueParser = Parse.String.rest <#> ContentType + headerValueEncode = unwrap +instance TypedHeader (ContentType MIME.MIME) where + headerName = "Content-Type" + headerValueParser = mimeParser <#> ContentType + headerValueEncode = MIME.toString <<< unwrap +instance TypedHeader (ContentType Type.MIME.Aac) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Aac)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Aac) +instance TypedHeader (ContentType Type.MIME.Abw) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Abw)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Abw) +instance TypedHeader (ContentType Type.MIME.Arc) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Arc)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Arc) +instance TypedHeader (ContentType Type.MIME.Avif) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Avif)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Avif) +instance TypedHeader (ContentType Type.MIME.Avi) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Avi)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Avi) +instance TypedHeader (ContentType Type.MIME.Azw) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Azw)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Azw) +instance TypedHeader (ContentType Type.MIME.Bin) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Bin)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Bin) +instance TypedHeader (ContentType Type.MIME.Bmp) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Bmp)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Bmp) +instance TypedHeader (ContentType Type.MIME.Bz) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Bz)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Bz) +instance TypedHeader (ContentType Type.MIME.Bz2) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Bz2)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Bz2) +instance TypedHeader (ContentType Type.MIME.Cda) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Cda)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Cda) +instance TypedHeader (ContentType Type.MIME.Csh) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Csh)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Csh) +instance TypedHeader (ContentType Type.MIME.Css) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Css)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Css) +instance TypedHeader (ContentType Type.MIME.Csv) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Csv)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Csv) +instance TypedHeader (ContentType Type.MIME.Doc) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Doc)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Doc) +instance TypedHeader (ContentType Type.MIME.Docx) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Docx)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Docx) +instance TypedHeader (ContentType Type.MIME.Eot) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Eot)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Eot) +instance TypedHeader (ContentType Type.MIME.Epub) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Epub)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Epub) +instance TypedHeader (ContentType Type.MIME.Gz) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Gz)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Gz) +instance TypedHeader (ContentType Type.MIME.Gif) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Gif)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Gif) +instance TypedHeader (ContentType Type.MIME.Html) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Html)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Html) +instance TypedHeader (ContentType Type.MIME.Ico) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ico)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ico) +instance TypedHeader (ContentType Type.MIME.Ics) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ics)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ics) +instance TypedHeader (ContentType Type.MIME.Jar) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Jar)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Jar) +instance TypedHeader (ContentType Type.MIME.Jpeg) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Jpeg)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Jpeg) +instance TypedHeader (ContentType Type.MIME.Js) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Js)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Js) +instance TypedHeader (ContentType Type.MIME.Json) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Json)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Json) +instance TypedHeader (ContentType Type.MIME.Jsonld) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Jsonld)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Jsonld) +instance TypedHeader (ContentType Type.MIME.Midi) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Midi)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Midi) +instance TypedHeader (ContentType Type.MIME.Mjs) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Mjs)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Mjs) +instance TypedHeader (ContentType Type.MIME.Mp3) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Mp3)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Mp3) +instance TypedHeader (ContentType Type.MIME.Mp4) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Mp4)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Mp4) +instance TypedHeader (ContentType Type.MIME.Mpeg) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Mpeg)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Mpeg) +instance TypedHeader (ContentType Type.MIME.Mpkg) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Mpkg)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Mpkg) +instance TypedHeader (ContentType Type.MIME.Odp) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Odp)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Odp) +instance TypedHeader (ContentType Type.MIME.Ods) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ods)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ods) +instance TypedHeader (ContentType Type.MIME.Odt) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Odt)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Odt) +instance TypedHeader (ContentType Type.MIME.Oga) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Oga)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Oga) +instance TypedHeader (ContentType Type.MIME.Ogv) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ogv)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ogv) +instance TypedHeader (ContentType Type.MIME.Ogx) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ogx)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ogx) +instance TypedHeader (ContentType Type.MIME.Opus) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Opus)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Opus) +instance TypedHeader (ContentType Type.MIME.Otf) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Otf)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Otf) +instance TypedHeader (ContentType Type.MIME.Png) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Png)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Png) +instance TypedHeader (ContentType Type.MIME.Pdf) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Pdf)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Pdf) +instance TypedHeader (ContentType Type.MIME.Php) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Php)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Php) +instance TypedHeader (ContentType Type.MIME.Ppt) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ppt)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ppt) +instance TypedHeader (ContentType Type.MIME.Pptx) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Pptx)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Pptx) +instance TypedHeader (ContentType Type.MIME.Rar) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Rar)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Rar) +instance TypedHeader (ContentType Type.MIME.Rtf) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Rtf)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Rtf) +instance TypedHeader (ContentType Type.MIME.Sh) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Sh)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Sh) +instance TypedHeader (ContentType Type.MIME.Svg) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Svg)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Svg) +instance TypedHeader (ContentType Type.MIME.Tar) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Tar)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Tar) +instance TypedHeader (ContentType Type.MIME.Tif) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Tif)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Tif) +instance TypedHeader (ContentType Type.MIME.Ts) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ts)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ts) +instance TypedHeader (ContentType Type.MIME.Ttf) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Ttf)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Ttf) +instance TypedHeader (ContentType Type.MIME.Txt) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Txt)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Txt) +instance TypedHeader (ContentType Type.MIME.Vsd) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Vsd)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Vsd) +instance TypedHeader (ContentType Type.MIME.Wav) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Wav)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Wav) +instance TypedHeader (ContentType Type.MIME.Weba) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Weba)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Weba) +instance TypedHeader (ContentType Type.MIME.Webm) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Webm)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Webm) +instance TypedHeader (ContentType Type.MIME.Webp) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Webp)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Webp) +instance TypedHeader (ContentType Type.MIME.Woff) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Woff)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Woff) +instance TypedHeader (ContentType Type.MIME.Woff2) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Woff2)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Woff2) +instance TypedHeader (ContentType Type.MIME.Xhtml) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Xhtml)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Xhtml) +instance TypedHeader (ContentType Type.MIME.Xls) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Xls)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Xls) +instance TypedHeader (ContentType Type.MIME.Xlsx) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Xlsx)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Xlsx) +instance TypedHeader (ContentType Type.MIME.Xml) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Xml)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Xml) +instance TypedHeader (ContentType Type.MIME.Xul) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Xul)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Xul) +instance TypedHeader (ContentType Type.MIME.Zip) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Zip)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Zip) +instance TypedHeader (ContentType Type.MIME.Video3gp) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Video3gp)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Video3gp) +instance TypedHeader (ContentType Type.MIME.Video3g2) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Video3g2)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Video3g2) +instance TypedHeader (ContentType Type.MIME.Archive7z) where + headerName = "Content-Type" + headerValueParser = mimeParser >>= (Parse.liftMaybe (const $ "expected " <> MIME.toString (Type.MIME.value @Type.MIME.Archive7z)) <<< Type.MIME.fromValue) <#> ContentType + headerValueEncode _ = MIME.toString (Type.MIME.value @Type.MIME.Archive7z) + +instance TypedHeader AccessControlAllowCredentials where + headerName = "Access-Control-Allow-Credentials" + headerValueParser = Parse.String.string "true" $> AccessControlAllowCredentials + headerValueEncode _ = "true" + +instance TypedHeader AccessControlAllowHeaders where + headerName = "Access-Control-Allow-Headers" + headerValueParser = + let + headers = commas1 headerNameParser <#> Right <#> AccessControlAllowHeaders + in + (wildcardParser $> AccessControlAllowHeaders (Left Wildcard)) <|> headers + headerValueEncode (AccessControlAllowHeaders (Left Wildcard)) = "*" + headerValueEncode (AccessControlAllowHeaders (Right hs)) = hs <#> String.Lower.toString # Array.NonEmpty.intercalate ", " + +instance TypedHeader AccessControlAllowMethods where + headerName = "Access-Control-Allow-Methods" + headerValueParser = + let + methods = commas1 methodParser <#> Right <#> AccessControlAllowMethods + in + (wildcardParser $> AccessControlAllowMethods (Left Wildcard)) <|> methods + headerValueEncode (AccessControlAllowMethods (Left Wildcard)) = "*" + headerValueEncode (AccessControlAllowMethods (Right ms)) = ms <#> Method.toString # Array.NonEmpty.intercalate ", " + +instance TypedHeader AccessControlAllowOrigin where + headerName = "Access-Control-Allow-Origin" + headerValueParser = + let + str = Parse.String.rest <#> Right <#> AccessControlAllowOrigin + in + (wildcardParser $> AccessControlAllowOrigin (Left Wildcard)) <|> str + headerValueEncode (AccessControlAllowOrigin (Left Wildcard)) = "*" + headerValueEncode (AccessControlAllowOrigin (Right a)) = a + +instance TypedHeader AccessControlExposeHeaders where + headerName = "Access-Control-Expose-Headers" + headerValueParser = + let + str = commas headerNameParser <#> Right <#> AccessControlExposeHeaders + in + (wildcardParser $> AccessControlExposeHeaders (Left Wildcard)) <|> str + headerValueEncode (AccessControlExposeHeaders (Left Wildcard)) = "*" + headerValueEncode (AccessControlExposeHeaders (Right hs)) = hs <#> String.Lower.toString # Array.intercalate ", " + +instance TypedHeader AccessControlMaxAge where + headerName = "Access-Control-Max-Age" + headerValueParser = Parse.String.Basic.intDecimal <#> AccessControlMaxAge + headerValueEncode (AccessControlMaxAge i) = Int.toStringAs Int.decimal i + +instance TypedHeader AccessControlRequestHeaders where + headerName = "Access-Control-Request-Headers" + headerValueParser = commas1 headerNameParser <#> AccessControlRequestHeaders + headerValueEncode (AccessControlRequestHeaders hs) = hs <#> String.Lower.toString # Array.NonEmpty.intercalate ", " + +instance TypedHeader AccessControlRequestMethod where + headerName = "Access-Control-Request-Method" + headerValueParser = methodParser <#> AccessControlRequestMethod + headerValueEncode (AccessControlRequestMethod m) = Method.toString m + +instance TypedHeader Age where + headerName = "Age" + headerValueParser = Parse.String.Basic.intDecimal <#> Age + headerValueEncode (Age i) = Int.toStringAs Int.decimal i + +instance TypedHeader Allow where + headerName = "Allow" + headerValueParser = commas1 methodParser <#> Allow + headerValueEncode (Allow ms) = ms <#> Method.toString # Array.NonEmpty.intercalate ", " + +instance TypedHeader Authorization where + headerName = "Authorization" + headerValueParser = + let + scheme = (Parse.String.anyTill (Parse.String.Basic.space) <#> fst <#> AuthScheme) + in + pure Authorization <*> scheme <*> (Parse.String.rest <#> String.trim) + headerValueEncode (Authorization (AuthScheme s) v) = s <> " " <> v + +instance TypedHeader BasicAuth where + headerName = "Authorization" + headerValueParser = do + Authorization (AuthScheme s) v <- headerValueParser @Authorization + when (String.toLower s /= "basic") $ Parse.fail $ "expected Authorization scheme to be Basic, found " <> s + decoded <- String.Base64.decode v # lmap Error.message # Parse.liftEither + case String.split (wrap ":") decoded of + [username, password] -> pure $ BasicAuth {username, password} + _ -> Parse.fail "malformed Basic Auth" + headerValueEncode (BasicAuth {username, password}) = + headerValueEncode $ Authorization (AuthScheme "Basic") (String.Base64.encode (username <> ":" <> password)) + +instance TypedHeader BearerAuth where + headerName = "Authorization" + headerValueParser = do + Authorization (AuthScheme s) v <- headerValueParser @Authorization + when (String.toLower s /= "basic") $ Parse.fail $ "expected Authorization scheme to be Bearer, found " <> s + pure $ BearerAuth v + headerValueEncode (BearerAuth a) = + headerValueEncode $ Authorization (AuthScheme "Bearer") a + +instance TypedHeader CacheControl where + headerName = "Cache-Control" + headerValueParser = do + directives <- commas1 directiveParser <#> Map.fromFoldable + pure $ CacheControl + { maxAge: Map.lookup "max-age" directives # join >>= Int.fromString + , maxStale: Map.lookup "max-stale" directives # join >>= Int.fromString + , minFresh: Map.lookup "min-fresh" directives # join >>= Int.fromString + , sMaxAge: Map.lookup "s-maxage" directives # join >>= Int.fromString + , noCache: Map.lookup "no-cache" directives # isJust + , noStore: Map.lookup "no-store" directives # isJust + , noTransform: Map.lookup "no-transform" directives # isJust + , onlyIfCached: Map.lookup "only-if-cached" directives # isJust + , mustRevalidate: Map.lookup "must-revalidate" directives # isJust + , mustUnderstand: Map.lookup "must-understand" directives # isJust + , proxyRevalidate: Map.lookup "proxy-revalidate" directives # isJust + , private: Map.lookup "private" directives # isJust + , public: Map.lookup "public" directives # isJust + , immutable: Map.lookup "immutable" directives # isJust + , staleWhileRevalidate: Map.lookup "stale-while-revalidate" directives # isJust + , staleIfError: Map.lookup "stale-if-error" directives # isJust + } + headerValueEncode (CacheControl a) = + let + flag v k + | v = Just k + | otherwise = Nothing + int (Just i) k = Just (k <> "=" <> Int.toStringAs Int.decimal i) + int Nothing _ = Nothing + in + Array.intercalate ", " $ Array.catMaybes + [ int a.maxAge "max-age" + , int a.maxStale "max-stale" + , int a.minFresh "min-fresh" + , int a.sMaxAge "s-maxage" + , flag a.noCache "no-cache" + , flag a.noStore "no-store" + , flag a.noTransform "no-transform" + , flag a.onlyIfCached "only-if-cached" + , flag a.mustRevalidate "must-revalidate" + , flag a.mustUnderstand "must-understand" + , flag a.proxyRevalidate "proxy-revalidate" + , flag a.private "private" + , flag a.public "public" + , flag a.immutable "immutable" + , flag a.staleWhileRevalidate "stale-while-revalidate" + , flag a.staleIfError "stale-if-error" + ] diff --git a/src/Axon.Request.Method.purs b/src/Axon.Request.Method.purs index 60509a4..29a5c79 100644 --- a/src/Axon.Request.Method.purs +++ b/src/Axon.Request.Method.purs @@ -14,18 +14,18 @@ derive instance Eq Method instance Show Method where show = genericShow -methodToString :: Method -> String -methodToString GET = "GET" -methodToString POST = "POST" -methodToString PUT = "PUT" -methodToString PATCH = "PATCH" -methodToString DELETE = "DELETE" -methodToString OPTIONS = "OPTIONS" -methodToString TRACE = "TRACE" -methodToString CONNECT = "CONNECT" +toString :: Method -> String +toString GET = "GET" +toString POST = "POST" +toString PUT = "PUT" +toString PATCH = "PATCH" +toString DELETE = "DELETE" +toString OPTIONS = "OPTIONS" +toString TRACE = "TRACE" +toString CONNECT = "CONNECT" -methodFromString :: String -> Maybe Method -methodFromString = +fromString :: String -> Maybe Method +fromString = let go "GET" = Just GET go "POST" = Just POST diff --git a/src/Type.MIME.purs b/src/Type.MIME.purs new file mode 100644 index 0000000..b4cba8f --- /dev/null +++ b/src/Type.MIME.purs @@ -0,0 +1,732 @@ +module Type.MIME where + +import Prelude + +import Data.Generic.Rep (class Generic) +import Data.MIME as MIME +import Data.Maybe (Maybe(..)) +import Data.Show.Generic (genericShow) + +class TypelevelMIME a where + fromValue :: MIME.MIME -> Maybe a + value :: MIME.MIME + +data Aac = Aac +derive instance Generic Aac _ +derive instance Eq Aac +instance Show Aac where + show = genericShow +instance TypelevelMIME Aac where + fromValue MIME.Aac = Just Aac + fromValue _ = Nothing + value = MIME.Aac + +data Abw = Abw +derive instance Generic Abw _ +derive instance Eq Abw +instance Show Abw where + show = genericShow +instance TypelevelMIME Abw where + fromValue MIME.Abw = Just Abw + fromValue _ = Nothing + value = MIME.Abw + +data Arc = Arc +derive instance Generic Arc _ +derive instance Eq Arc +instance Show Arc where + show = genericShow +instance TypelevelMIME Arc where + fromValue MIME.Arc = Just Arc + fromValue _ = Nothing + value = MIME.Arc + +data Avif = Avif +derive instance Generic Avif _ +derive instance Eq Avif +instance Show Avif where + show = genericShow +instance TypelevelMIME Avif where + fromValue MIME.Avif = Just Avif + fromValue _ = Nothing + value = MIME.Avif + +data Avi = Avi +derive instance Generic Avi _ +derive instance Eq Avi +instance Show Avi where + show = genericShow +instance TypelevelMIME Avi where + fromValue MIME.Avi = Just Avi + fromValue _ = Nothing + value = MIME.Avi + +data Azw = Azw +derive instance Generic Azw _ +derive instance Eq Azw +instance Show Azw where + show = genericShow +instance TypelevelMIME Azw where + fromValue MIME.Azw = Just Azw + fromValue _ = Nothing + value = MIME.Azw + +data Bin = Bin +derive instance Generic Bin _ +derive instance Eq Bin +instance Show Bin where + show = genericShow +instance TypelevelMIME Bin where + fromValue MIME.Bin = Just Bin + fromValue _ = Nothing + value = MIME.Bin + +data Bmp = Bmp +derive instance Generic Bmp _ +derive instance Eq Bmp +instance Show Bmp where + show = genericShow +instance TypelevelMIME Bmp where + fromValue MIME.Bmp = Just Bmp + fromValue _ = Nothing + value = MIME.Bmp + +data Bz = Bz +derive instance Generic Bz _ +derive instance Eq Bz +instance Show Bz where + show = genericShow +instance TypelevelMIME Bz where + fromValue MIME.Bz = Just Bz + fromValue _ = Nothing + value = MIME.Bz + +data Bz2 = Bz2 +derive instance Generic Bz2 _ +derive instance Eq Bz2 +instance Show Bz2 where + show = genericShow +instance TypelevelMIME Bz2 where + fromValue MIME.Bz2 = Just Bz2 + fromValue _ = Nothing + value = MIME.Bz2 + +data Cda = Cda +derive instance Generic Cda _ +derive instance Eq Cda +instance Show Cda where + show = genericShow +instance TypelevelMIME Cda where + fromValue MIME.Cda = Just Cda + fromValue _ = Nothing + value = MIME.Cda + +data Csh = Csh +derive instance Generic Csh _ +derive instance Eq Csh +instance Show Csh where + show = genericShow +instance TypelevelMIME Csh where + fromValue MIME.Csh = Just Csh + fromValue _ = Nothing + value = MIME.Csh + +data Css = Css +derive instance Generic Css _ +derive instance Eq Css +instance Show Css where + show = genericShow +instance TypelevelMIME Css where + fromValue MIME.Css = Just Css + fromValue _ = Nothing + value = MIME.Css + +data Csv = Csv +derive instance Generic Csv _ +derive instance Eq Csv +instance Show Csv where + show = genericShow +instance TypelevelMIME Csv where + fromValue MIME.Csv = Just Csv + fromValue _ = Nothing + value = MIME.Csv + +data Doc = Doc +derive instance Generic Doc _ +derive instance Eq Doc +instance Show Doc where + show = genericShow +instance TypelevelMIME Doc where + fromValue MIME.Doc = Just Doc + fromValue _ = Nothing + value = MIME.Doc + +data Docx = Docx +derive instance Generic Docx _ +derive instance Eq Docx +instance Show Docx where + show = genericShow +instance TypelevelMIME Docx where + fromValue MIME.Docx = Just Docx + fromValue _ = Nothing + value = MIME.Docx + +data Eot = Eot +derive instance Generic Eot _ +derive instance Eq Eot +instance Show Eot where + show = genericShow +instance TypelevelMIME Eot where + fromValue MIME.Eot = Just Eot + fromValue _ = Nothing + value = MIME.Eot + +data Epub = Epub +derive instance Generic Epub _ +derive instance Eq Epub +instance Show Epub where + show = genericShow +instance TypelevelMIME Epub where + fromValue MIME.Epub = Just Epub + fromValue _ = Nothing + value = MIME.Epub + +data Gz = Gz +derive instance Generic Gz _ +derive instance Eq Gz +instance Show Gz where + show = genericShow +instance TypelevelMIME Gz where + fromValue MIME.Gz = Just Gz + fromValue _ = Nothing + value = MIME.Gz + +data Gif = Gif +derive instance Generic Gif _ +derive instance Eq Gif +instance Show Gif where + show = genericShow +instance TypelevelMIME Gif where + fromValue MIME.Gif = Just Gif + fromValue _ = Nothing + value = MIME.Gif + +data Html = Html +derive instance Generic Html _ +derive instance Eq Html +instance Show Html where + show = genericShow +instance TypelevelMIME Html where + fromValue MIME.Html = Just Html + fromValue _ = Nothing + value = MIME.Html + +data Ico = Ico +derive instance Generic Ico _ +derive instance Eq Ico +instance Show Ico where + show = genericShow +instance TypelevelMIME Ico where + fromValue MIME.Ico = Just Ico + fromValue _ = Nothing + value = MIME.Ico + +data Ics = Ics +derive instance Generic Ics _ +derive instance Eq Ics +instance Show Ics where + show = genericShow +instance TypelevelMIME Ics where + fromValue MIME.Ics = Just Ics + fromValue _ = Nothing + value = MIME.Ics + +data Jar = Jar +derive instance Generic Jar _ +derive instance Eq Jar +instance Show Jar where + show = genericShow +instance TypelevelMIME Jar where + fromValue MIME.Jar = Just Jar + fromValue _ = Nothing + value = MIME.Jar + +data Jpeg = Jpeg +derive instance Generic Jpeg _ +derive instance Eq Jpeg +instance Show Jpeg where + show = genericShow +instance TypelevelMIME Jpeg where + fromValue MIME.Jpeg = Just Jpeg + fromValue _ = Nothing + value = MIME.Jpeg + +data Js = Js +derive instance Generic Js _ +derive instance Eq Js +instance Show Js where + show = genericShow +instance TypelevelMIME Js where + fromValue MIME.Js = Just Js + fromValue _ = Nothing + value = MIME.Js + +data Json = Json +derive instance Generic Json _ +derive instance Eq Json +instance Show Json where + show = genericShow +instance TypelevelMIME Json where + fromValue MIME.Json = Just Json + fromValue _ = Nothing + value = MIME.Json + +data Jsonld = Jsonld +derive instance Generic Jsonld _ +derive instance Eq Jsonld +instance Show Jsonld where + show = genericShow +instance TypelevelMIME Jsonld where + fromValue MIME.Jsonld = Just Jsonld + fromValue _ = Nothing + value = MIME.Jsonld + +data Midi = Midi +derive instance Generic Midi _ +derive instance Eq Midi +instance Show Midi where + show = genericShow +instance TypelevelMIME Midi where + fromValue MIME.Midi = Just Midi + fromValue _ = Nothing + value = MIME.Midi + +data Mjs = Mjs +derive instance Generic Mjs _ +derive instance Eq Mjs +instance Show Mjs where + show = genericShow +instance TypelevelMIME Mjs where + fromValue MIME.Mjs = Just Mjs + fromValue _ = Nothing + value = MIME.Mjs + +data Mp3 = Mp3 +derive instance Generic Mp3 _ +derive instance Eq Mp3 +instance Show Mp3 where + show = genericShow +instance TypelevelMIME Mp3 where + fromValue MIME.Mp3 = Just Mp3 + fromValue _ = Nothing + value = MIME.Mp3 + +data Mp4 = Mp4 +derive instance Generic Mp4 _ +derive instance Eq Mp4 +instance Show Mp4 where + show = genericShow +instance TypelevelMIME Mp4 where + fromValue MIME.Mp4 = Just Mp4 + fromValue _ = Nothing + value = MIME.Mp4 + +data Mpeg = Mpeg +derive instance Generic Mpeg _ +derive instance Eq Mpeg +instance Show Mpeg where + show = genericShow +instance TypelevelMIME Mpeg where + fromValue MIME.Mpeg = Just Mpeg + fromValue _ = Nothing + value = MIME.Mpeg + +data Mpkg = Mpkg +derive instance Generic Mpkg _ +derive instance Eq Mpkg +instance Show Mpkg where + show = genericShow +instance TypelevelMIME Mpkg where + fromValue MIME.Mpkg = Just Mpkg + fromValue _ = Nothing + value = MIME.Mpkg + +data Odp = Odp +derive instance Generic Odp _ +derive instance Eq Odp +instance Show Odp where + show = genericShow +instance TypelevelMIME Odp where + fromValue MIME.Odp = Just Odp + fromValue _ = Nothing + value = MIME.Odp + +data Ods = Ods +derive instance Generic Ods _ +derive instance Eq Ods +instance Show Ods where + show = genericShow +instance TypelevelMIME Ods where + fromValue MIME.Ods = Just Ods + fromValue _ = Nothing + value = MIME.Ods + +data Odt = Odt +derive instance Generic Odt _ +derive instance Eq Odt +instance Show Odt where + show = genericShow +instance TypelevelMIME Odt where + fromValue MIME.Odt = Just Odt + fromValue _ = Nothing + value = MIME.Odt + +data Oga = Oga +derive instance Generic Oga _ +derive instance Eq Oga +instance Show Oga where + show = genericShow +instance TypelevelMIME Oga where + fromValue MIME.Oga = Just Oga + fromValue _ = Nothing + value = MIME.Oga + +data Ogv = Ogv +derive instance Generic Ogv _ +derive instance Eq Ogv +instance Show Ogv where + show = genericShow +instance TypelevelMIME Ogv where + fromValue MIME.Ogv = Just Ogv + fromValue _ = Nothing + value = MIME.Ogv + +data Ogx = Ogx +derive instance Generic Ogx _ +derive instance Eq Ogx +instance Show Ogx where + show = genericShow +instance TypelevelMIME Ogx where + fromValue MIME.Ogx = Just Ogx + fromValue _ = Nothing + value = MIME.Ogx + +data Opus = Opus +derive instance Generic Opus _ +derive instance Eq Opus +instance Show Opus where + show = genericShow +instance TypelevelMIME Opus where + fromValue MIME.Opus = Just Opus + fromValue _ = Nothing + value = MIME.Opus + +data Otf = Otf +derive instance Generic Otf _ +derive instance Eq Otf +instance Show Otf where + show = genericShow +instance TypelevelMIME Otf where + fromValue MIME.Otf = Just Otf + fromValue _ = Nothing + value = MIME.Otf + +data Png = Png +derive instance Generic Png _ +derive instance Eq Png +instance Show Png where + show = genericShow +instance TypelevelMIME Png where + fromValue MIME.Png = Just Png + fromValue _ = Nothing + value = MIME.Png + +data Pdf = Pdf +derive instance Generic Pdf _ +derive instance Eq Pdf +instance Show Pdf where + show = genericShow +instance TypelevelMIME Pdf where + fromValue MIME.Pdf = Just Pdf + fromValue _ = Nothing + value = MIME.Pdf + +data Php = Php +derive instance Generic Php _ +derive instance Eq Php +instance Show Php where + show = genericShow +instance TypelevelMIME Php where + fromValue MIME.Php = Just Php + fromValue _ = Nothing + value = MIME.Php + +data Ppt = Ppt +derive instance Generic Ppt _ +derive instance Eq Ppt +instance Show Ppt where + show = genericShow +instance TypelevelMIME Ppt where + fromValue MIME.Ppt = Just Ppt + fromValue _ = Nothing + value = MIME.Ppt + +data Pptx = Pptx +derive instance Generic Pptx _ +derive instance Eq Pptx +instance Show Pptx where + show = genericShow +instance TypelevelMIME Pptx where + fromValue MIME.Pptx = Just Pptx + fromValue _ = Nothing + value = MIME.Pptx + +data Rar = Rar +derive instance Generic Rar _ +derive instance Eq Rar +instance Show Rar where + show = genericShow +instance TypelevelMIME Rar where + fromValue MIME.Rar = Just Rar + fromValue _ = Nothing + value = MIME.Rar + +data Rtf = Rtf +derive instance Generic Rtf _ +derive instance Eq Rtf +instance Show Rtf where + show = genericShow +instance TypelevelMIME Rtf where + fromValue MIME.Rtf = Just Rtf + fromValue _ = Nothing + value = MIME.Rtf + +data Sh = Sh +derive instance Generic Sh _ +derive instance Eq Sh +instance Show Sh where + show = genericShow +instance TypelevelMIME Sh where + fromValue MIME.Sh = Just Sh + fromValue _ = Nothing + value = MIME.Sh + +data Svg = Svg +derive instance Generic Svg _ +derive instance Eq Svg +instance Show Svg where + show = genericShow +instance TypelevelMIME Svg where + fromValue MIME.Svg = Just Svg + fromValue _ = Nothing + value = MIME.Svg + +data Tar = Tar +derive instance Generic Tar _ +derive instance Eq Tar +instance Show Tar where + show = genericShow +instance TypelevelMIME Tar where + fromValue MIME.Tar = Just Tar + fromValue _ = Nothing + value = MIME.Tar + +data Tif = Tif +derive instance Generic Tif _ +derive instance Eq Tif +instance Show Tif where + show = genericShow +instance TypelevelMIME Tif where + fromValue MIME.Tif = Just Tif + fromValue _ = Nothing + value = MIME.Tif + +data Ts = Ts +derive instance Generic Ts _ +derive instance Eq Ts +instance Show Ts where + show = genericShow +instance TypelevelMIME Ts where + fromValue MIME.Ts = Just Ts + fromValue _ = Nothing + value = MIME.Ts + +data Ttf = Ttf +derive instance Generic Ttf _ +derive instance Eq Ttf +instance Show Ttf where + show = genericShow +instance TypelevelMIME Ttf where + fromValue MIME.Ttf = Just Ttf + fromValue _ = Nothing + value = MIME.Ttf + +data Txt = Txt +derive instance Generic Txt _ +derive instance Eq Txt +instance Show Txt where + show = genericShow +instance TypelevelMIME Txt where + fromValue MIME.Txt = Just Txt + fromValue _ = Nothing + value = MIME.Txt + +data Vsd = Vsd +derive instance Generic Vsd _ +derive instance Eq Vsd +instance Show Vsd where + show = genericShow +instance TypelevelMIME Vsd where + fromValue MIME.Vsd = Just Vsd + fromValue _ = Nothing + value = MIME.Vsd + +data Wav = Wav +derive instance Generic Wav _ +derive instance Eq Wav +instance Show Wav where + show = genericShow +instance TypelevelMIME Wav where + fromValue MIME.Wav = Just Wav + fromValue _ = Nothing + value = MIME.Wav + +data Weba = Weba +derive instance Generic Weba _ +derive instance Eq Weba +instance Show Weba where + show = genericShow +instance TypelevelMIME Weba where + fromValue MIME.Weba = Just Weba + fromValue _ = Nothing + value = MIME.Weba + +data Webm = Webm +derive instance Generic Webm _ +derive instance Eq Webm +instance Show Webm where + show = genericShow +instance TypelevelMIME Webm where + fromValue MIME.Webm = Just Webm + fromValue _ = Nothing + value = MIME.Webm + +data Webp = Webp +derive instance Generic Webp _ +derive instance Eq Webp +instance Show Webp where + show = genericShow +instance TypelevelMIME Webp where + fromValue MIME.Webp = Just Webp + fromValue _ = Nothing + value = MIME.Webp + +data Woff = Woff +derive instance Generic Woff _ +derive instance Eq Woff +instance Show Woff where + show = genericShow +instance TypelevelMIME Woff where + fromValue MIME.Woff = Just Woff + fromValue _ = Nothing + value = MIME.Woff + +data Woff2 = Woff2 +derive instance Generic Woff2 _ +derive instance Eq Woff2 +instance Show Woff2 where + show = genericShow +instance TypelevelMIME Woff2 where + fromValue MIME.Woff2 = Just Woff2 + fromValue _ = Nothing + value = MIME.Woff2 + +data Xhtml = Xhtml +derive instance Generic Xhtml _ +derive instance Eq Xhtml +instance Show Xhtml where + show = genericShow +instance TypelevelMIME Xhtml where + fromValue MIME.Xhtml = Just Xhtml + fromValue _ = Nothing + value = MIME.Xhtml + +data Xls = Xls +derive instance Generic Xls _ +derive instance Eq Xls +instance Show Xls where + show = genericShow +instance TypelevelMIME Xls where + fromValue MIME.Xls = Just Xls + fromValue _ = Nothing + value = MIME.Xls + +data Xlsx = Xlsx +derive instance Generic Xlsx _ +derive instance Eq Xlsx +instance Show Xlsx where + show = genericShow +instance TypelevelMIME Xlsx where + fromValue MIME.Xlsx = Just Xlsx + fromValue _ = Nothing + value = MIME.Xlsx + +data Xml = Xml +derive instance Generic Xml _ +derive instance Eq Xml +instance Show Xml where + show = genericShow +instance TypelevelMIME Xml where + fromValue MIME.Xml = Just Xml + fromValue _ = Nothing + value = MIME.Xml + +data Xul = Xul +derive instance Generic Xul _ +derive instance Eq Xul +instance Show Xul where + show = genericShow +instance TypelevelMIME Xul where + fromValue MIME.Xul = Just Xul + fromValue _ = Nothing + value = MIME.Xul + +data Zip = Zip +derive instance Generic Zip _ +derive instance Eq Zip +instance Show Zip where + show = genericShow +instance TypelevelMIME Zip where + fromValue MIME.Zip = Just Zip + fromValue _ = Nothing + value = MIME.Zip + +data Video3gp = Video3gp +derive instance Generic Video3gp _ +derive instance Eq Video3gp +instance Show Video3gp where + show = genericShow +instance TypelevelMIME Video3gp where + fromValue MIME.Video3gp = Just Video3gp + fromValue _ = Nothing + value = MIME.Video3gp + +data Video3g2 = Video3g2 +derive instance Generic Video3g2 _ +derive instance Eq Video3g2 +instance Show Video3g2 where + show = genericShow +instance TypelevelMIME Video3g2 where + fromValue MIME.Video3g2 = Just Video3g2 + fromValue _ = Nothing + value = MIME.Video3g2 + +data Archive7z = Archive7z +derive instance Generic Archive7z _ +derive instance Eq Archive7z +instance Show Archive7z where + show = genericShow +instance TypelevelMIME Archive7z where + fromValue MIME.Archive7z = Just Archive7z + fromValue _ = Nothing + value = MIME.Archive7z