I have following code functions:
def jsonOrBadRequest[F[_] : Monad](service: HttpService[F])
: HttpService[F]
= {
object dsl extends Http4sDsl[F]
import dsl._
Kleisli[OptionT[F, ?], Request[F], Response[F]] { req =>
req.contentType match {
case Some(s) =>
if (s != `Content-Type`(MediaType.`application/json`))
OptionT.liftF(BadRequest("Malformed format."))
else
service(req)
case None =>
OptionT.liftF(BadRequest("Malformed format."))
}
}
}
and wanted to know, what does the question mark mean? It is from the library https://github.com/non/kind-projector.
This is not special Scala syntax.
?is a valid identifier like anything else.kind-projectoruses it to declare type-level lambdas. For example,(Examples taken directly from the
kind-projectordocumentation)