-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace polymorphic proxy workaround with monomorphic Proxy type #281
Replace polymorphic proxy workaround with monomorphic Proxy type #281
Conversation
This also formats code via purs-tidy
Is there a downside to leaving |
I'm not sure. I suppose one could do something like data MyProxyType (sym :: Symbol) = MyProxyType OtherInfo
reflectSymbol (MyProxyType "foo" :: MyProxyType "bar") But if this is hard-coded to |
What about the opposite — is there an advantage to leaving it polymorphic? As far as I remember it was a stopgap to reduce breakage but the plan was to remove it. The main thing that comes to mind is that leaving it polymorphic is a little less clear than an explicit Proxy argument (to me), including in type errors. As a consequence we have things like Proxy2 or Proxy3, which really aren’t necessary anymore (right?). |
The hypothetical advantage is you could use types other than proxy that carry the symbol... like, say you have a generic newtype Id (tag ∷ Symbol) = Id NonEmptyString
type ItemId = Id "Item"
type OrderId = Id "Order" You could just pass your printIdType ∷ ∀ tag. IsSymbol tag ⇒ Id tag → String
printIdType = reflectSymbol But it's not really that big a deal either, it should always be possible to instantiate a printIdType ∷ ∀ tag. IsSymbol tag ⇒ Id tag → String
printIdType _ = reflectSymbol (Proxy ∷ _ tag) At the worst it would require adding some type signatures. Also "constructing" a I do actually have some types like |
Description of the change
Fixes #231 by changing
forall proxy. proxy SomeKind -> ..
to justProxy SomeKind
.Also removes
Proxy2
andProxy3
types sinceProxy
is enough now.Checklist: