Proposal: relax type of asProxyTypeOf

Oliver Charles ollie at ocharles.org.uk
Sun Dec 7 12:55:42 UTC 2014


Daniel Wagner <dmwit at galois.com> writes:

> In base, the new Data.Proxy module has this handy function:
>
> asProxyTypeOf :: a -> Proxy a -> a
> asProxyTypeOf = const
>
> This is nice for restricting the phantom type variable of a Proxy that
> you have lying around. This use could be generalized to other types with
> phantom type variables by making the type slightly more polymorphic:
>
> asProxyTypeOf :: a -> proxy a -> a
>
> Since phantom type variables are a very common pattern, this would make
> asProxyTypeOf more generally useful.
>
> Possible downside: it may be that somebody used asProxyTypeOf to
> restrict both the phantom type and the "Proxy" type, and that the more
> polymorphic type for asProxyTypeOf would cause that code to break. I
> find this pretty unlikely. Perhaps the folks behind the "tagged" package
> could mention whether this complaint ever came up when it made a similar
> generalization.

+1, this looks sensible to me.

- Ollie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141207/ae0f44ea/attachment.sig>


More information about the Libraries mailing list