I'm excited about servant, and I'm ok with its internal typelevel magic as long as it doesn't gets in the way, and the only thing that confuses me is its use of a type-proxy in public API. Here's the code:
serve :: HasServer layout => Proxy layout -> Server layout -> Application
serve p server = toApplication (runRouter (route p (return (RR (Right server)))))
As I understand, type-proxies are fairly simple thing and are needed to carry a type when you don't have a value with that type. So why to pass a proxy carrying layout type when there is already layout type in Server's type parameter? I've tried cloning servant's repo and changing code to this:
{-# LANGUAGE ScopedTypeVariables #-}
serve :: forall layout . HasServer layout => Server layout -> Application
serve server = toApplication (runRouter (route p (return (RR (Right server)))))
where
p :: Proxy layout
p = Proxy
And surprisingly to me this fails to compile (telling something about layout type mismatch). But why, shouldn't my local p have the same layout type as server (with ScopedTypeVariables turned on)?