{-# LANGUAGE ImportQualifiedPost #-}
module Extension(
defaultExtensions,
configExtensions,
extensionImpliedEnabledBy,
extensionImplies
) where
import Data.List.Extra
import Data.Map qualified as Map
import GHC.LanguageExtensions.Type
import Language.Haskell.GhclibParserEx.GHC.Driver.Session qualified as GhclibParserEx
badExtensions :: [Extension]
badExtensions =
[Extension]
reallyBadExtensions [Extension] -> [Extension] -> [Extension]
forall a. [a] -> [a] -> [a]
++
[ Extension
Arrows
, Extension
UnboxedTuples, Extension
UnboxedSums
, Extension
QuasiQuotes
, Extension
RecursiveDo
, Extension
LexicalNegation
, Extension
OverloadedRecordDot
, Extension
OverloadedRecordUpdate
]
reallyBadExtensions :: [Extension]
reallyBadExtensions =
[ Extension
TransformListComp
, Extension
StaticPointers
, Extension
AlternativeLayoutRule
, Extension
NegativeLiterals
, Extension
StarIsType
, Extension
MonadComprehensions
]
defaultExtensions :: [Extension]
defaultExtensions :: [Extension]
defaultExtensions = [Extension]
forall a. (Enum a, Bounded a) => [a]
enumerate [Extension] -> [Extension] -> [Extension]
forall a. Eq a => [a] -> [a] -> [a]
\\ [Extension]
badExtensions
configExtensions :: [Extension]
configExtensions :: [Extension]
configExtensions = [Extension]
forall a. (Enum a, Bounded a) => [a]
enumerate [Extension] -> [Extension] -> [Extension]
forall a. Eq a => [a] -> [a] -> [a]
\\ [Extension]
reallyBadExtensions
extensionImplies :: Extension -> ([Extension], [Extension])
extensionImplies :: Extension -> ([Extension], [Extension])
extensionImplies = \Extension
x ->([Extension], [Extension])
-> Extension
-> Map Extension ([Extension], [Extension])
-> ([Extension], [Extension])
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault ([], []) Extension
x Map Extension ([Extension], [Extension])
mp
where mp :: Map Extension ([Extension], [Extension])
mp = [(Extension, ([Extension], [Extension]))]
-> Map Extension ([Extension], [Extension])
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(Extension, ([Extension], [Extension]))]
extensionImplications
extensionImpliedEnabledBy :: Extension -> [Extension]
extensionImpliedEnabledBy :: Extension -> [Extension]
extensionImpliedEnabledBy = \Extension
x -> [Extension]
-> Extension -> Map Extension [Extension] -> [Extension]
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault [] Extension
x Map Extension [Extension]
mp
where
mp :: Map Extension [Extension]
mp = ([Extension] -> [Extension] -> [Extension])
-> [(Extension, [Extension])] -> Map Extension [Extension]
forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
Map.fromListWith [Extension] -> [Extension] -> [Extension]
forall a. [a] -> [a] -> [a]
(++) [(Extension
b, [Extension
a]) | (Extension
a, ([Extension]
bs, [Extension]
_)) <- [(Extension, ([Extension], [Extension]))]
extensionImplications, Extension
b <- [Extension]
bs]
_extensionImpliedDisabledBy :: Extension -> [Extension]
_extensionImpliedDisabledBy :: Extension -> [Extension]
_extensionImpliedDisabledBy = \Extension
x -> [Extension]
-> Extension -> Map Extension [Extension] -> [Extension]
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault [] Extension
x Map Extension [Extension]
mp
where
mp :: Map Extension [Extension]
mp = ([Extension] -> [Extension] -> [Extension])
-> [(Extension, [Extension])] -> Map Extension [Extension]
forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
Map.fromListWith [Extension] -> [Extension] -> [Extension]
forall a. [a] -> [a] -> [a]
(++) [(Extension
b, [Extension
a]) | (Extension
a, ([Extension]
_, [Extension]
bs)) <- [(Extension, ([Extension], [Extension]))]
extensionImplications, Extension
b <- [Extension]
bs]
extensionImplications :: [(Extension, ([Extension], [Extension]))]
extensionImplications :: [(Extension, ([Extension], [Extension]))]
extensionImplications = [(Extension, ([Extension], [Extension]))]
GhclibParserEx.extensionImplications