@@ -5,18 +5,20 @@ import cats.data.{Kleisli, OptionT}
55import cats .effect .Sync
66import cats .implicits ._
77
8- /** Functions for creating [[HttpRoutes ]]. */
8+ /** Functions for creating [[HttpRoutes ]] kleislis . */
99object HttpRoutes {
10- /** Lifts a function into [[HttpRoutes ]].
10+ /** Lifts a function into an [[HttpRoutes ]]. The application of `run`
11+ * is suspended in `F` to permit more efficient combination of
12+ * routes via `SemigroupK`.
1113 *
1214 * @tparam F the effect of the [[HttpRoutes ]]
1315 * @param run the function to lift
1416 * @return an [[HttpRoutes ]] that wraps `run`
1517 */
16- def apply [F [_]](run : Request [F ] => OptionT [F , Response [F ]]): HttpRoutes [F ] =
17- Kleisli (run)
18+ def apply [F [_]: Sync ](run : Request [F ] => OptionT [F , Response [F ]]): HttpRoutes [F ] =
19+ Http (run)
1820
19- /** Lifts an effectful [[Response ]] into [[HttpRoutes ]].
21+ /** Lifts an effectful [[Response ]] into an [[HttpRoutes ]].
2022 *
2123 * @tparam F the effect of the [[HttpRoutes ]]
2224 * @param fr the effectful [[Response ]] to lift
@@ -25,7 +27,7 @@ object HttpRoutes {
2527 def liftF [F [_]](fr : OptionT [F , Response [F ]]): HttpRoutes [F ] =
2628 Kleisli .liftF(fr)
2729
28- /** Lifts a [[Response ]] into [[HttpRoutes ]].
30+ /** Lifts a [[Response ]] into an [[HttpRoutes ]].
2931 *
3032 * @tparam F the base effect of the [[HttpRoutes ]]
3133 * @param r the [[Response ]] to lift
@@ -34,28 +36,30 @@ object HttpRoutes {
3436 def pure [F [_]](r : Response [F ])(implicit FO : Applicative [OptionT [F , ? ]]): HttpRoutes [F ] =
3537 Kleisli .pure(r)
3638
37- /** Transforms [[HttpRoutes ]] on its input.
39+ /** Transforms an [[HttpRoutes ]] on its input. The application of the
40+ * transformed function is suspended in `F` to permit more
41+ * efficient combination of routes via `SemigroupK`.
3842 *
3943 * @tparam F the base effect of the [[HttpRoutes ]]
4044 * @param f a function to apply to the [[Request ]]
4145 * @param fa the [[HttpRoutes ]] to transform
42- * @return [[HttpRoutes ]] whose input is transformed by `f` before
46+ * @return An [[HttpRoutes ]] whose input is transformed by `f` before
4347 * being applied to `fa`
4448 */
45- def local [F [_]](f : Request [F ] => Request [F ])(fa : HttpRoutes [F ]): HttpRoutes [F ] =
46- Kleisli .local[OptionT [F , ? ], Response [ F ], Request [ F ] ](f)(fa)
49+ def local [F [_]: Sync ](f : Request [F ] => Request [F ])(fa : HttpRoutes [F ]): HttpRoutes [F ] =
50+ Http .local[OptionT [F , ? ], F ](f)(fa)
4751
4852 /** Lifts a partial function into an [[HttpRoutes ]]. The application of the
49- * partial function is delayed in `F` to permit more efficient combination
53+ * partial function is suspended in `F` to permit more efficient combination
5054 * of routes via `SemigroupK`.
5155 *
5256 * @tparam F the base effect of the [[HttpRoutes ]]
53- * @param pfthe partial function to lift
54- * @return [[HttpRoutes ]] that returns some [[Response ]] in an `OptionT[F, ?]`
57+ * @param pf the partial function to lift
58+ * @return An [[HttpRoutes ]] that returns some [[Response ]] in an `OptionT[F, ?]`
5559 * wherever `pf` is defined, an `OptionT.none` wherever it is not
5660 */
5761 def of [F [_]](pf : PartialFunction [Request [F ], F [Response [F ]]])(implicit F : Sync [F ]): HttpRoutes [F ] =
58- Kleisli (req => OptionT (F .delay (pf.lift(req).sequence).flatten ))
62+ Kleisli (req => OptionT (F .suspend (pf.lift(req).sequence)))
5963
6064 /** An empty set of routes. Always responds with `pOptionT.none`.
6165 *
0 commit comments