Going through happstack-lite tutorial:
we build functions that have return type of ServerPart Reponse:
homePage :: ServerPart Response
however, in web-routes crash course, our functions change signature to the following:
homePage :: RouteT Sitemap (ServerPartT IO) Response
Didn’t we have ServerPart before, and not ServerPartT?
Also, is there an easier way to switch to web-routes, without changing every method’s type signature?
ServerPartis simply defined astype ServerPart a = ServerPartT IO a. In Happstack 8 we might change this totype ServerPart = ServerPartT IOwhich would mean we could write types likeRouteT Sitemap ServerPart Response, but until then, we have to useServerPartTdirectly because type synonyms can’t be “partially applied”. However, they are the same types. That is,ServerPart Responseis just an alias forServerPartT IO Response.Not really. I like to define my own type for “handlers” early on, then I can just change its definition. For example,
type Handler = ServerPart ResponseandhomePage :: Handler, and then when I add in web-routes I just redefine Handlertype Handler = RouteT Sitemap (ServerPartT IO) Response.Your editor probably has a search-and-replace feature though, for example in Vim: