[Git][ghc/ghc][wip/issue-23821] 4 commits: users-guide: Note that GHC2021 doesn't include ExplicitNamespaces
Gergő Érdi (@cactus)
gitlab at gitlab.haskell.org
Wed Aug 16 01:33:51 UTC 2023
Gergő Érdi pushed to branch wip/issue-23821 at Glasgow Haskell Compiler / GHC
Commits:
e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00
users-guide: Note that GHC2021 doesn't include ExplicitNamespaces
As noted in #23801.
- - - - -
d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00
users-guide: Support both distutils and packaging
As noted in #23818, some old distributions (e.g. Debian 9) only include
`distutils` while newer distributions only include `packaging`.
Fixes #23818.
- - - - -
1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00
users-guide: Ensure extlinks is compatible with Sphinx <4
The semantics of the `extlinks` attribute annoyingly changed in Sphinx
4. Reflect this in our configuration. See #22690.
Fixes #23807.
- - - - -
f369f3c8 by Gergő Érdi at 2023-08-16T01:33:47+00:00
If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting
Fixes #23821.
- - - - -
10 changed files:
- compiler/GHC/Tc/Solver.hs
- docs/users_guide/exts/control.rst
- docs/users_guide/flags.py
- docs/users_guide/ghc_config.py.in
- docs/users_guide/utils.py
- testsuite/tests/plugins/Makefile
- + testsuite/tests/plugins/T23821.hs
- testsuite/tests/plugins/all.T
- + testsuite/tests/plugins/defaulting-plugin/DefaultInterference.hs
- testsuite/tests/plugins/defaulting-plugin/defaulting-plugin.cabal
Changes:
=====================================
compiler/GHC/Tc/Solver.hs
=====================================
@@ -3598,6 +3598,12 @@ applyDefaultingRules wanteds
; return defaultedGroups
}
+ -- If a defaulting plugin solves a tyvar, some of the wanteds
+ -- will have filled-in metavars by now (see #23281). So we
+ -- re-zonk to make sure the built-in defaulting rules don't try
+ -- to solve the same metavars.
+ ; wanteds <- if or plugin_defaulted then TcS.zonkWC wanteds else pure wanteds
+
; let groups = findDefaultableGroups info wanteds
; traceTcS "applyDefaultingRules {" $
=====================================
docs/users_guide/exts/control.rst
=====================================
@@ -36,6 +36,13 @@ Language extensions can be controlled (i.e. allowed or not) in two ways:
still happen (e.g. the simplified subsumption change introduced in GHC 9.0
which caused GHC to reject some programs using :extension:`RankNTypes`).
+ Also note that due to a `minor oversight
+ <https://github.com/ghc-proposals/ghc-proposals/issues/551>`_, this
+ extension set behaves slightly differently than enabling each of its
+ constituent extensions. Specifically, while :extension:`TypeOperators` implies
+ :extension:`ExplicitNamespaces`, :extension:`ExplicitNamespaces` is not included
+ in :extension:`GHC2021`.
+
The ``GHC2021`` language set comprises the following extensions:
.. hlist::
@@ -86,6 +93,7 @@ Language extensions can be controlled (i.e. allowed or not) in two ways:
* :extension:`TypeApplications`
* :extension:`TypeOperators`
* :extension:`TypeSynonymInstances`
+ * :extension:`NoExplicitNamespaces <ExplicitNamespaces>`
.. extension:: Haskell2010
=====================================
docs/users_guide/flags.py
=====================================
@@ -50,8 +50,8 @@ import sphinx
from sphinx import addnodes
from sphinx.domains.std import GenericObject
from sphinx.errors import SphinxError
-from packaging.version import parse
-from utils import build_table_from_list
+
+from utils import build_table_from_list, parse_version
import os.path
@@ -628,8 +628,8 @@ def purge_flags(app, env, docname):
def setup(app):
# The override argument to add_directive_to_domain is only supported by >= 1.8
- sphinx_version = parse(sphinx.__version__)
- override_arg = {'override': True} if sphinx_version >= parse('1.8') else {}
+ sphinx_version = parse_version(sphinx.__version__)
+ override_arg = {'override': True} if sphinx_version >= parse_version('1.8') else {}
# Add ghc-flag directive, and override the class with our own
app.add_object_type('ghc-flag', 'ghc-flag')
=====================================
docs/users_guide/ghc_config.py.in
=====================================
@@ -1,7 +1,17 @@
-extlinks = {
- 'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '%s'),
- 'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '#%s'),
-}
+import sphinx
+from utils import parse_version
+
+if parse_version(sphinx.__version__) >= parse_version("4.0.0"):
+ # N.B. see #23807 and #22690
+ extlinks = {
+ 'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '#%s'),
+ 'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '%s'),
+ }
+else:
+ extlinks = {
+ 'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '#'),
+ 'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', ''),
+ }
libs_base_uri = '../libraries'
=====================================
docs/users_guide/utils.py
=====================================
@@ -1,5 +1,12 @@
from docutils import nodes
+# N.B. `packaging` is not available in Ubuntu 18.04 or Debian 9
+# See #23818.
+try:
+ from packaging.version import parse as parse_version
+except ImportError as e:
+ from distutils.version import LooseVersion as parse_version
+
# Taken from Docutils source inside the ListTable class. We must bypass
# using the class itself, but this function comes in handy.
def build_table_from_list(table_data, col_widths):
=====================================
testsuite/tests/plugins/Makefile
=====================================
@@ -172,6 +172,10 @@ test-defaulting-plugin:
test-defaulting-plugin-fail:
-"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) -v0 test-defaulting-plugin-fail.hs -package-db defaulting-plugin/pkg.test-defaulting-plugin-fail/local.package.conf
+.PHONY: T23821
+T23821:
+ -"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 T23821.hs -package-db defaulting-plugin/pkg.test-defaulting-plugin/local.package.conf
+
.PHONY: plugins-order
plugins-order:
"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 plugins-order.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin ImpurePlugin -fplugin PurePlugin -fplugin-opt ImpurePlugin:First_Option -fplugin-opt PurePlugin:Second_Option -fplugin-opt PurePlugin:Second_Option_2 -fplugin FingerprintPlugin -fplugin-opt FingerprintPlugin:1
=====================================
testsuite/tests/plugins/T23821.hs
=====================================
@@ -0,0 +1,12 @@
+{-# OPTIONS_GHC -fplugin DefaultInterference #-}
+{-# LANGUAGE ExtendedDefaultRules #-}
+module Main where
+
+class IsColor a where
+ op :: a -> ()
+
+instance IsColor (Int, Int, Int) where
+ op _ = ()
+
+main :: IO ()
+main = pure $ op (1, 2, 3)
=====================================
testsuite/tests/plugins/all.T
=====================================
@@ -280,6 +280,11 @@ test('test-defaulting-plugin-fail',
pre_cmd('$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin-fail TOP={top}')],
makefile_test, [])
+test('T23821',
+ [extra_files(['defaulting-plugin/']),
+ pre_cmd('$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}')],
+ makefile_test, [])
+
test('plugins-order',
[extra_files(['plugin-recomp/', 'plugin-recomp-test.hs']),
pre_cmd('$MAKE -s --no-print-directory -C plugin-recomp package.plugins01 TOP={top}')
=====================================
testsuite/tests/plugins/defaulting-plugin/DefaultInterference.hs
=====================================
@@ -0,0 +1,32 @@
+module DefaultInterference(plugin) where
+
+import GHC.Driver.Plugins
+import GHC.Tc.Plugin
+import GHC.Tc.Types
+import GHC.Tc.Utils.TcType
+import GHC.Tc.Types.Constraint
+import GHC.Core.Predicate
+import GHC.Tc.Solver
+import GHC.Core.Type
+import GHC.Core.Class
+import GHC.Data.Bag
+import GHC.Builtin.Types (intTy)
+
+plugin :: Plugin
+plugin = defaultPlugin
+ { defaultingPlugin = \_ -> Just DefaultingPlugin
+ { dePluginInit = pure ()
+ , dePluginRun = \ _ -> defaultEverythingToInt
+ , dePluginStop = \ _ -> pure ()
+ }
+ }
+
+defaultEverythingToInt :: WantedConstraints -> TcPluginM [DefaultingProposal]
+defaultEverythingToInt wanteds = pure
+ [ DefaultingProposal tv [intTy] [ct]
+ | ct <- bagToList $ approximateWC True wanteds
+ , Just (cls, tys) <- pure $ getClassPredTys_maybe (ctPred ct)
+ , [ty] <- pure $ filterOutInvisibleTypes (classTyCon cls) tys
+ , Just tv <- pure $ getTyVar_maybe ty
+ , isMetaTyVar tv
+ ]
=====================================
testsuite/tests/plugins/defaulting-plugin/defaulting-plugin.cabal
=====================================
@@ -6,5 +6,5 @@ version: 0.1.0.0
library
default-language: Haskell2010
build-depends: base, ghc, containers
- exposed-modules: DefaultLifted
+ exposed-modules: DefaultLifted DefaultInterference
ghc-options: -Wall
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/66dc8f828b69cf2a659e4b09039bdbd845e015d3...f369f3c838c610e9464e3f7302f8db16ad814306
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/66dc8f828b69cf2a659e4b09039bdbd845e015d3...f369f3c838c610e9464e3f7302f8db16ad814306
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230815/753d4946/attachment-0001.html>
More information about the ghc-commits
mailing list