[GHC] #10970: Built in MIN_VERSION macro support
GHC
ghc-devs at haskell.org
Tue Feb 9 15:03:00 UTC 2016
#10970: Built in MIN_VERSION macro support
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 8.0.1
Component: Compiler | Version: 7.11
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1349,
Wiki Page: | Phab:D1869
-------------------------------------+-------------------------------------
Comment (by rwbarton):
Replying to [comment:12 hvr]:
> Replying to [comment:3 rwbarton]:
> > [...] I don't understand any more why it should be the case that we
only create these macros for packages explicitly specified with `-package`
or equivalent.
>
> Well, if you `-hide-all-packages` and unmask a few packages via
`-package`, then exposing macros for all other packages in the package
database would be very unsound, as it would destroy modularity.
I was unclear in comment:3. I thought I was pretty clear in comment:7, but
let me try again.
For a given compilation, after processing all package-related flags and
environment variables, and reading in all package databases, GHC selects
some set of installed packages, called the exposed packages. These are the
packages that GHC will use to satisfy import statements.
My proposal is simply: define `MIN_VERSION_x` macros for exactly the
exposed packages. If you can import it, then you can check its version
too.
So, if you `-hide-all-packages` and unmask a few packages via `-package`,
you'd only get `MIN_VERSION_x` macros for those packages you exposed with
`-package`.
The modularity concerns that Cabal addresses for imports then extend
directly to `MIN_VERSION_x` macros. In Cabal, you need to state your
dependency on a module to import it. So, you need to state your dependency
on a module to check its version with `MIN_VERSION_x`, too. No need to
reason explicitly about `-hide-all-packages` and `-package` flags to
arrive at this result.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10970#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list