/usr/share/doc/libghc-servant-doc/html/servant.txt is in libghc-servant-doc 0.11-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | -- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A family of combinators for defining webservices APIs
--
-- A family of combinators for defining webservices APIs and serving them
--
-- You can learn about the basics in the <a>tutorial</a>.
--
-- <a>CHANGELOG</a>
@package servant
@version 0.11
module Servant.API.WithNamedContext
-- | <a>WithNamedContext</a> names a specific tagged context to use for the
-- combinators in the API. (See also in <tt>servant-server</tt>,
-- <tt>Servant.Server.Context</tt>.) For example:
--
-- <pre>
-- type UseNamedContextAPI = WithNamedContext "myContext" '[String] (
-- ReqBody '[JSON] Int :> Get '[JSON] Int)
-- </pre>
--
-- Both the <tt>ReqBody</tt> and <tt>Get</tt> combinators will use the
-- <a>WithNamedContext</a> with type tag "myContext" as their context.
--
-- <tt>Context</tt>s are only relevant for <tt>servant-server</tt>.
--
-- For more information, see the tutorial.
data WithNamedContext (name :: Symbol) (subContext :: [*]) subApi
module Servant.API.Verbs
-- | <tt>Verb</tt> is a general type for representing HTTP verbs (a.k.a.
-- methods). For convenience, type synonyms for each verb with a 200
-- response code are provided, but you are free to define your own:
--
-- <pre>
-- >>> type Post204 contentTypes a = Verb 'POST 204 contentTypes a
-- </pre>
data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [*]) a
-- | <a>GET</a> with 200 status code.
type Get = Verb GET 200
-- | <a>POST</a> with 200 status code.
type Post = Verb POST 200
-- | <a>PUT</a> with 200 status code.
type Put = Verb PUT 200
-- | <a>DELETE</a> with 200 status code.
type Delete = Verb DELETE 200
-- | <a>PATCH</a> with 200 status code.
type Patch = Verb PATCH 200
-- | <a>POST</a> with 201 status code.
type PostCreated = Verb POST 201
-- | <a>GET</a> with 202 status code.
type GetAccepted = Verb GET 202
-- | <a>POST</a> with 202 status code.
type PostAccepted = Verb POST 202
-- | <a>DELETE</a> with 202 status code.
type DeleteAccepted = Verb DELETE 202
-- | <a>PATCH</a> with 202 status code.
type PatchAccepted = Verb PATCH 202
-- | <a>PUT</a> with 202 status code.
type PutAccepted = Verb PUT 202
-- | <a>GET</a> with 203 status code.
type GetNonAuthoritative = Verb GET 203
-- | <a>POST</a> with 203 status code.
type PostNonAuthoritative = Verb POST 203
-- | <a>DELETE</a> with 203 status code.
type DeleteNonAuthoritative = Verb DELETE 203
-- | <a>PATCH</a> with 203 status code.
type PatchNonAuthoritative = Verb PATCH 203
-- | <a>PUT</a> with 203 status code.
type PutNonAuthoritative = Verb PUT 203
-- | <a>GET</a> with 204 status code.
type GetNoContent = Verb GET 204
-- | <a>POST</a> with 204 status code.
type PostNoContent = Verb POST 204
-- | <a>DELETE</a> with 204 status code.
type DeleteNoContent = Verb DELETE 204
-- | <a>PATCH</a> with 204 status code.
type PatchNoContent = Verb PATCH 204
-- | <a>PUT</a> with 204 status code.
type PutNoContent = Verb PUT 204
-- | <a>GET</a> with 205 status code.
type GetResetContent = Verb GET 205
-- | <a>POST</a> with 205 status code.
type PostResetContent = Verb POST 205
-- | <a>DELETE</a> with 205 status code.
type DeleteResetContent = Verb DELETE 205
-- | <a>PATCH</a> with 205 status code.
type PatchResetContent = Verb PATCH 205
-- | <a>PUT</a> with 205 status code.
type PutResetContent = Verb PUT 205
-- | <a>GET</a> with 206 status code.
type GetPartialContent = Verb GET 206
class ReflectMethod a
reflectMethod :: ReflectMethod a => Proxy a -> Method
-- | HTTP standard method (as defined by RFC 2616, and PATCH which is
-- defined by RFC 5789).
data StdMethod :: *
GET :: StdMethod
POST :: StdMethod
HEAD :: StdMethod
PUT :: StdMethod
DELETE :: StdMethod
TRACE :: StdMethod
CONNECT :: StdMethod
OPTIONS :: StdMethod
PATCH :: StdMethod
instance forall k1 (method :: k1) (statusCode :: GHC.Types.Nat) (contentTypes :: [GHC.Types.*]) k (a :: k). GHC.Generics.Generic (Servant.API.Verbs.Verb method statusCode contentTypes a)
instance Servant.API.Verbs.ReflectMethod 'Network.HTTP.Types.Method.GET
instance Servant.API.Verbs.ReflectMethod 'Network.HTTP.Types.Method.POST
instance Servant.API.Verbs.ReflectMethod 'Network.HTTP.Types.Method.PUT
instance Servant.API.Verbs.ReflectMethod 'Network.HTTP.Types.Method.DELETE
instance Servant.API.Verbs.ReflectMethod 'Network.HTTP.Types.Method.PATCH
instance Servant.API.Verbs.ReflectMethod 'Network.HTTP.Types.Method.HEAD
instance Servant.API.Verbs.ReflectMethod 'Network.HTTP.Types.Method.OPTIONS
instance Servant.API.Verbs.ReflectMethod 'Network.HTTP.Types.Method.TRACE
instance Servant.API.Verbs.ReflectMethod 'Network.HTTP.Types.Method.CONNECT
module Servant.API.Vault
-- | A persistent store for values of arbitrary types.
--
-- This variant is the simplest and creates keys in the <a>IO</a> monad.
-- See the module <a>Data.Vault.ST</a> if you want to use it with the
-- <a>ST</a> monad instead.
type Vault = Vault RealWorld
module Servant.API.Sub
-- | The contained API (second argument) can be found under <tt>("/" ++
-- path)</tt> (path being the first argument).
--
-- Example:
--
-- <pre>
-- >>> -- GET /hello/world
--
-- >>> -- returning a JSON encoded World value
--
-- >>> type MyApi = "hello" :> "world" :> Get '[JSON] World
-- </pre>
data (:>) (path :: k) a
module Servant.API.ReqBody
-- | Extract the request body as a value of type <tt>a</tt>.
--
-- Example:
--
-- <pre>
-- >>> -- POST /books
--
-- >>> type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book
-- </pre>
data ReqBody (contentTypes :: [*]) a
module Servant.API.RemoteHost
-- | Provides access to the host or IP address from which the HTTP request
-- was sent.
data RemoteHost
module Servant.API.Raw
-- | Endpoint for plugging in your own Wai <tt>Application</tt>s.
--
-- The given <tt>Application</tt> will get the request as received by the
-- server, potentially with a modified (stripped) <tt>pathInfo</tt> if
-- the <tt>Application</tt> is being routed with <a>:></a>.
--
-- In addition to just letting you plug in your existing WAI
-- <tt>Application</tt>s, this can also be used with
-- <a>serveDirectory</a> to serve static files stored in a particular
-- directory on your filesystem
data Raw
module Servant.API.QueryParam
-- | Lookup a potentially value-less query string parameter with boolean
-- semantics. If the param <tt>sym</tt> is there without any value, or if
-- it's there with value "true" or "1", it's interpreted as <a>True</a>.
-- Otherwise, it's interpreted as <a>False</a>.
--
-- Example:
--
-- <pre>
-- >>> -- /books?published
--
-- >>> type MyApi = "books" :> QueryFlag "published" :> Get '[JSON] [Book]
-- </pre>
data QueryFlag (sym :: Symbol)
-- | Lookup the value associated to the <tt>sym</tt> query string parameter
-- and try to extract it as a value of type <tt>a</tt>.
--
-- Example:
--
-- <pre>
-- >>> -- /books?author=<author name>
--
-- >>> type MyApi = "books" :> QueryParam "author" Text :> Get '[JSON] [Book]
-- </pre>
data QueryParam (sym :: Symbol) a
-- | Lookup the values associated to the <tt>sym</tt> query string
-- parameter and try to extract it as a value of type <tt>[a]</tt>. This
-- is typically meant to support query string parameters of the form
-- <tt>param[]=val1&param[]=val2</tt> and so on. Note that servant
-- doesn't actually require the <tt>[]</tt>s and will fetch the values
-- just fine with <tt>param=val1&param=val2</tt>, too.
--
-- Example:
--
-- <pre>
-- >>> -- /books?authors[]=<author1>&authors[]=<author2>&...
--
-- >>> type MyApi = "books" :> QueryParams "authors" Text :> Get '[JSON] [Book]
-- </pre>
data QueryParams (sym :: Symbol) a
module Servant.API.IsSecure
-- | Was this request made over an SSL connection?
--
-- Note that this value will not tell you if the client originally made
-- this request over SSL, but rather whether the current connection is
-- SSL. The distinction lies with reverse proxies. In many cases, the
-- client will connect to a load balancer over SSL, but connect to the
-- WAI handler without SSL. In such a case, the handlers would get
-- <a>NotSecure</a>, but from a user perspective, there is a secure
-- connection.
data IsSecure
-- | the connection to the server is secure (HTTPS)
Secure :: IsSecure
-- | the connection to the server is not secure (HTTP)
NotSecure :: IsSecure
instance GHC.Classes.Ord Servant.API.IsSecure.IsSecure
instance GHC.Generics.Generic Servant.API.IsSecure.IsSecure
instance GHC.Read.Read Servant.API.IsSecure.IsSecure
instance GHC.Show.Show Servant.API.IsSecure.IsSecure
instance GHC.Classes.Eq Servant.API.IsSecure.IsSecure
module Servant.API.HttpVersion
-- | HTTP Version.
--
-- Note that the Show instance is intended merely for debugging.
data HttpVersion :: *
HttpVersion :: ~Int -> ~Int -> HttpVersion
[httpMajor] :: HttpVersion -> ~Int
[httpMinor] :: HttpVersion -> ~Int
module Servant.API.Header
-- | Extract the given header's value as a value of type <tt>a</tt>.
--
-- Example:
--
-- <pre>
-- >>> newtype Referer = Referer Text deriving (Eq, Show)
--
-- >>>
--
-- >>> -- GET /view-my-referer
--
-- >>> type MyApi = "view-my-referer" :> Header "from" Referer :> Get '[JSON] Referer
-- </pre>
data Header (sym :: Symbol) a
Header :: a -> Header a
MissingHeader :: Header a
UndecodableHeader :: ByteString -> Header a
instance GHC.Base.Functor (Servant.API.Header.Header sym)
instance GHC.Show.Show a => GHC.Show.Show (Servant.API.Header.Header sym a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Servant.API.Header.Header sym a)
-- | This module provides facilities for adding headers to a response.
--
-- <pre>
-- >>> let headerVal = addHeader "some-url" 5 :: Headers '[Header "Location" String] Int
-- </pre>
--
-- The value is added to the header specified by the type
-- (<tt>Location</tt> in the example above).
module Servant.API.ResponseHeaders
-- | Response Header objects. You should never need to construct one
-- directly. Instead, use <a>addOptionalHeader</a>.
data Headers ls a
Headers :: a -> HList ls -> Headers ls a
-- | The underlying value of a <a>Headers</a>
[getResponse] :: Headers ls a -> a
-- | HList of headers.
[getHeadersHList] :: Headers ls a -> HList ls
class AddHeader h v orig new | h v orig -> new, new -> h, new -> v, new -> orig
-- | <tt>addHeader</tt> adds a header to a response. Note that it changes
-- the type of the value in the following ways:
--
-- <ol>
-- <li>A simple value is wrapped in "Headers '[hdr]":</li>
-- </ol>
--
-- <pre>
-- >>> let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
--
-- >>> getHeaders example1
-- [("someheader","5")]
-- </pre>
--
-- <ol>
-- <li>A value that already has a header has its new header *prepended*
-- to the existing list:</li>
-- </ol>
--
-- <pre>
-- >>> let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
--
-- >>> let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] String
--
-- >>> getHeaders example2
-- [("1st","true"),("someheader","5")]
-- </pre>
--
-- Note that while in your handlers type annotations are not required,
-- since the type can be inferred from the API type, in other cases you
-- may find yourself needing to add annotations.
addHeader :: AddHeader h v orig new => v -> orig -> new
-- | Deliberately do not add a header to a value.
--
-- <pre>
-- >>> let example1 = noHeader "hi" :: Headers '[Header "someheader" Int] String
--
-- >>> getHeaders example1
-- []
-- </pre>
noHeader :: AddHeader h v orig new => orig -> new
class BuildHeadersTo hs
-- | Note: if there are multiple occurences of a header in the argument,
-- the values are interspersed with commas before deserialization (see
-- <a>RFC2616 Sec 4.2</a>)
buildHeadersTo :: BuildHeadersTo hs => [Header] -> HList hs
class GetHeaders ls
getHeaders :: GetHeaders ls => ls -> [Header]
data HList a
[HNil] :: HList '[]
[HCons] :: Header h x -> HList xs -> HList (Header h x : xs)
instance GHC.Base.Functor (Servant.API.ResponseHeaders.Headers ls)
instance Servant.API.ResponseHeaders.BuildHeadersTo '[]
instance (Web.Internal.HttpApiData.FromHttpApiData v, Servant.API.ResponseHeaders.BuildHeadersTo xs, GHC.TypeLits.KnownSymbol h) => Servant.API.ResponseHeaders.BuildHeadersTo (Servant.API.Header.Header h v : xs)
instance Servant.API.ResponseHeaders.GetHeaders (Servant.API.ResponseHeaders.HList '[])
instance (GHC.TypeLits.KnownSymbol h, Web.Internal.HttpApiData.ToHttpApiData x, Servant.API.ResponseHeaders.GetHeaders (Servant.API.ResponseHeaders.HList xs)) => Servant.API.ResponseHeaders.GetHeaders (Servant.API.ResponseHeaders.HList (Servant.API.Header.Header h x : xs))
instance Servant.API.ResponseHeaders.GetHeaders (Servant.API.ResponseHeaders.Headers '[] a)
instance (GHC.TypeLits.KnownSymbol h, Servant.API.ResponseHeaders.GetHeaders (Servant.API.ResponseHeaders.HList rest), Web.Internal.HttpApiData.ToHttpApiData v) => Servant.API.ResponseHeaders.GetHeaders (Servant.API.ResponseHeaders.Headers (Servant.API.Header.Header h v : rest) a)
instance (GHC.TypeLits.KnownSymbol h, Web.Internal.HttpApiData.ToHttpApiData v) => Servant.API.ResponseHeaders.AddHeader h v (Servant.API.ResponseHeaders.Headers (fst : rest) a) (Servant.API.ResponseHeaders.Headers (Servant.API.Header.Header h v : fst : rest) a)
instance (GHC.TypeLits.KnownSymbol h, Web.Internal.HttpApiData.ToHttpApiData v, new ~ Servant.API.ResponseHeaders.Headers '[Servant.API.Header.Header h v] a) => Servant.API.ResponseHeaders.AddHeader h v a new
module Servant.API.Experimental.Auth
-- | A generalized Authentication combinator. Use this if you have a
-- non-standard authentication technique.
--
-- NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE.
data AuthProtect (tag :: k)
module Servant.API.Empty
-- | An empty API: one which serves nothing. Morally speaking, this should
-- be the unit of <tt>:<|></tt>. Implementors of interpretations of
-- API types should treat <a>EmptyAPI</a> as close to the unit as
-- possible.
data EmptyAPI
EmptyAPI :: EmptyAPI
instance GHC.Enum.Enum Servant.API.Empty.EmptyAPI
instance GHC.Enum.Bounded Servant.API.Empty.EmptyAPI
instance GHC.Show.Show Servant.API.Empty.EmptyAPI
instance GHC.Classes.Eq Servant.API.Empty.EmptyAPI
-- | A collection of basic Content-Types (also known as Internet Media
-- Types, or MIME types). Additionally, this module provides classes that
-- encapsulate how to serialize or deserialize values to or from a
-- particular Content-Type.
--
-- Content-Types are used in <tt>ReqBody</tt> and the method combinators:
--
-- <pre>
-- >>> type MyEndpoint = ReqBody '[JSON, PlainText] Book :> Get '[JSON, PlainText] Book
-- </pre>
--
-- Meaning the endpoint accepts requests of Content-Type
-- <tt>application/json</tt> or <tt>text/plain;charset-utf8</tt>, and
-- returns data in either one of those formats (depending on the
-- <tt>Accept</tt> header).
--
-- If you would like to support Content-Types beyond those provided here,
-- then:
--
-- <ol>
-- <li>Declare a new data type with no constructors (e.g. <tt>data
-- HTML</tt>).</li>
-- <li>Make an instance of it for <a>Accept</a>.</li>
-- <li>If you want to be able to serialize data *into* that Content-Type,
-- make an instance of it for <a>MimeRender</a>.</li>
-- <li>If you want to be able to deserialize data *from* that
-- Content-Type, make an instance of it for <a>MimeUnrender</a>.</li>
-- </ol>
--
-- Note that roles are reversed in <tt>servant-server</tt> and
-- <tt>servant-client</tt>: to be able to serve (or even typecheck) a
-- <tt>Get '[JSON, XML] MyData</tt>, you'll need to have the appropriate
-- <a>MimeRender</a> instances in scope, whereas to query that endpoint
-- with <tt>servant-client</tt>, you'll need a <a>MimeUnrender</a>
-- instance in scope.
module Servant.API.ContentTypes
data JSON
data PlainText
data FormUrlEncoded
data OctetStream
-- | Instances of <a>Accept</a> represent mimetypes. They are used for
-- matching against the <tt>Accept</tt> HTTP header of the request, and
-- for setting the <tt>Content-Type</tt> header of the response
--
-- Example:
--
-- <pre>
-- >>> import Network.HTTP.Media ((//), (/:))
--
-- >>> data HTML
--
-- >>> :{
-- instance Accept HTML where
-- contentType _ = "text" // "html" /: ("charset", "utf-8")
-- :}
-- </pre>
class Accept ctype where contentType = head . contentTypes contentTypes = (:| []) . contentType
contentType :: Accept ctype => Proxy ctype -> MediaType
contentTypes :: Accept ctype => Proxy ctype -> NonEmpty MediaType
-- | Instantiate this class to register a way of serializing a type based
-- on the <tt>Accept</tt> header.
--
-- Example:
--
-- <pre>
-- data MyContentType
--
-- instance Accept MyContentType where
-- contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
--
-- instance Show a => MimeRender MyContentType a where
-- mimeRender _ val = pack ("This is MINE! " ++ show val)
--
-- type MyAPI = "path" :> Get '[MyContentType] Int
-- </pre>
class Accept ctype => MimeRender ctype a
mimeRender :: MimeRender ctype a => Proxy ctype -> a -> ByteString
-- | Instantiate this class to register a way of deserializing a type based
-- on the request's <tt>Content-Type</tt> header.
--
-- <pre>
-- >>> import Network.HTTP.Media hiding (Accept)
--
-- >>> import qualified Data.ByteString.Lazy.Char8 as BSC
--
-- >>> data MyContentType = MyContentType String
-- </pre>
--
-- <pre>
-- >>> :{
-- instance Accept MyContentType where
-- contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
-- :}
-- </pre>
--
-- <pre>
-- >>> :{
-- instance Read a => MimeUnrender MyContentType a where
-- mimeUnrender _ bs = case BSC.take 12 bs of
-- "MyContentType" -> return . read . BSC.unpack $ BSC.drop 12 bs
-- _ -> Left "didn't start with the magic incantation"
-- :}
-- </pre>
--
-- <pre>
-- >>> type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int
-- </pre>
class Accept ctype => MimeUnrender ctype a where mimeUnrender p = mimeUnrenderWithType p (contentType p) mimeUnrenderWithType p _ = mimeUnrender p
mimeUnrender :: MimeUnrender ctype a => Proxy ctype -> ByteString -> Either String a
-- | Variant which is given the actual <a>MediaType</a> provided by the
-- other party.
--
-- In the most cases you don't want to branch based on the
-- <a>MediaType</a>. See <a>pr552</a> for a motivating example.
mimeUnrenderWithType :: MimeUnrender ctype a => Proxy ctype -> MediaType -> ByteString -> Either String a
-- | A type for responses without content-body.
data NoContent
NoContent :: NoContent
newtype AcceptHeader
AcceptHeader :: ByteString -> AcceptHeader
class (AllMime list) => AllCTRender (list :: [*]) a
handleAcceptH :: AllCTRender list a => Proxy list -> AcceptHeader -> a -> Maybe (ByteString, ByteString)
class AllCTUnrender (list :: [*]) a where handleCTypeH p ctypeH body = ($ body) `fmap` canHandleCTypeH p ctypeH
canHandleCTypeH :: AllCTUnrender list a => Proxy list -> ByteString -> Maybe (ByteString -> Either String a)
handleCTypeH :: AllCTUnrender list a => Proxy list -> ByteString -> ByteString -> Maybe (Either String a)
class AllMime (list :: [*])
allMime :: AllMime list => Proxy list -> [MediaType]
class (AllMime list) => AllMimeRender (list :: [*]) a
allMimeRender :: AllMimeRender list a => Proxy list -> a -> [(MediaType, ByteString)]
class (AllMime list) => AllMimeUnrender (list :: [*]) a
allMimeUnrender :: AllMimeUnrender list a => Proxy list -> [(MediaType, ByteString -> Either String a)]
-- | Like <a>eitherDecode</a> but allows all JSON values instead of just
-- objects and arrays.
--
-- Will handle trailing whitespace, but not trailing junk. ie.
--
-- <pre>
-- >>> eitherDecodeLenient "1 " :: Either String Int
-- Right 1
-- </pre>
--
-- <pre>
-- >>> eitherDecodeLenient "1 junk" :: Either String Int
-- Left "trailing junk after valid JSON: endOfInput"
-- </pre>
eitherDecodeLenient :: FromJSON a => ByteString -> Either String a
canHandleAcceptH :: AllMime list => Proxy list -> AcceptHeader -> Bool
instance GHC.Generics.Generic Servant.API.ContentTypes.NoContent
instance GHC.Read.Read Servant.API.ContentTypes.NoContent
instance GHC.Classes.Eq Servant.API.ContentTypes.NoContent
instance GHC.Show.Show Servant.API.ContentTypes.NoContent
instance GHC.Generics.Generic Servant.API.ContentTypes.AcceptHeader
instance GHC.Read.Read Servant.API.ContentTypes.AcceptHeader
instance GHC.Show.Show Servant.API.ContentTypes.AcceptHeader
instance GHC.Classes.Eq Servant.API.ContentTypes.AcceptHeader
instance Servant.API.ContentTypes.Accept Servant.API.ContentTypes.JSON
instance Servant.API.ContentTypes.Accept Servant.API.ContentTypes.FormUrlEncoded
instance Servant.API.ContentTypes.Accept Servant.API.ContentTypes.PlainText
instance Servant.API.ContentTypes.Accept Servant.API.ContentTypes.OctetStream
instance (Servant.API.ContentTypes.Accept ct, Servant.API.ContentTypes.AllMime cts, Servant.API.ContentTypes.AllMimeRender (ct : cts) a) => Servant.API.ContentTypes.AllCTRender (ct : cts) a
instance (TypeError ...) => Servant.API.ContentTypes.AllCTRender '[] ()
instance Servant.API.ContentTypes.AllMimeUnrender ctyps a => Servant.API.ContentTypes.AllCTUnrender ctyps a
instance Servant.API.ContentTypes.AllMime '[]
instance (Servant.API.ContentTypes.Accept ctyp, Servant.API.ContentTypes.AllMime ctyps) => Servant.API.ContentTypes.AllMime (ctyp : ctyps)
instance Servant.API.ContentTypes.MimeRender ctyp a => Servant.API.ContentTypes.AllMimeRender '[ctyp] a
instance (Servant.API.ContentTypes.MimeRender ctyp a, Servant.API.ContentTypes.AllMimeRender (ctyp' : ctyps) a) => Servant.API.ContentTypes.AllMimeRender (ctyp : ctyp' : ctyps) a
instance Servant.API.ContentTypes.Accept ctyp => Servant.API.ContentTypes.AllMimeRender '[ctyp] Servant.API.ContentTypes.NoContent
instance Servant.API.ContentTypes.AllMime (ctyp : ctyp' : ctyps) => Servant.API.ContentTypes.AllMimeRender (ctyp : ctyp' : ctyps) Servant.API.ContentTypes.NoContent
instance Servant.API.ContentTypes.AllMimeUnrender '[] a
instance (Servant.API.ContentTypes.MimeUnrender ctyp a, Servant.API.ContentTypes.AllMimeUnrender ctyps a) => Servant.API.ContentTypes.AllMimeUnrender (ctyp : ctyps) a
instance Data.Aeson.Types.ToJSON.ToJSON a => Servant.API.ContentTypes.MimeRender Servant.API.ContentTypes.JSON a
instance Web.Internal.FormUrlEncoded.ToForm a => Servant.API.ContentTypes.MimeRender Servant.API.ContentTypes.FormUrlEncoded a
instance Servant.API.ContentTypes.MimeRender Servant.API.ContentTypes.PlainText Data.Text.Internal.Lazy.Text
instance Servant.API.ContentTypes.MimeRender Servant.API.ContentTypes.PlainText Data.Text.Internal.Text
instance Servant.API.ContentTypes.MimeRender Servant.API.ContentTypes.PlainText GHC.Base.String
instance Servant.API.ContentTypes.MimeRender Servant.API.ContentTypes.OctetStream Data.ByteString.Lazy.Internal.ByteString
instance Servant.API.ContentTypes.MimeRender Servant.API.ContentTypes.OctetStream Data.ByteString.Internal.ByteString
instance Data.Aeson.Types.FromJSON.FromJSON a => Servant.API.ContentTypes.MimeUnrender Servant.API.ContentTypes.JSON a
instance Web.Internal.FormUrlEncoded.FromForm a => Servant.API.ContentTypes.MimeUnrender Servant.API.ContentTypes.FormUrlEncoded a
instance Servant.API.ContentTypes.MimeUnrender Servant.API.ContentTypes.PlainText Data.Text.Internal.Lazy.Text
instance Servant.API.ContentTypes.MimeUnrender Servant.API.ContentTypes.PlainText Data.Text.Internal.Text
instance Servant.API.ContentTypes.MimeUnrender Servant.API.ContentTypes.PlainText GHC.Base.String
instance Servant.API.ContentTypes.MimeUnrender Servant.API.ContentTypes.OctetStream Data.ByteString.Lazy.Internal.ByteString
instance Servant.API.ContentTypes.MimeUnrender Servant.API.ContentTypes.OctetStream Data.ByteString.Internal.ByteString
module Servant.API.Capture
-- | Capture a value from the request path under a certain type <tt>a</tt>.
--
-- Example:
--
-- <pre>
-- >>> -- GET /books/:isbn
--
-- >>> type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book
-- </pre>
data Capture (sym :: Symbol) a
-- | Capture all remaining values from the request path under a certain
-- type <tt>a</tt>.
--
-- Example:
--
-- <pre>
-- >>> -- GET /src/*
--
-- >>> type MyAPI = "src" :> CaptureAll "segments" Text :> Get '[JSON] SourceFile
-- </pre>
data CaptureAll (sym :: Symbol) a
module Servant.API.BasicAuth
-- | Combinator for <a>Basic Access Authentication</a>.
--
-- <ul>
-- <li>IMPORTANT*: Only use Basic Auth over HTTPS! Credentials are not
-- hashed or encrypted. Note also that because the same credentials are
-- sent on every request, Basic Auth is not as secure as some
-- alternatives. Further, the implementation in servant-server does not
-- protect against some types of timing attacks.</li>
-- </ul>
--
-- In Basic Auth, username and password are base64-encoded and
-- transmitted via the <tt>Authorization</tt> header. Handshakes are not
-- required, making it relatively efficient.
data BasicAuth (realm :: Symbol) (userData :: *)
-- | A simple datatype to hold data required to decorate a request
data BasicAuthData
BasicAuthData :: !ByteString -> !ByteString -> BasicAuthData
[basicAuthUsername] :: BasicAuthData -> !ByteString
[basicAuthPassword] :: BasicAuthData -> !ByteString
module Servant.API.Alternative
-- | Union of two APIs, first takes precedence in case of overlap.
--
-- Example:
--
-- <pre>
-- >>> :{
-- type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
-- :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] () -- POST /books
-- :}
-- </pre>
data (:<|>) a b
(:<|>) :: a -> b -> (:<|>) a b
instance (GHC.Enum.Bounded b, GHC.Enum.Bounded a) => GHC.Enum.Bounded (a Servant.API.Alternative.:<|> b)
instance Data.Foldable.Foldable ((Servant.API.Alternative.:<|>) a)
instance Data.Traversable.Traversable ((Servant.API.Alternative.:<|>) a)
instance GHC.Base.Functor ((Servant.API.Alternative.:<|>) a)
instance (GHC.Show.Show b, GHC.Show.Show a) => GHC.Show.Show (a Servant.API.Alternative.:<|> b)
instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (a Servant.API.Alternative.:<|> b)
instance (Data.Semigroup.Semigroup a, Data.Semigroup.Semigroup b) => Data.Semigroup.Semigroup (a Servant.API.Alternative.:<|> b)
instance (GHC.Base.Monoid a, GHC.Base.Monoid b) => GHC.Base.Monoid (a Servant.API.Alternative.:<|> b)
-- | This module collects utilities for manipulating <tt>servant</tt> API
-- types. The functionality in this module is for advanced usage.
--
-- The code samples in this module use the following type synonym:
--
-- <pre>
-- type SampleAPI = "hello" :> Get '[JSON] Int
-- :<|> "bye" :> Capture "name" String :> Post '[JSON, PlainText] Bool
-- </pre>
module Servant.API.TypeLevel
-- | Flatten API into a list of endpoints.
--
-- <pre>
-- >>> Refl :: Endpoints SampleAPI :~: '["hello" :> Verb 'GET 200 '[JSON] Int, "bye" :> (Capture "name" String :> Verb 'POST 200 '[JSON, PlainText] Bool)]
-- Refl
-- </pre>
-- | You may use this type family to tell the type checker that your custom
-- type may be skipped as part of a link. This is useful for things like
-- <tt><a>QueryParam</a></tt> that are optional in a URI and do not
-- affect them if they are omitted.
--
-- <pre>
-- >>> data CustomThing
--
-- >>> type instance IsElem' e (CustomThing :> s) = IsElem e s
-- </pre>
--
-- Note that <tt><a>IsElem</a></tt> is called, which will mutually
-- recurse back to <tt><a>IsElem'</a></tt> if it exhausts all other
-- options again.
--
-- Once you have written a <tt>HasLink</tt> instance for
-- <tt>CustomThing</tt> you are ready to go.
-- | Closed type family, check if <tt>endpoint</tt> is within <tt>api</tt>.
-- Uses <tt><a>IsElem'</a></tt> if it exhausts all other options.
--
-- <pre>
-- >>> ok (Proxy :: Proxy (IsElem ("hello" :> Get '[JSON] Int) SampleAPI))
-- OK
-- </pre>
--
-- <pre>
-- >>> ok (Proxy :: Proxy (IsElem ("bye" :> Get '[JSON] Int) SampleAPI))
-- ...
-- ... Could not deduce...
-- ...
-- </pre>
--
-- An endpoint is considered within an api even if it is missing
-- combinators that don't affect the URL:
--
-- <pre>
-- >>> ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (Header "h" Bool :> Get '[JSON] Int)))
-- OK
-- </pre>
--
-- <pre>
-- >>> ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (ReqBody '[JSON] Bool :> Get '[JSON] Int)))
-- OK
-- </pre>
--
-- <ul>
-- <li>N.B.:* <tt>IsElem a b</tt> can be seen as capturing the notion of
-- whether the URL represented by <tt>a</tt> would match the URL
-- represented by <tt>b</tt>, *not* whether a request represented by
-- <tt>a</tt> matches the endpoints serving <tt>b</tt> (for the latter,
-- use <a>IsIn</a>).</li>
-- </ul>
-- | Check whether <tt>sub</tt> is a sub-API of <tt>api</tt>.
--
-- <pre>
-- >>> ok (Proxy :: Proxy (IsSubAPI SampleAPI (SampleAPI :<|> Get '[JSON] Int)))
-- OK
-- </pre>
--
-- <pre>
-- >>> ok (Proxy :: Proxy (IsSubAPI (SampleAPI :<|> Get '[JSON] Int) SampleAPI))
-- ...
-- ... Could not deduce...
-- ...
-- </pre>
--
-- This uses <tt>IsElem</tt> for checking; thus the note there applies
-- here.
-- | Check that every element of <tt>xs</tt> is an endpoint of <tt>api</tt>
-- (using <tt><a>IsElem</a></tt>).
-- | Closed type family, check if <tt>endpoint</tt> is exactly within
-- <tt>api</tt>.
--
-- <pre>
-- >>> ok (Proxy :: Proxy (IsIn ("hello" :> Get '[JSON] Int) SampleAPI))
-- OK
-- </pre>
--
-- Unlike <a>IsElem</a>, this requires an *exact* match.
--
-- <pre>
-- >>> ok (Proxy :: Proxy (IsIn (Get '[JSON] Int) (Header "h" Bool :> Get '[JSON] Int)))
-- ...
-- ... Could not deduce...
-- ...
-- </pre>
-- | Check whether <tt>sub</tt> is a sub API of <tt>api</tt>.
--
-- Like <a>IsSubAPI</a>, but uses <a>IsIn</a> rather than <a>IsElem</a>.
-- | Check that every element of <tt>xs</tt> is an endpoint of <tt>api</tt>
-- (using <tt><a>IsIn</a></tt>).
--
-- ok (Proxy :: Proxy (AllIsIn (Endpoints SampleAPI) SampleAPI)) OK
-- | Apply <tt>(e :>)</tt> to every API in <tt>xs</tt>.
-- | Append two type-level lists.
-- | Check that a value is an element of a list:
--
-- <pre>
-- >>> ok (Proxy :: Proxy (Elem Bool '[Int, Bool]))
-- OK
-- </pre>
--
-- <pre>
-- >>> ok (Proxy :: Proxy (Elem String '[Int, Bool]))
-- ...
-- ... [Char]...'[Int, Bool...
-- ...
-- </pre>
type Elem e es = ElemGo e es es
-- | If either a or b produce an empty constraint, produce an empty
-- constraint.
-- | If both a or b produce an empty constraint, produce an empty
-- constraint.
-- | Type safe generation of internal links.
--
-- Given an API with a few endpoints:
--
-- <pre>
-- >>> :set -XDataKinds -XTypeFamilies -XTypeOperators
--
-- >>> import Servant.API
--
-- >>> import Servant.Utils.Links
--
-- >>> import Data.Proxy
--
-- >>>
--
-- >>>
--
-- >>>
--
-- >>> type Hello = "hello" :> Get '[JSON] Int
--
-- >>> type Bye = "bye" :> QueryParam "name" String :> Delete '[JSON] NoContent
--
-- >>> type API = Hello :<|> Bye
--
-- >>> let api = Proxy :: Proxy API
-- </pre>
--
-- It is possible to generate links that are guaranteed to be within
-- <tt>API</tt> with <a>safeLink</a>. The first argument to
-- <a>safeLink</a> is a type representing the API you would like to
-- restrict links to. The second argument is the destination endpoint you
-- would like the link to point to, this will need to end with a verb
-- like GET or POST. Further arguments may be required depending on the
-- type of the endpoint. If everything lines up you will get a
-- <a>Link</a> out the other end.
--
-- You may omit <a>QueryParam</a>s and the like should you not want to
-- provide them, but types which form part of the URL path like
-- <a>Capture</a> must be included. The reason you may want to omit
-- <a>QueryParam</a>s is that safeLink is a bit magical: if parameters
-- are included that could take input it will return a function that
-- accepts that input and generates a link. This is best shown with an
-- example. Here, a link is generated with no parameters:
--
-- <pre>
-- >>> let hello = Proxy :: Proxy ("hello" :> Get '[JSON] Int)
--
-- >>> toUrlPiece (safeLink api hello :: Link)
-- "hello"
-- </pre>
--
-- If the API has an endpoint with parameters then we can generate links
-- with or without those:
--
-- <pre>
-- >>> let with = Proxy :: Proxy ("bye" :> QueryParam "name" String :> Delete '[JSON] NoContent)
--
-- >>> toUrlPiece $ safeLink api with (Just "Hubert")
-- "bye?name=Hubert"
-- </pre>
--
-- <pre>
-- >>> let without = Proxy :: Proxy ("bye" :> Delete '[JSON] NoContent)
--
-- >>> toUrlPiece $ safeLink api without
-- "bye"
-- </pre>
--
-- If you would like create a helper for generating links only within
-- that API, you can partially apply safeLink if you specify a correct
-- type signature like so:
--
-- <pre>
-- >>> :set -XConstraintKinds
--
-- >>> :{
--
-- >>> let apiLink :: (IsElem endpoint API, HasLink endpoint)
--
-- >>> => Proxy endpoint -> MkLink endpoint
--
-- >>> apiLink = safeLink api
--
-- >>> :}
-- </pre>
--
-- Attempting to construct a link to an endpoint that does not exist in
-- api will result in a type error like this:
--
-- <pre>
-- >>> let bad_link = Proxy :: Proxy ("hello" :> Delete '[JSON] NoContent)
--
-- >>> safeLink api bad_link
-- ...
-- ...Could not deduce...
-- ...
-- </pre>
--
-- This error is essentially saying that the type family couldn't find
-- bad_link under api after trying the open (but empty) type family
-- <a>IsElem'</a> as a last resort.
module Servant.Utils.Links
-- | Create a valid (by construction) relative URI with query params.
--
-- This function will only typecheck if <tt>endpoint</tt> is part of the
-- API <tt>api</tt>
safeLink :: forall endpoint api. (IsElem endpoint api, HasLink endpoint) => Proxy api -> Proxy endpoint -> MkLink endpoint
-- | Represents a general universal resource identifier using its component
-- parts.
--
-- For example, for the URI
--
-- <pre>
-- foo://anonymous@www.haskell.org:42/ghc?query#frag
-- </pre>
--
-- the components are:
data URI :: *
URI :: String -> Maybe URIAuth -> String -> String -> String -> URI
-- | <pre>
-- foo:
-- </pre>
[uriScheme] :: URI -> String
-- | <pre>
-- //anonymous@www.haskell.org:42
-- </pre>
[uriAuthority] :: URI -> Maybe URIAuth
-- | <pre>
-- /ghc
-- </pre>
[uriPath] :: URI -> String
-- | <pre>
-- ?query
-- </pre>
[uriQuery] :: URI -> String
-- | <pre>
-- #frag
-- </pre>
[uriFragment] :: URI -> String
-- | Construct a toLink for an endpoint.
class HasLink endpoint where type MkLink endpoint where {
type family MkLink endpoint;
}
toLink :: HasLink endpoint => Proxy endpoint -> Link -> MkLink endpoint
-- | A safe link datatype. The only way of constructing a <a>Link</a> is
-- using <a>safeLink</a>, which means any <a>Link</a> is guaranteed to be
-- part of the mentioned API.
data Link
-- | Transform <a>Link</a> into <a>URI</a>.
--
-- <pre>
-- >>> type API = "something" :> Get '[JSON] Int
--
-- >>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API)
-- something
-- </pre>
--
-- <pre>
-- >>> type API = "sum" :> QueryParams "x" Int :> Get '[JSON] Int
--
-- >>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
-- sum?x[]=1&x[]=2&x[]=3
-- </pre>
--
-- <pre>
-- >>> type API = "foo/bar" :> Get '[JSON] Int
--
-- >>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API)
-- foo%2Fbar
-- </pre>
linkURI :: Link -> URI
-- | Configurable <a>linkURI</a>.
--
-- <pre>
-- >>> type API = "sum" :> QueryParams "x" Int :> Get '[JSON] Int
--
-- >>> linkURI' LinkArrayElementBracket $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
-- sum?x[]=1&x[]=2&x[]=3
-- </pre>
--
-- <pre>
-- >>> linkURI' LinkArrayElementPlain $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
-- sum?x=1&x=2&x=3
-- </pre>
linkURI' :: LinkArrayElementStyle -> Link -> URI
-- | How to encode array query elements.
data LinkArrayElementStyle
-- | <pre>
-- foo[]=1&foo[]=2
-- </pre>
LinkArrayElementBracket :: LinkArrayElementStyle
-- | <pre>
-- foo=1&foo=2
-- </pre>
LinkArrayElementPlain :: LinkArrayElementStyle
-- | Query parameter.
data Param
SingleParam :: String -> Text -> Param
ArrayElemParam :: String -> Text -> Param
FlagParam :: String -> Param
linkSegments :: Link -> [String]
linkQueryParams :: Link -> [Param]
instance GHC.Enum.Bounded Servant.Utils.Links.LinkArrayElementStyle
instance GHC.Enum.Enum Servant.Utils.Links.LinkArrayElementStyle
instance GHC.Show.Show Servant.Utils.Links.LinkArrayElementStyle
instance GHC.Classes.Ord Servant.Utils.Links.LinkArrayElementStyle
instance GHC.Classes.Eq Servant.Utils.Links.LinkArrayElementStyle
instance GHC.Show.Show Servant.Utils.Links.Link
instance GHC.Show.Show Servant.Utils.Links.Param
instance Web.Internal.HttpApiData.ToHttpApiData Servant.Utils.Links.Link
instance forall k (sym :: GHC.Types.Symbol) (sub :: k). (GHC.TypeLits.KnownSymbol sym, Servant.Utils.Links.HasLink sub) => Servant.Utils.Links.HasLink (sym Servant.API.Sub.:> sub)
instance forall k (sym :: GHC.Types.Symbol) v (sub :: k). (GHC.TypeLits.KnownSymbol sym, Web.Internal.HttpApiData.ToHttpApiData v, Servant.Utils.Links.HasLink sub) => Servant.Utils.Links.HasLink (Servant.API.QueryParam.QueryParam sym v Servant.API.Sub.:> sub)
instance forall k (sym :: GHC.Types.Symbol) v (sub :: k). (GHC.TypeLits.KnownSymbol sym, Web.Internal.HttpApiData.ToHttpApiData v, Servant.Utils.Links.HasLink sub) => Servant.Utils.Links.HasLink (Servant.API.QueryParam.QueryParams sym v Servant.API.Sub.:> sub)
instance forall k (sym :: GHC.Types.Symbol) (sub :: k). (GHC.TypeLits.KnownSymbol sym, Servant.Utils.Links.HasLink sub) => Servant.Utils.Links.HasLink (Servant.API.QueryParam.QueryFlag sym Servant.API.Sub.:> sub)
instance forall k k1 (sub :: k1) (ct :: [GHC.Types.*]) (a :: k). Servant.Utils.Links.HasLink sub => Servant.Utils.Links.HasLink (Servant.API.ReqBody.ReqBody ct a Servant.API.Sub.:> sub)
instance forall k v (sub :: k) (sym :: GHC.Types.Symbol). (Web.Internal.HttpApiData.ToHttpApiData v, Servant.Utils.Links.HasLink sub) => Servant.Utils.Links.HasLink (Servant.API.Capture.Capture sym v Servant.API.Sub.:> sub)
instance forall k v (sub :: k) (sym :: GHC.Types.Symbol). (Web.Internal.HttpApiData.ToHttpApiData v, Servant.Utils.Links.HasLink sub) => Servant.Utils.Links.HasLink (Servant.API.Capture.CaptureAll sym v Servant.API.Sub.:> sub)
instance forall k (sub :: k) (sym :: GHC.Types.Symbol) a. Servant.Utils.Links.HasLink sub => Servant.Utils.Links.HasLink (Servant.API.Header.Header sym a Servant.API.Sub.:> sub)
instance forall k (sub :: k). Servant.Utils.Links.HasLink sub => Servant.Utils.Links.HasLink (Servant.API.RemoteHost.RemoteHost Servant.API.Sub.:> sub)
instance forall k (sub :: k) (realm :: GHC.Types.Symbol) a. Servant.Utils.Links.HasLink sub => Servant.Utils.Links.HasLink (Servant.API.BasicAuth.BasicAuth realm a Servant.API.Sub.:> sub)
instance forall k k1 (m :: k1) (s :: GHC.Types.Nat) (ct :: [GHC.Types.*]) (a :: k). Servant.Utils.Links.HasLink (Servant.API.Verbs.Verb m s ct a)
instance Servant.Utils.Links.HasLink Servant.API.Raw.Raw
instance forall k k1 (sub :: k1) (tag :: k). Servant.Utils.Links.HasLink sub => Servant.Utils.Links.HasLink (Servant.API.Experimental.Auth.AuthProtect tag Servant.API.Sub.:> sub)
module Servant.API
-- | This is a module containing an API with all <a>API</a> combinators. It
-- is used for testing only (in particular, checking that instances exist
-- for the core servant classes for each combinator), and should not be
-- imported.
module Servant.API.Internal.Test.ComprehensiveAPI
type GET = Get '[JSON] NoContent
type ComprehensiveAPI = ComprehensiveAPIWithoutRaw :<|> Raw
comprehensiveAPI :: Proxy ComprehensiveAPI
type ComprehensiveAPIWithoutRaw = GET :<|> (Get '[JSON] Int :<|> ((Capture "foo" Int :> GET) :<|> ((Header "foo" Int :> GET) :<|> ((HttpVersion :> GET) :<|> ((IsSecure :> GET) :<|> ((QueryParam "foo" Int :> GET) :<|> ((QueryParams "foo" Int :> GET) :<|> ((QueryFlag "foo" :> GET) :<|> ((RemoteHost :> GET) :<|> ((ReqBody '[JSON] Int :> GET) :<|> (Get '[JSON] (Headers '[Header "foo" Int] NoContent) :<|> (("foo" :> GET) :<|> ((Vault :> GET) :<|> (Verb POST 204 '[JSON] NoContent :<|> (Verb POST 204 '[JSON] Int :<|> (WithNamedContext "foo" '[] GET :<|> ((CaptureAll "foo" Int :> GET) :<|> EmptyAPI)))))))))))))))))
comprehensiveAPIWithoutRaw :: Proxy ComprehensiveAPIWithoutRaw
module Servant.Utils.Enter
-- | Helper type family to state the <a>Enter</a> symmetry.
class (Entered m n typ ~ ret, Entered n m ret ~ typ) => Enter typ m n ret | typ m n -> ret, ret m n -> typ, ret typ m -> n, ret typ n -> m
-- | Map the leafs of an API type.
enter :: Enter typ m n ret => (m :~> n) -> typ -> ret
-- | Like <a>lift</a>.
liftNat :: (MonadTrans t, Monad m) => m :~> t m
runReaderTNat :: r -> (ReaderT r m :~> m)
evalStateTLNat :: Monad m => s -> (StateT s m :~> m)
evalStateTSNat :: Monad m => s -> (StateT s m :~> m)
-- | Log the contents of <a>WriterT</a> with the function provided as the
-- first argument, and return the value of the <tt>WriterT</tt>
-- computation
logWriterTSNat :: MonadIO m => (w -> IO ()) -> (WriterT w m :~> m)
-- | Like <a>logWriterTSNat</a>, but for lazy <tt>WriterT</tt>.
logWriterTLNat :: MonadIO m => (w -> IO ()) -> (WriterT w m :~> m)
-- | Like <tt>mmorph</tt>'s <a>hoist</a>.
hoistNat :: (MFunctor t, Monad m) => (m :~> n) -> (t m :~> t n)
-- | Like <tt>mmorph</tt>'s <a>embed</a>.
embedNat :: (MMonad t, Monad n) => (m :~> t n) -> (t m :~> t n)
-- | Like <tt>mmorph</tt>'s <a>squash</a>.
squashNat :: (Monad m, MMonad t) => t (t m) :~> t m
-- | Like <tt>mmorph</tt>'s <a>generalize</a>.
generalizeNat :: Applicative m => Identity :~> m
-- | A natural transformation suitable for storing in a container.
newtype (:~>) k (f :: k -> *) (g :: k -> *) :: forall k. (k -> *) -> (k -> *) -> *
NT :: (~>) k f g -> (:~>) k
[$$] :: (:~>) k -> (~>) k f g
instance (Servant.Utils.Enter.Enter typ1 m1 n1 ret1, Servant.Utils.Enter.Enter typ2 m2 n2 ret2, m1 ~ m2, n1 ~ n2, Servant.Utils.Enter.Entered m1 n1 (typ1 Servant.API.Alternative.:<|> typ2) ~ (ret1 Servant.API.Alternative.:<|> ret2), Servant.Utils.Enter.Entered n1 m1 (ret1 Servant.API.Alternative.:<|> ret2) ~ (typ1 Servant.API.Alternative.:<|> typ2)) => Servant.Utils.Enter.Enter (typ1 Servant.API.Alternative.:<|> typ2) m1 n1 (ret1 Servant.API.Alternative.:<|> ret2)
instance (Servant.Utils.Enter.Enter typ m n ret, Servant.Utils.Enter.Entered m n (a -> typ) ~ (a -> ret), Servant.Utils.Enter.Entered n m (a -> ret) ~ (a -> typ)) => Servant.Utils.Enter.Enter (a -> typ) m n (a -> ret)
instance (Servant.Utils.Enter.Entered m n (Data.Tagged.Tagged m a) ~ Data.Tagged.Tagged n a, Servant.Utils.Enter.Entered n m (Data.Tagged.Tagged n a) ~ Data.Tagged.Tagged m a) => Servant.Utils.Enter.Enter (Data.Tagged.Tagged m a) m n (Data.Tagged.Tagged n a)
instance (Servant.Utils.Enter.Entered m n (m a) ~ n a, Servant.Utils.Enter.Entered n m (n a) ~ m a) => Servant.Utils.Enter.Enter (m a) m n (n a)
|