Subject: Ssreflect Users Discussion List
List archive
- From: Enrico Tassi <>
- To:
- Subject: Re: [ssreflect] Phantom types and "*_of" aliases
- Date: Thu, 7 Dec 2017 10:16:56 +0100
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=None ; spf=None
- Ironport-phdr: 9a23:kM5q8BD+nMsigQTgjgO7UyQJP3N1i/DPJgcQr6AfoPdwSP39r8bcNUDSrc9gkEXOFd2Crakb26yL6+jJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6i760TlHAQ7lOARxK+/pMovJlYG20fqz8tvSZR9JjXyze+BcNhKz+CjXrMgdhsNeI70qy1Odr31Seu9Rg39hPkmStxf6/Ma5upB5pXcD88k9/tJNBP2pN58zSqZVWWwr
On Wed, Dec 06, 2017 at 09:59:11PM +0000, Arthur Azevedo de Amorim wrote:
> Phantom types are used in several places of mathcomp to infer canonical
> structures. Is there any reason for preferring, e.g.
>
> Record my_type (T : eqType) := MyType {value : T; _ : some_pred value}.
> Definition my_type_of (T : eqType) of phant T := my_type T.
>
> over
>
> Record my_type (T : eqType) (p : phant T) := MyType (value : T; _ :
> some_pred value).
I don't know if it is the main reason, but I've always had the feeling
that "phantom types" are used as a device to ease the construction of
objects, they are not morally part of the object you are defining.
A bit like smart constructors in functional programming languages.
Best,
--
Enrico Tassi
- [ssreflect] Phantom types and "*_of" aliases, Arthur Azevedo de Amorim, 12/06/2017
- Re: [ssreflect] Phantom types and "*_of" aliases, Enrico Tassi, 12/07/2017
Archive powered by MHonArc 2.6.18.