haskell-servant / servant

Servant is a Haskell DSL for describing, serving, querying, mocking, documenting web applications and more!
https://docs.servant.dev/
1.83k stars 412 forks source link

Replace Proxy with TypeApplications #1273

Open poscat0x04 opened 4 years ago

poscat0x04 commented 4 years ago

390 there was a proposal 4 years ago on removing Proxy but was rejected . I think the extension TypeApplications is stable enough now so can we reconsider the proposal?

dmjio commented 4 years ago

@poscat0x04, I'm not completely convinced the gains provided are worth the implementation effort, breakage / loss of backwards compatibility, adoption hindrance, ease-of type inference. The tangible gains are essentially the removal of a few characters of boilerplate. It's also possible to use TypeApplications with Proxy in the current implementation to save a few characters. Besides aesthetics, what gains does this really provide that doesn't come at the aforementioned costs? The gains must offset all the aforementioned costs in my opinion, otherwise we risk some form of regression.

api1 = serve (Proxy :: Proxy API) handlers -- old
api2 = serve (Proxy @ API) handlers        -- current
api3 = serve @API handlers                 -- proposed
poscat0x04 commented 4 years ago

Well I don't think backward compatibility is much of a issue since

  1. we already have a package versioning policy that prevents breaking packages with backward incompatible changes
  2. it is possible to have a smooth transition, ie. we could first provide serve' that uses TypeApplications and deprecate serve and eventually replace serve with serve'
dmjio commented 4 years ago

@poscat0x04 what tangible benefits does this provide besides boilerplate reduction of a few characters? This change requires modifying every instance of every interpretation for every package. Also, symbolVal and natVal still use Proxy.

codygman commented 3 years ago

I feel like the answer is no, but I'll ask anyway:

Do TypeApplications have any advantage in compiled time resource usage over Proxy? My uneducated guess is no because TypeApplications might be implemented by desugaring to Proxy.

For contact, I came here after my work code base encountered issues with this compile performance issue: https://github.com/haskell-servant/servant/issues/986

codygman commented 3 years ago

I feel like the answer is no, but I'll ask anyway:

Do TypeApplications have any advantage in compiled time resource usage over Proxy? My uneducated guess is no because TypeApplications might be implemented by desugaring to Proxy.

For contact, I came here after my work code base encountered issues with this compile performance issue: #986

It looks like the answer is actually yes... though I'd want to test to be totally sure.

https://gitlab.haskell.org/ghc/ghc/-/issues/18902#note_324353

I found out type applications are basically implemented in core and were exposed upward, so this isn't so shocking with that information.

It seems possible this could help servant compile times.