[Haskell-cafe] Is there a way to query the availability of an extension? Or could we?

Edward Z. Yang ezyang at mit.edu
Tue May 17 21:22:26 UTC 2016


Hello David,

This would be simple to add, since GHC 8.0 already generates
macros for package versions.  The relevant code is
compiler/main/DriverPipeline.hs search for "MIN_VERSION".

I would bikeshed the macro name a little; how about something
like LANGUAGE_ScopedTypeVariables?

Cheers,
Edward

Excerpts from David Feuer's message of 2016-05-17 14:19:45 -0700:
> We have __GLASGOW_HASKELL__ to tell us what GHC version we're running
> (if we're running GHC), and Cabal sets up MIN_VERSION_blah macros and
> (when applicable) the __HADDOCK_VERSION__ macro. But what if we're
> running some other compiler? It seems rather painful to have to write
> code that enables or disables various extensions based on what version
> N of compiler C happens to support. Not to mention that this is even a
> pain when just dealing with GHC, since it involves digging through
> release notes or waiting to see how Travis throws up.
> 
> Is there some better way? If not, could we add one?
> 
> __Have_ScopedTypeVariables__
> 
> could tell us if the ScopedTypeVariables extension is available. Then
> instead of saying "We need ScopedTypeVariables" when we can
> (painfully) do without, we can just use it precisely when we have it.


More information about the Haskell-Cafe mailing list