summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTibor Erdesz <erdeszt@gmail.com>2017-06-23 16:33:18 -0400
committerBen Gamari <ben@smart-cactus.org>2017-06-23 16:33:19 -0400
commitfaefa7e57d543e7001457a53954c9b378a38ee60 (patch)
tree6bbe86ebc4edb7de68454e50b1ed07d2df7d1f4c
parent42eee6eac3d4bf4b2b557cdc13f2d5acae93d4e8 (diff)
downloadhaskell-faefa7e57d543e7001457a53954c9b378a38ee60.tar.gz
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
-rw-r--r--docs/users_guide/glasgow_exts.rst21
1 files changed, 17 insertions, 4 deletions
diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst
index e4da54e087..8846596ddb 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