servant icon indicating copy to clipboard operation
servant copied to clipboard

Replace Proxy with TypeApplications

Open poscat0x04 opened this issue 5 years ago • 5 comments

#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?

poscat0x04 avatar Feb 15 '20 07:02 poscat0x04

@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

dmjio avatar Jun 06 '20 05:06 dmjio

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'

poscat0x04 avatar Jun 07 '20 07:06 poscat0x04

@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.

dmjio avatar Jun 07 '20 16:06 dmjio

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 avatar Jul 19 '21 15:07 codygman

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.

codygman avatar Jul 20 '21 04:07 codygman