[commit: ghc] master: documentation: fix trac issue #12978 (faefa7e)
git at git.haskell.org
git at git.haskell.org
Fri Jun 23 20:35:14 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/faefa7e57d543e7001457a53954c9b378a38ee60/ghc
>---------------------------------------------------------------
commit faefa7e57d543e7001457a53954c9b378a38ee60
Author: Tibor Erdesz <erdeszt at gmail.com>
Date: Fri Jun 23 16:33:18 2017 -0400
documentation: fix trac issue #12978
Add reference to TypeApplications to the AllowAmbiguousType section of
the user docs
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie
GHC Trac Issues: #12978
Differential Revision: https://phabricator.haskell.org/D3668
>---------------------------------------------------------------
faefa7e57d543e7001457a53954c9b378a38ee60
docs/users_guide/glasgow_exts.rst | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst
index e4da54e..8846596 100644
--- a/docs/users_guide/glasgow_exts.rst
+++ b/docs/users_guide/glasgow_exts.rst
@@ -8943,10 +8943,23 @@ the function is callable. For example: ::
Here ``strange``\'s type is ambiguous, but the call in ``foo`` is OK
because it gives rise to a constraint ``(D Bool beta)``, which is
-soluble by the ``(D Bool b)`` instance. So the language extension
-:ghc-flag:`-XAllowAmbiguousTypes` allows you to switch off the ambiguity check.
-But even with ambiguity checking switched off, GHC will complain about a
-function that can *never* be called, such as this one: ::
+soluble by the ``(D Bool b)`` instance.
+
+Another way of getting rid of the ambiguity at the call site is to use
+the :ghc-flag:`-XTypeApplications` flag to specify the types. For example: ::
+
+ class D a b where
+ h :: b
+ instance D Int Int where ...
+
+ main = print (h @Int @Int)
+
+Here ``a`` is ambiguous in the definition of ``D`` but later specified
+to be `Int` using type applications.
+
+So the language extension :ghc-flag:`-XAllowAmbiguousTypes` allows you to
+switch off the ambiguity check. But even with ambiguity checking switched off,
+GHC will complain about a function that can *never* be called, such as this one: ::
f :: (Int ~ Bool) => a -> a
More information about the ghc-commits
mailing list