[GHC] #14685: Pragma to reset language extensions in module header

#14685: Pragma to reset language extensions in module header -------------------------------------+------------------------------------- Reporter: mgsloan | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- In https://github.com/commercialhaskell/stack/issues/3789 , there is an issue where if OverloadableStrings is enabled in default extensions, the Paths_ module generated by cabal no longer compiles. I've opened a fix here - https://github.com/haskell/cabal/pull/5054 . However, this just disables specific extensions known to be problematic. It would be better to have a pragma that says "Please reset the extensions used for this module". I propose {{{ {-# LANGUAGE_RESET Haskell2010 #-} }}} and {{{ {-# LANGUAGE_RESET Haskell98 #-} }}} This would also provide for quite a nice workaround for the most common source of trouble when loading multiple packages at once into ghci - default-extensions causing some code to no longer compile. See https://ghc.haskell.org/trac/ghc/ticket/10827 for more about this. With `LANGUAGE_RESET`, we could write packages that gracefully load along with other packages that specify default-extensions. Of course, this is open to name bikeshedding. `{-# SET_LANGUAGE Haskell98 #-}`? Or perhaps just straight up `{-# HASKELL_98 #-}`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14685 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14685: Pragma to reset language extensions in module header -------------------------------------+------------------------------------- Reporter: mgsloan | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): *Sigh* We don't need the overkill of a new pragma; we'd just need something like `{-# OPTIONS_GHC -X #-}` which resets any `-X...` flags set before the compiler encounters the `-X` flag via `OPTIONS_GHC` ; just like `-i` resets all include paths. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14685#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14685: Pragma to reset language extensions in module header -------------------------------------+------------------------------------- Reporter: mgsloan | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mgsloan): *Sigh* You think I didn't consider something like that? When convenient, I strongly prefer to write code that is compatible with older versions of the tools we use, unless there is a strong reason to do otherwise. I particularly appreciate it when others do the same.... :| With all prior versions, your suggestion would result in {{{ foo.hs:1:16: error: unknown flag in {-# OPTIONS_GHC #-} pragma: -X }}} With my proposal, it results in {{{ foo.hs:1:1: warning: [-Wunrecognised-pragmas] Unrecognised pragma }}} That said, having `-X` mean the same thing would be consistent with `-i` and the like, so that could be considered. I think that flag convention is really weird, but it is at least consistent. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14685#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14685: Pragma to reset language extensions in module header -------------------------------------+------------------------------------- Reporter: mgsloan | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mgsloan): I have considered it a it a bit, and my proposal does indeed imply a bit of a fiddly difference in build semantics depending on version. It turns out that I'd usually want that difference, because my primary use-case is protecting code from variation in extensions used by the build. However, if the protection is not possible, I still want it to try to build. I guess this ugly incantation could be used. {{{ {-# LANGUAGE CPP #-} #if __GLASGOW_HASKELL__ >= 804 {-# OPTIONS_GHC -X #-} #endif }}} So, if one cares about behavior consistency `LANGUAGE_RESET` should only be used as a protection from varying build configurations, *not* as a way to turn off all the default options from your package configuration. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14685#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC