[commit: ghc] overlapping-tyfams: Finished updating manual. (9216de8)
Richard Eisenberg
eir at cis.upenn.edu
Fri Jun 21 15:17:33 CEST 2013
Repository : http://darcs.haskell.org/ghc.git/
On branch : overlapping-tyfams
https://github.com/ghc/ghc/commit/9216de8802b80cfe17c4d8959acf5268c5284870
>---------------------------------------------------------------
commit 9216de8802b80cfe17c4d8959acf5268c5284870
Author: Richard Eisenberg <eir at cis.upenn.edu>
Date: Fri Jun 21 08:51:41 2013 +0100
Finished updating manual.
>---------------------------------------------------------------
docs/users_guide/glasgow_exts.xml | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index 75a2c68..cae2d67 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.
</para>
+ <para>
+ 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:
+<programlisting>
+type family F a where
+ F Int = Bool
+ F a = Char
+
+type family G a where
+ G Int = Int
+ G a = a
+</programlisting>
+ In the definition for <literal>F</literal>, 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 <literal>F a</literal> does not simplify; only a type such
+ as <literal>F Double</literal> will simplify to
+ <literal>Char</literal>. In <literal>G</literal>, on the other hand,
+ the two equations are compatible. Thus, GHC can ignore the first
+ equation when looking at the second. So, <literal>G a</literal> will
+ simplify to <literal>a</literal>.
+
<para> However see <xref linkend="ghci-decls"/> for the overlap rules in GHCi.</para>
</sect3>
More information about the ghc-commits
mailing list