The WebPart
type you're looking at comes from Suave. You can read more about it at https://suave.io/async.html, but I'll summarize. You're correct: it is a type for a function. Specifically, it is a function that takes a Context
(which in Suave is a combination of an HTTP request record and a response record), and returns a Context option
asynchronously. That is, since some requests can fail, the function has the option of returning None
instead of a value. And since some requests can take a long time, all requests are treated as returning asynchronously, hence the Async
.
To chain two requests together, Suave provides the binding operator >=>
so that you don't have to go through the boilerplate of typing async { match result1 with None -> None | Some x -> return! request2 x
all the time; instead, you can just type request1 >=> request2
for the same effect.
If you need more help and reading through the Suave documentation hasn't provided the help you need, let us know and we'll try to explain further.
WebPart
takes aContext
and simply wraps both anOption
and anAsync
computation around it? – Occidentalize