Potentially confusing syntax for injective type families

I was updating haskell-src-exts for ghc 8.0 recently and found some of the syntax for injective type families quite confusing. Is it a problem that the two following snippets have quite different meanings? 1. With the infectivity annotation, this declares an associated type. class Hcl a b where type Ht a b = r | r -> b a 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 Has this been considered? Matt

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.

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
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.

When this was first discussed a bunch of alternatives were tossed around, mostly involving new keywords, or putting a conditional result keyword in place. Here you can pick the name of the result type, so it doesn't pick any naming conventions for you. My understanding is that the current syntax was selected because it avoids magic conditional keywords and fits into a gap in the current grammar. All of the alternatives seemed worse. -Edward On Sun, Feb 14, 2016 at 5:56 AM, Matthew Pickering < matthewtpickering@gmail.com> wrote:
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
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
On Sun, Feb 14, 2016 at 9:28 AM, Jan Stolarek
wrote: 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.
ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

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. Yes, I bumped into this issue quite early. After some discussion it was decided that this potential ambiguity is an acceptable trade-off.
Janek Dnia niedziela, 14 lutego 2016, Matthew Pickering napisał:
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
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.
--- 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.
participants (3)
-
Edward Kmett
-
Jan Stolarek
-
Matthew Pickering