+-- These -X<blah> flags can all be reversed with -XNo<blah>
+xFlags :: [(String, DynFlag)]
+xFlags = [
+ ( "CPP", Opt_Cpp ),
+ ( "PatternGuards", Opt_PatternGuards ),
+ ( "UnicodeSyntax", Opt_UnicodeSyntax ),
+ ( "MagicHash", Opt_MagicHash ),
+ ( "PolymorphicComponents", Opt_PolymorphicComponents ),
+ ( "ExistentialQuantification", Opt_ExistentialQuantification ),
+ ( "KindSignatures", Opt_KindSignatures ),
+ ( "PatternSignatures", Opt_PatternSignatures ),
+ ( "EmptyDataDecls", Opt_EmptyDataDecls ),
+ ( "ParallelListComp", Opt_ParallelListComp ),
+ ( "ForeignFunctionInterface", Opt_ForeignFunctionInterface ),
+ ( "UnliftedFFITypes", Opt_UnliftedFFITypes ),
+ ( "PartiallyAppliedClosedTypeSynonyms",
+ Opt_PartiallyAppliedClosedTypeSynonyms ),
+ ( "Rank2Types", Opt_Rank2Types ),
+ ( "RankNTypes", Opt_RankNTypes ),
+ ( "TypeOperators", Opt_TypeOperators ),
+ ( "RecursiveDo", Opt_RecursiveDo ),
+ ( "Arrows", Opt_Arrows ),
+ ( "PArr", Opt_PArr ),
+ ( "TemplateHaskell", Opt_TemplateHaskell ),
+ ( "Generics", Opt_Generics ),
+ -- On by default:
+ ( "ImplicitPrelude", Opt_ImplicitPrelude ),
+ ( "RecordWildCards", Opt_RecordWildCards ),
+ ( "RecordPuns", Opt_RecordPuns ),
+ ( "DisambiguateRecordFields", Opt_DisambiguateRecordFields ),
+ ( "OverloadedStrings", Opt_OverloadedStrings ),
+ ( "GADTs", Opt_GADTs ),
+ ( "TypeFamilies", Opt_TypeFamilies ),
+ ( "BangPatterns", Opt_BangPatterns ),
+ -- On by default:
+ ( "MonomorphismRestriction", Opt_MonomorphismRestriction ),
+ -- On by default (which is not strictly H98):
+ ( "MonoPatBinds", Opt_MonoPatBinds ),
+ ( "RelaxedPolyRec", Opt_RelaxedPolyRec),
+ ( "ExtendedDefaultRules", Opt_ExtendedDefaultRules ),
+ ( "ImplicitParams", Opt_ImplicitParams ),
+ ( "ScopedTypeVariables", Opt_ScopedTypeVariables ),
+ ( "UnboxedTuples", Opt_UnboxedTuples ),
+ ( "StandaloneDeriving", Opt_StandaloneDeriving ),
+ ( "DeriveDataTypeable", Opt_DeriveDataTypeable ),
+ ( "TypeSynonymInstances", Opt_TypeSynonymInstances ),
+ ( "FlexibleContexts", Opt_FlexibleContexts ),
+ ( "FlexibleInstances", Opt_FlexibleInstances ),
+ ( "ConstrainedClassMethods", Opt_ConstrainedClassMethods ),
+ ( "MultiParamTypeClasses", Opt_MultiParamTypeClasses ),
+ ( "FunctionalDependencies", Opt_FunctionalDependencies ),
+ ( "GeneralizedNewtypeDeriving", Opt_GeneralizedNewtypeDeriving ),
+ ( "OverlappingInstances", Opt_OverlappingInstances ),
+ ( "UndecidableInstances", Opt_UndecidableInstances ),
+ ( "IncoherentInstances", Opt_IncoherentInstances )
+ ]
+
+impliedFlags :: [(DynFlag, [DynFlag])]
+impliedFlags = [
+ ( Opt_GADTs, [Opt_RelaxedPolyRec] ) -- We want type-sig variables to be completely rigid for GADTs
+ ]
+
+glasgowExtsFlags = [
+ Opt_PrintExplicitForalls
+ , Opt_ForeignFunctionInterface
+ , Opt_UnliftedFFITypes
+ , Opt_GADTs
+ , Opt_ImplicitParams
+ , Opt_ScopedTypeVariables
+ , Opt_UnboxedTuples
+ , Opt_TypeSynonymInstances
+ , Opt_StandaloneDeriving
+ , Opt_DeriveDataTypeable
+ , Opt_FlexibleContexts
+ , Opt_FlexibleInstances
+ , Opt_ConstrainedClassMethods
+ , Opt_MultiParamTypeClasses
+ , Opt_FunctionalDependencies
+ , Opt_MagicHash
+ , Opt_PolymorphicComponents
+ , Opt_ExistentialQuantification
+ , Opt_UnicodeSyntax
+ , Opt_PatternGuards
+ , Opt_PartiallyAppliedClosedTypeSynonyms
+ , Opt_RankNTypes
+ , Opt_TypeOperators
+ , Opt_RecursiveDo
+ , Opt_ParallelListComp
+ , Opt_EmptyDataDecls
+ , Opt_KindSignatures
+ , Opt_PatternSignatures
+ , Opt_GeneralizedNewtypeDeriving
+ , Opt_TypeFamilies ]
+
+------------------
+isFlag :: [(String,a)] -> String -> Bool
+isFlag flags f = any (\(ff,_) -> ff == f) flags
+
+isPrefFlag :: String -> [(String,a)] -> String -> Bool
+isPrefFlag pref flags no_f
+ | Just f <- maybePrefixMatch pref no_f = isFlag flags f
+ | otherwise = False
+
+------------------
+getFlag :: [(String,a)] -> String -> a
+getFlag flags f = case [ opt | (ff, opt) <- flags, ff == f] of
+ (o:os) -> o
+ [] -> panic ("get_flag " ++ f)
+
+getPrefFlag :: String -> [(String,a)] -> String -> a
+getPrefFlag pref flags f = getFlag flags (fromJust (maybePrefixMatch pref f))
+-- We should only be passed flags which match the prefix