śĪEż? t      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrs Dennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownSafe+,DQRUChange a list of types into a list of functions that take the given type and return x.LRefl :: ReturnX Double '[String, Int] :~: '[String -> Double, Int -> Double]Refl%Don't do anything with an empty list:"Refl :: ReturnX Double '[] :~: '[]Refl A type-level snoc.Append to an empty list:%Refl :: Snoc '[] Double :~: '[Double]ReflAppend to a non-empty list:/Refl :: Snoc '[Char] String :~: '[Char, String]ReflDennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownSafe,D<This is used internally and should not be used by end-users.Z is used in Servant API definitions and signifies that an API will throw the given error.GHere is an example of how to create an API that potentially returns a t as an error, or an u on success:$import Servant.API (Get, JSON, (:>))+type API = Throws String :> Get '[JSON] IntDennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownSafe%&*+,-9:;<=?DOQRTa) gives us a way to convert a tuple to an . See  .  v) is used as a standard open product type.6This type class provides a way to turn a tuple into a  .Convert a tuple into a  . See   for examples. 1An extensible product type. This is similar to  /, except a product type instead of a sum type. Turn a tuple into a  .LtupleToProduct (Identity 1, Identity 2.0) :: Product Identity '[Int, Double]+Cons (Identity 1) (Cons (Identity 2.0) Nil) Turn a tuple into an .#For example, turn a triple into an :JtupleToOpenProduct (1, 2.0, "hello") :: OpenProduct '[Int, Double, String]ECons (Identity 1) (Cons (Identity 2.0) (Cons (Identity "hello") Nil))Turn a single value into an :-tupleToOpenProduct 'c' :: OpenProduct '[Char]Cons (Identity 'c') NilShow   values.Show   values.Convert a 4-tuple into an .Convert a 3-tuple into an .Convert a tuple into an .Convert a single value into an .Convert a 4-tuple into a  .Convert a 3-tuple into a  .Convert a tuple into a  .Convert a single value into a  .        Dennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownNone%&*+,-/9:;<=?DOQRT[a We can use  v as a standard open sum type.This is a helpful  Constraint synonym to assert that a is a member of as. a as i& provides a way to potentially get an f a out of a  f as ((). It also provides a way to create a  f as from an f a ().This is safe because of the $ contraint. This $! constraint tells us that there  actually is an a in as at index i.]As an end-user, you should never need to implement an additional instance of this typeclass.This is implemented as w  .This is implemented as x .This is implemented as y .A  is parameterized by a universe u, an interpretation f and a list of labels as@. The labels of the union are given by inhabitants of the kind u"; the type of values at any label a :: u is given by its interpretation f a :: *.!KA mere approximation of the natural numbers. And their image as lifted by  -XDataKinds+ corresponds to the actual natural numbers.$=A partial relation that gives the index of a value in a list.Find the first item:'import Data.Type.Equality ((:~:)(Refl))+Refl :: RIndex String '[String, Int] :~: 'ZReflFind the third item:7Refl :: RIndex Char '[String, Int, Char] :~: 'S ('S 'Z)Refl%Case analysis for .$Here is an example of matching on a :@let u = This (Identity "hello") :: Union Identity '[String, Int]7let runIdent = runIdentity :: Identity String -> String'union (const "not a String") runIdent u"hello"$Here is an example of matching on a  :Klet v = That (This (Identity 3.3)) :: Union Identity '[String, Double, Int]'union (const "not a String") runIdent v"not a String"&\Since a union with an empty list of labels is uninhabited, we can recover any type from it.'Map over the interpretation f in the .!Here is an example of changing a  v '[t, u] to  z '[t, u]:@let u = This (Identity "hello") :: Union Identity '[String, Int]9umap (Just . runIdentity) u :: Union Maybe '[String, Int] Just "hello"(!An alternate case anaylsis for a Q. This method uses a tuple containing handlers for each potential value of the $. This is somewhat similar to the   function.!Here is an example of handling a @ with two possible values. Notice that a normal tuple is used::let u = This $ Identity 3 :: Union Identity '[Int, String]Jlet intHandler = (Identity $ \int -> show int) :: Identity (Int -> String)Hlet strHandler = (Identity $ \str -> str) :: Identity (String -> String):catchesUnion (intHandler, strHandler) u :: Identity String Identity "3"Given a  like  v '[u, t], the type of ( becomes the following:  ( :: (v (u -> t), v (t -> t )) ->  v '[u, t ] -> v t  Checkout 1 for more examples.)Lens-compatible { for .Use ) to construct a :4review _This (Just "hello") :: Union Maybe '[String] Just "hello"Use ) to try to destruct a  into a f a:@let u = This (Identity "hello") :: Union Identity '[String, Int]*preview _This u :: Maybe (Identity String)Just (Identity "hello")Use ) to try to destruct a  into a f a (unsuccessfully):Klet v = That (This (Identity 3.3)) :: Union Identity '[String, Double, Int]*preview _This v :: Maybe (Identity String)Nothing*Lens-compatible { for  .Use * to construct a :4let u = This (Just "hello") :: Union Maybe '[String]/review _That u :: Union Maybe '[Double, String] Just "hello"Use * to try to peel off a   from a :Glet v = That (This (Identity "hello")) :: Union Identity '[Int, String]3preview _That v :: Maybe (Union Identity '[String])Just (Identity "hello")Use * to try to peel off a   from a  (unsuccessfully):?let w = This (Identity 3.5) :: Union Identity '[Double, String]3preview _That w :: Maybe (Union Identity '[String])Nothing+Case analysis for .,Here is an example of successfully matching:let string = "hello" :: String8let o = openUnionLift string :: OpenUnion '[String, Int]%openUnion (const "not a String") id o"hello".Here is an example of unsuccessfully matching:let double = 3.3 :: Double@let p = openUnionLift double :: OpenUnion '[String, Double, Int]%openUnion (const "not a String") id p"not a String",This is similar to  fromMaybe for an .,Here is an example of successfully matching:let string = "hello" :: String8let o = openUnionLift string :: OpenUnion '[String, Int]&fromOpenUnion (const "not a String") o"hello".Here is an example of unsuccessfully matching:let double = 3.3 :: Double@let p = openUnionLift double :: OpenUnion '[String, Double, Int]&fromOpenUnion (const "not a String") p"not a String"-Flipped version of ,.. Just like  but for ./ Just like  but for . Creating an :let string = "hello" :: String8openUnionLift string :: OpenUnion '[Double, String, Int]Identity "hello"0 Just like  but for .Successful matching:let string = "hello" :: String@let o = openUnionLift string :: OpenUnion '[Double, String, Int] openUnionMatch o :: Maybe String Just "hello"Failure matching:let double = 3.3 :: Double;let p = openUnionLift double :: OpenUnion '[Double, String] openUnionMatch p :: Maybe StringNothing1"An alternate case anaylsis for an Q. This method uses a tuple containing handlers for each potential value of the $. This is somewhat similar to the   function."Here is an example of handling an ? with two possible values. Notice that a normal tuple is used:<let u = openUnionLift (3 :: Int) :: OpenUnion '[Int, String]4let intHandler = (\int -> show int) :: Int -> String2let strHandler = (\str -> str) :: String -> String5catchesOpenUnion (intHandler, strHandler) u :: String"3" Given an  like  '[u, t], the type of 1 becomes the following:  1 :: (u -> x, t -> x) ->  '[u, t ] -> x "Here is an example of handling an  with three possible values:Mlet u = openUnionLift ("hello" :: String) :: OpenUnion '[Int, String, Double]4let intHandler = (\int -> show int) :: Int -> String2let strHandler = (\str -> str) :: String -> String=let dblHandler = (\dbl -> "got a double") :: Double -> StringAcatchesOpenUnion (intHandler, strHandler, dblHandler) u :: String"hello""Here is an example of handling an T with only one possible value. Notice how a tuple is not used, just a single value:<let u = openUnionLift (2.2 :: Double) :: OpenUnion '[Double]=let dblHandler = (\dbl -> "got a double") :: Double -> String'catchesOpenUnion dblHandler u :: String"got a double"When working with large s, it can be easier to use 1 than +.2'This is only a valid instance when the |( instances for the types don't overlap.This is similar to the } instance.3This will always fail, since  f '[] is effectively Void.:'This is only a valid instance when the }( instances for the types don't overlap.,For instance, imagine we are working with a  of a t and a ~. 3.5 can only be read as a ~ , not as a t. Oppositely, "hello" can only be read as a t , not as a ~.Llet o = readMaybe "Identity 3.5" :: Maybe (Union Identity '[Double, String])oJust (Identity 3.5)$o >>= openUnionMatch :: Maybe DoubleJust 3.5$o >>= openUnionMatch :: Maybe StringNothingRlet p = readMaybe "Identity \"hello\"" :: Maybe (Union Identity '[Double, String])pJust (Identity "hello")$p >>= openUnionMatch :: Maybe DoubleNothing$p >>= openUnionMatch :: Maybe String Just "hello"'However, imagine are we working with a  of a t and Text. "hello" can be  as both a t and Text@. However, in the following example, it can only be read as a t:Plet q = readMaybe "Identity \"hello\"" :: Maybe (Union Identity '[String, Text])qJust (Identity "hello")$q >>= openUnionMatch :: Maybe String Just "hello""q >>= openUnionMatch :: Maybe TextNothingEIf the order of the types is flipped around, we are are able to read "hello" as a Text but not as a t.Plet r = readMaybe "Identity \"hello\"" :: Maybe (Union Identity '[Text, String])rJust (Identity "hello")$r >>= openUnionMatch :: Maybe StringNothing"r >>= openUnionMatch :: Maybe Text Just "hello";This will always fail, since  f '[] is effectively Void.+ !"#$%&'€()*+,-./0123456789:;<=>?@A !"#$%&'()*+,-./01 %(&')*!"#$+,-./01$ !"#$%&'€()*+,-./0123456789:;<=>?@ADennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownNone%&-/02345:OTBThis B. type is a used as a wrapper around either an < with an error or a successful value. It is similar to an  e a, but where the e is specialized to  es'. The most important difference from  is the the | and ‚ instances. Given an B '[t, ~] ()(, we know that the envelope could be a D and contain (). Or it could be a C that contains either a t or a ~6. It might be simpler to think of it as a type like  t ( ~ ()).An B can be created with the E and F functions. The {s Q, R, and S% can be used to get values out of an B.E Create an C from a member of the .'For instance, here is how to create an C that contains a ~:let double = 3.5 :: Double:toErrEnvelope double :: Envelope '[String, Double, Int] ()ErrEnvelope (Identity 3.5)FThis is a function to create a D.3toSuccEnvelope "hello" :: Envelope '[Double] StringSuccEnvelope "hello"GG is E lifted up to an ƒ.HH is F lifted up to an ƒ.ICase analysis for Bs.$Here is an example of matching on a D:Blet env = toSuccEnvelope "hello" :: Envelope '[Double, Int] String&envelope (const "not a String") id env"hello"$Here is an example of matching on a C:let double = 3.5 :: DoubleAlet env' = toErrEnvelope double :: Envelope '[Double, Int] String'envelope (const "not a String") id env'"not a String"J Just like   but for B.,Here is an example of successfully matching:Blet env = toSuccEnvelope "hello" :: Envelope '[Double, Int] String'fromEnvelope (const "not a String") env"hello".Here is an example of unsuccessfully matching:let double = 3.5 :: DoubleAlet env' = toErrEnvelope double :: Envelope '[Double, Int] String(fromEnvelope (const "not a String") env'"not a String"KLifted version of J.LFlipped version of J.MFlipped version of K.N Convert an B to an .O Convert an  to an B.PLens-compatible „ from B to .QLens-compatible { to pull out an a from a D.Use Q to construct an B:9review _SuccEnvelope "hello" :: Envelope '[Double] StringSuccEnvelope "hello"Use Q to try to destruct an B into an a:=let env = toSuccEnvelope "hello" :: Envelope '[Double] String)preview _SuccEnvelope env :: Maybe String Just "hello"Use Q( to try to destruct a 'Envelope into an a (unsuccessfully):let double = 3.5 :: Double<let env' = toErrEnvelope double :: Envelope '[Double] String*preview _SuccEnvelope env' :: Maybe StringNothingRLens-compatible { to pull out an  es from a C.Use R to construct an B:let string = "hello" :: StringGreview _ErrEnvelope (openUnionLift string) :: Envelope '[String] DoubleErrEnvelope (Identity "hello")Use R to try to destruct an B into an  es:let double = 3.5 :: Double7let env = toErrEnvelope double :: Envelope '[Double] ()7preview _ErrEnvelope env :: Maybe (OpenUnion '[Double])Just (Identity 3.5)Use R) to try to destruct a 'Envelope into an  es (unsuccessfully):5let env' = toSuccEnvelope () :: Envelope '[Double] ()8preview _ErrEnvelope env' :: Maybe (OpenUnion '[Double])NothingMost users will not use R, but instead S.SLens-compatible { to pull out a specific e from an C.Use S to construct an B:let string = "hello" :: String:review _ErrEnvelopeErr string :: Envelope '[String] DoubleErrEnvelope (Identity "hello")Use S to try to destruct an B into an e:let double = 3.5 :: Double7let env = toErrEnvelope double :: Envelope '[Double] ()+preview _ErrEnvelopeErr env :: Maybe DoubleJust 3.5Use S) to try to destruct a 'Envelope into an e (unsuccessfully):5let env' = toSuccEnvelope () :: Envelope '[Double] (),preview _ErrEnvelopeErr env' :: Maybe DoubleNothing<let env'' = toErrEnvelope 'c' :: Envelope '[Double, Char] ()-preview _ErrEnvelopeErr env'' :: Maybe DoubleNothingMost users will use S instead of R.TPull out a specific e from an C.Successfully pull out an e:let double = 3.5 :: Double7let env = toErrEnvelope double :: Envelope '[Double] ()$errEnvelopeMatch env :: Maybe DoubleJust 3.5Unsuccessfully pull out an e:5let env' = toSuccEnvelope () :: Envelope '[Double] ()%errEnvelopeMatch env' :: Maybe DoubleNothing<let env'' = toErrEnvelope 'c' :: Envelope '[Double, Char] ()&errEnvelopeMatch env'' :: Maybe DoubleNothingU"An alternate case anaylsis for an BQ. This method uses a tuple containing handlers for each potential value of the B$. This is somewhat similar to the   function."Here is an example of handling an DE with two possible error values. Notice that a normal tuple is used:>let env = toSuccEnvelope 2.0 :: Envelope '[Int, String] Double4let intHandler = (\int -> show int) :: Int -> String2let strHandler = (\str -> str) :: String -> String>let succHandler = (\dbl -> "got a double") :: Double -> StringBcatchesEnvelope (intHandler, strHandler) succHandler env :: String"got a double""Here is an example of handling an CZ with two possible error values. Notice that a normal tuple is used to hold the handlers:Dlet env = toErrEnvelope (3 :: Int) :: Envelope '[Int, String] Double4let intHandler = (\int -> show int) :: Int -> String2let strHandler = (\str -> str) :: String -> String>let succHandler = (\dbl -> "got a double") :: Double -> StringBcatchesEnvelope (intHandler, strHandler) succHandler env :: String"3" Given an B like B '[u, t] ~, the type of U becomes the following:  U :: (u -> x, t -> x) -> (~ -> x) -> B '[u, t] ~ -> x "Here is an example of handling an CP with three possible values. Notice how a 3-tuple is used to hold the handlers:Plet env = toErrEnvelope ("hi" :: String) :: Envelope '[Int, String, Char] Double4let intHandler = (\int -> show int) :: Int -> String2let strHandler = (\str -> str) :: String -> String2let chrHandler = (\chr -> [chr]) :: Char -> String>let succHandler = (\dbl -> "got a double") :: Double -> StringNcatchesEnvelope (intHandler, strHandler, chrHandler) succHandler env :: String"hi" Given an B like B '[u, t, …] ~, the type of U becomes the following:  U :: (u -> x, t -> x, … -> x) -> (~ -> x) -> B '[u, t, …] ~ -> x "Here is an example of handling an CY with only one possible error value. Notice that a normal handler is used (not a tuple):<let env = toErrEnvelope (3 :: Int) :: Envelope '[Int] Double4let intHandler = (\int -> show int) :: Int -> String>let succHandler = (\dbl -> "got a double") :: Double -> String4catchesEnvelope intHandler succHandler env :: String"3" Given an B like B '[u] ~, the type of U becomes the following:  U :: (u -> x) -> (~ -> x) -> B '[u] ~ -> x When working with an BG with a large number of possible error types, it can be easier to use U than I.Z'This is only a valid instance when the | instances for the es don't overlap.1For an explanation, see the documentation on the | instance for Union.[This ‚ instance encodes an BA as an object with one of two keys depending on whether it is a D or an C.Here is an example of a D:let string = "hello" :: String<let env = toSuccEnvelope string :: Envelope '[Double] StringputByteStrLn $ encode env{"data":"hello"}Here is an example of a C:let double = 3.5 :: Double<let env' = toErrEnvelope double :: Envelope '[Double] StringputByteStrLn $ encode env' {"err":3.5}BCDEFGHIJKLMNOPQRSTUVWXYZ[BCDEFGHIJKLMNOPQRSTUBCDFEHGIJLKMTUQRSNOPBCDEFGHIJKLMNOPQRSTUVWXYZ[Dennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownNone+,-9:;<=DOQRTeWhen a  e comes immediately after a  es,  the e onto the es.fWhen  es comes before a †, change it into the same † but returning an B es.g Change a  into .efggfeefgDennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownNone+,-9:;<=DLOQRThCreate samples for a given list of types, under given ctypes.AAdditional instances of this class should not need to be created.jCreate a sample for a given e under given ctypes.kWe can generate a sample of an B es a8 as long as there is a way to generate a sample of the a.8This doesn't need to worry about generating a sample of es(, because that is taken care of in the ‡ instance for  es.lWhen a  e comes immediately after a  es,  the e onto the es.m3Create a response body for each of the error types.n&An empty list of types has no samples.oWhen  es comes before a †+, generate the documentation for the same †, but returning an B es-. Also add documentation for the potential es.p Change a  into . hijklmnophij pohinmjlkhijklmnopDennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownNone+,-9:;<=DOQRTqWhen a  e comes immediately after a  es,  the e onto the es.rWhen  es comes before a †, change it into the same † but returning an B es.s Change a  into .qrssrqqrsDennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownNoneDennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownNone<  !#"$%&'()*+,-./01BCDEFGHIJKLMNOPQRSTUDennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownNone8  !"#$%&'()*+,-./01BCDEFGHIJKLMNOPQRSTU8BCDFEHGIJLKMTUQRSNOP+,-./01 %&'()*!"#$   ˆ !"#$%&'()*+,-. /0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰„Š‹ŒŽŒŒ‘’„…“Œ”•–—˜„™š‡ˆ›„œž„ Ÿ– ”„…¢Œ”£‡ˆ¤„¦§Ø©Ŗ«9servant-checked-exceptions-0.2.0.0-AZ3BYUslA3f31gpdUMZAg7(Servant.Checked.Exceptions.Internal.Util/Servant.Checked.Exceptions.Internal.Servant.API+Servant.Checked.Exceptions.Internal.Product)Servant.Checked.Exceptions.Internal.Union,Servant.Checked.Exceptions.Internal.Envelope2Servant.Checked.Exceptions.Internal.Servant.Client0Servant.Checked.Exceptions.Internal.Servant.Docs2Servant.Checked.Exceptions.Internal.Servant.ServerUnionControl.Exceptioncatches Data.Either fromEither+Servant.Checked.Exceptions.Internal.Servant#Servant.Checked.Exceptions.InternalServant.Checked.ExceptionsReturnXSnocThrowingThrows ToOpenProduct toOpenProduct OpenProduct ToProduct toProductProductNilConstupleToProducttupleToOpenProduct $fShowProduct$fShowProduct0$fToOpenProduct(,,,):$fToOpenProduct(,,):$fToOpenProduct(,):$fToOpenProducta:$fToProductu(,,,)f:$fToProductu(,,)f:$fToProductu(,)f:$fToProductuff: OpenUnionIsMemberUElem unionPrism unionLift unionMatchThisThatNatZSRIndexunion absurdUnionumap catchesUnion_This_That openUnion fromOpenUnionfromOpenUnionOropenUnionPrism openUnionLiftopenUnionMatchcatchesOpenUnion$fFromJSONUnion$fFromJSONUnion0 $fToJSONUnion$fToJSONUnion0 $fOrdUnion $fOrdUnion0 $fEqUnion $fEqUnion0 $fReadUnion $fReadUnion0 $fShowUnion $fShowUnion0 $fNFDataUnion$fNFDataUnion0 $fUElemaa:S $fUElemaa:ZEnvelope ErrEnvelope SuccEnvelope toErrEnvelopetoSuccEnvelopepureErrEnvelopepureSuccEnvelopeenvelope fromEnvelope fromEnvelopeMfromEnvelopeOrfromEnvelopeOrMenvelopeToEithereitherToEnvelopeisoEnvelopeEither _SuccEnvelope _ErrEnvelope_ErrEnvelopeErrerrEnvelopeMatchcatchesEnvelope$fSemigroupEnvelope$fMonadFixEnvelope$fMonadEnvelope$fApplicativeEnvelope$fFromJSONEnvelope$fToJSONEnvelope$fFoldableEnvelope$fFunctorEnvelope$fGenericEnvelope$fTraversableEnvelope$fShowEnvelope$fReadEnvelope $fOrdEnvelope $fEqEnvelope$fDataEnvelope$fHasClientTYPE:>$fHasClientTYPE:>0$fHasClientTYPE:>1CreateRespBodiesForcreateRespBodiesForcreateRespBodyFor$fToSampleEnvelope$fHasDocsTYPE:> $fCreateRespBodiesFor[][]:ctypes $fCreateRespBodiesFork[][]ctypes$fHasDocsTYPE:>0$fHasDocsTYPE:>1$fHasServerTYPE:>context$fHasServerTYPE:>context0$fHasServerTYPE:>context1baseGHC.BaseStringghc-prim GHC.TypesIntData.Functor.IdentityIdentity"lens-4.15.2-7NfXuU5AnOD65llKMmK4xMControl.Lens.Prismprism'Control.Lens.ReviewreviewControl.Lens.FoldpreviewMaybeControl.Lens.TypePrism$aeson-1.2.0.0-EbPrqFF8uEn6JTr1dCEeDTData.Aeson.Types.FromJSONFromJSONGHC.ReadReadDouble Text.ReadreadcatchesUnionProductEitherData.Aeson.Types.ToJSONToJSON ApplicativeIsoChar#servant-0.10-7PMMYsYq3nrL2VY0E9CiIQServant.API.VerbsVerb(servant-docs-0.10-Cj3kdxRWtDB7SI0EbD8UcRServant.Docs.InternalHasDocs