[commit: ghc] ghc-8.2: documentation: fix trac issue #12978 (ba15d18)

git at git.haskell.org git at git.haskell.org
Mon Jun 26 22:25:31 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/ba15d1879438ad19e5cdd3f38c2c5f449e6e911c/ghc

>---------------------------------------------------------------

commit ba15d1879438ad19e5cdd3f38c2c5f449e6e911c
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
    
    (cherry picked from commit faefa7e57d543e7001457a53954c9b378a38ee60)


>---------------------------------------------------------------

ba15d1879438ad19e5cdd3f38c2c5f449e6e911c
 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 5b71c02..ecd1ebd 100644
--- a/docs/users_guide/glasgow_exts.rst
+++ b/docs/users_guide/glasgow_exts.rst
@@ -8848,10 +8848,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