Potentially confusing syntax for injective type families

Matthew Pickering matthewtpickering at gmail.com
Sun Feb 14 10:56:43 UTC 2016


I guess my point is that the most natural parsing of

class Hcl a b where
     type Ht a b = r | r -> a b

is  (type Ht a b = r) (| r -> a b) rather than (type Ht a b) (= r | r -> a b).

A concrete example, in the case of functional dependencies, the
vertical bar is used to signal what we expect *additional* optional
information. In this case, adding the injectivity annotation
completely changes the meaning of what came before.

I don't have a solution and I hate bike-shedding. I just made this
message to make sure the fact had been considered before release.

Matt



On Sun, Feb 14, 2016 at 9:28 AM, Jan Stolarek <jan.stolarek at p.lodz.pl> wrote:
>> 2. Without the infectivity annotation, this declares an associate type
>> synonym default. This isn't valid because Ht is not declared as an
>> associated type before hand and r is not mentioned on the LHS.
>>
>> class Hcl a b where
>>     type Ht a b = r
> Indeed, this is invalid and GHC rejects this, so I think we're OK here. In case of associated
> types if you want to declare injectivity you need to provide the "| r -> ...." part. Otherwise
> you're declaring a default. This is documented in the User's Guide for 8.0.
>
> Janek
>
> ---
> Politechnika Łódzka
> Lodz University of Technology
>
> Treść tej wiadomości zawiera informacje przeznaczone tylko dla adresata.
> Jeżeli nie jesteście Państwo jej adresatem, bądź otrzymaliście ją przez pomyłkę
> prosimy o powiadomienie o tym nadawcy oraz trwałe jej usunięcie.
>
> This email contains information intended solely for the use of the individual to whom it is addressed.
> If you are not the intended recipient or if you have received this message in error,
> please notify the sender and delete it from your system.


More information about the ghc-devs mailing list