@@ -66,9 +66,9 @@ a server for `FactoringAPI` (without the `'`) reflects the
66
66
server must be a function that takes an `Int` (the `Capture`) and
67
67
returns two values glued with `:<|>`, one of type `Maybe Int -> Handler Int`
68
68
and the other of type `Handler Int`. Let's provide such a server
69
- implementation.
69
+ implementation, with those "nested types" .
70
70
71
- _Note_ : you can load this module in ghci and ask for the concrete
71
+ **Tip** : you can load this module in ghci and ask for the concrete
72
72
type that `Server FactoringAPI` "resolves to" by typing
73
73
`:kind! Server FactoringAPI`.
74
74
@@ -82,6 +82,16 @@ factoringServer x = getXY :<|> postX
82
82
postX = return (x - 1)
83
83
`` `
84
84
85
+ If you want to avoid the " nested types" and the need to manually
86
+ dispatch the arguments (like `x` above) to the different request
87
+ handlers, and would just like to be able to declare the API type
88
+ as above but pretending that the `Capture` is not factored out,
89
+ that every combinator is "distributed" (i.e that all endpoints
90
+ are specified like `FactoringAPI'` above), then you should
91
+ look at `flatten` from the
92
+ [servant-flatten](https://hackage.haskell.org/package/servant-flatten)
93
+ package.
94
+
85
95
Next come the two sub-APIs defined in terms of this `SimpleAPI`
86
96
type, but with different parameters. That type is just a good old
87
97
Haskell type synonym that abstracts away a pretty common structure in
0 commit comments