No `mkProxy` in `Data.Proxy`(?)

Several packages on Hackage declare this or similar (search Hoogle for a -> Proxy a):

mkProxy :: a -> Proxy a
mkProxy _ = Proxy

Data.Proxy has no such thing, but does include

asProxyTypeOf :: a -> proxy a -> a
asProxyTypeOf = const

Similar usage to Prelude.asTypeOf; so typically used infix; and note the lower-case proxy.

(There is a Monoid instance with mempty = Proxy.)

Is there some deep reason why mkProxy should be frowned on? For example: its first argument would have to be a value, whereas Proxy is all about types divorced from values.

send a PR to base? I think it would be appreciated.

mkProxy :: a -> Proxy a is already in base, it is called pure :wink:

12 Likes

if not infer-able one can use pure @Proxy @a