@@ -1,4 +1,6 @@
1−{-# LANGUAGE RecordWildCards #-}
1+{-# LANGUAGE RecordWildCards #-}
2+{-# LANGUAGE StandaloneDeriving #-}
3+{-# OPTIONS_GHC -fno-warn-orphans #-}
24
35-- | Parser for Haskell source code.
46
@@ -10,7 +12,7 @@ where
1012import Control.Exception
1113import Control.Monad
1214import Control.Monad.IO.Class
13−import Data.List (isPrefixOf, foldl')
15+import Data.List (isPrefixOf, foldl', (\\))
1416import Data.Maybe (catMaybes)
1517import GHC hiding (IE, parseModule, parser)
1618import GHC.LanguageExtensions.Type (Extension (..))
@@ -159,65 +161,26 @@ getPragma s@(x:xs)
159161-- default for ease of use.
160162
161163setDefaultExts :: DynFlags -> DynFlags
162−setDefaultExts flags = foldl' GHC.xopt_set flags
163− [ OverlappingInstances
164− , UndecidableInstances
165− , IncoherentInstances
166− , UndecidableSuperClasses
167− , ExtendedDefaultRules
168− , ForeignFunctionInterface
169− , TemplateHaskell
170− , QuasiQuotes
171− , ImplicitParams
172− , ScopedTypeVariables
173− , BangPatterns
174− , TypeFamilies
175− , TypeFamilyDependencies
176− , TypeInType
177− , OverloadedStrings
178− , OverloadedLists
179− , RecordWildCards
180− , RecordPuns
181− , GADTs
182− , GADTSyntax
183− , NPlusKPatterns
184− , ConstraintKinds
185− , PolyKinds
186− , DataKinds
187− , InstanceSigs
188− , StandaloneDeriving
189− , DefaultSignatures
190− , DeriveAnyClass
191− , DerivingStrategies
192− , DerivingVia
193− , FlexibleContexts
194− , FlexibleInstances
195− , MultiParamTypeClasses
196− , FunctionalDependencies
197− , ExistentialQuantification
198− , EmptyDataDecls
199− , KindSignatures
200− , RoleAnnotations
201− , GeneralizedNewtypeDeriving
202− , RecursiveDo
203− , TupleSections
204− , PatternGuards
205− , RankNTypes
206− , TypeOperators
207− , ExplicitNamespaces
208− , PackageImports
209− , ExplicitForAll
210− , LambdaCase
211− , MultiWayIf
212− , BinaryLiterals
213− , NegativeLiterals
214− , HexFloatLiterals
215− , OverloadedLabels
216− , EmptyCase
217− , NamedWildCards
218− , StaticPointers
219− , TypeApplications
220− , NumericUnderscores
221− , QuantifiedConstraints
222− , StarIsType
223− ]
164+setDefaultExts flags = foldl' GHC.xopt_set flags whitelist
165+ where
166+ whitelist = allExts \\ blacklist
167+ allExts = [minBound..maxBound]
168+ blacklist =
169+ [ Arrows -- steals proc
170+ , Cpp -- forbidden
171+ , PatternSynonyms -- steals the pattern keyword
172+ , RecursiveDo -- steals the rec keyword
173+ , StaticPointers -- steals static keyword
174+ , TransformListComp -- steals the group keyword
175+ , UnboxedTuples -- breaks (#) lens operator
176+ , MagicHash -- screws {-# these things #-}
177+ , AlternativeLayoutRule
178+ , AlternativeLayoutRuleTransitional
179+ , MonadComprehensions
180+ , UnboxedSums
181+ , TemplateHaskellQuotes -- enables TH subset of quasi-quotes, this
182+ -- apparently interferes with QuasiQuotes in
183+ -- weird ways
184+ ]
185+
186+deriving instance Bounded Extension