diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index 75a2c68af335..cae2d6751162 100644 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -5269,6 +5269,31 @@ type instance H [x] x = Bool necessary for type soundness. + + Compatibility also affects closed type families. When simplifying an + application of a closed type family, GHC will select an equation only + when it is sure that no incompatible previous equation will ever apply. + Here are some examples: + +type family F a where + F Int = Bool + F a = Char + +type family G a where + G Int = Int + G a = a + + In the definition for F, the two equations are + incompatible -- their patterns are not apart, and yet their + right-hand sides do not coincide. Thus, before GHC selects the + second equation, it must be sure that the first can never apply. So, + the type F a does not simplify; only a type such + as F Double will simplify to + Char. In G, on the other hand, + the two equations are compatible. Thus, GHC can ignore the first + equation when looking at the second. So, G a will + simplify to a. + However see for the overlap rules in GHCi.