Potentially confusing syntax for injective type families

Matthew Pickering matthewtpickering at gmail.com
Sat Feb 13 11:50:39 UTC 2016


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


More information about the ghc-devs mailing list