{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE CPP #-}
module Language.Haskell.Exts.Extension (
Language(..),
knownLanguages,
classifyLanguage,
prettyLanguage,
Extension(..), KnownExtension(..),
classifyExtension,
parseExtension, prettyExtension,
ghcDefault, glasgowExts,
knownExtensions, deprecatedExtensions,
impliesExts, toExtensionList
) where
#if __GLASGOW_HASKELL__ < 710
import Control.Applicative ((<$>), (<|>))
#else
import Control.Applicative ((<|>))
#endif
import Data.Array (Array, accumArray, bounds, Ix(inRange), (!))
import Data.List (nub)
import Data.Maybe (fromMaybe)
import Data.Data
data Language =
Haskell98
| Haskell2010
| HaskellAllDisabled
| UnknownLanguage String
deriving (Int -> Language -> ShowS
[Language] -> ShowS
Language -> String
(Int -> Language -> ShowS)
-> (Language -> String) -> ([Language] -> ShowS) -> Show Language
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Language -> ShowS
showsPrec :: Int -> Language -> ShowS
$cshow :: Language -> String
show :: Language -> String
$cshowList :: [Language] -> ShowS
showList :: [Language] -> ShowS
Show, ReadPrec [Language]
ReadPrec Language
Int -> ReadS Language
ReadS [Language]
(Int -> ReadS Language)
-> ReadS [Language]
-> ReadPrec Language
-> ReadPrec [Language]
-> Read Language
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Language
readsPrec :: Int -> ReadS Language
$creadList :: ReadS [Language]
readList :: ReadS [Language]
$creadPrec :: ReadPrec Language
readPrec :: ReadPrec Language
$creadListPrec :: ReadPrec [Language]
readListPrec :: ReadPrec [Language]
Read, Language -> Language -> Bool
(Language -> Language -> Bool)
-> (Language -> Language -> Bool) -> Eq Language
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Language -> Language -> Bool
== :: Language -> Language -> Bool
$c/= :: Language -> Language -> Bool
/= :: Language -> Language -> Bool
Eq, Eq Language
Eq Language =>
(Language -> Language -> Ordering)
-> (Language -> Language -> Bool)
-> (Language -> Language -> Bool)
-> (Language -> Language -> Bool)
-> (Language -> Language -> Bool)
-> (Language -> Language -> Language)
-> (Language -> Language -> Language)
-> Ord Language
Language -> Language -> Bool
Language -> Language -> Ordering
Language -> Language -> Language
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Language -> Language -> Ordering
compare :: Language -> Language -> Ordering
$c< :: Language -> Language -> Bool
< :: Language -> Language -> Bool
$c<= :: Language -> Language -> Bool
<= :: Language -> Language -> Bool
$c> :: Language -> Language -> Bool
> :: Language -> Language -> Bool
$c>= :: Language -> Language -> Bool
>= :: Language -> Language -> Bool
$cmax :: Language -> Language -> Language
max :: Language -> Language -> Language
$cmin :: Language -> Language -> Language
min :: Language -> Language -> Language
Ord, Typeable Language
Typeable Language =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Language -> c Language)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Language)
-> (Language -> Constr)
-> (Language -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Language))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Language))
-> ((forall b. Data b => b -> b) -> Language -> Language)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Language -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Language -> r)
-> (forall u. (forall d. Data d => d -> u) -> Language -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Language -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Language -> m Language)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Language -> m Language)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Language -> m Language)
-> Data Language
Language -> Constr
Language -> DataType
(forall b. Data b => b -> b) -> Language -> Language
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Language -> u
forall u. (forall d. Data d => d -> u) -> Language -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Language -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Language -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Language -> m Language
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Language -> m Language
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Language
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Language -> c Language
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Language)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Language)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Language -> c Language
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Language -> c Language
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Language
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Language
$ctoConstr :: Language -> Constr
toConstr :: Language -> Constr
$cdataTypeOf :: Language -> DataType
dataTypeOf :: Language -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Language)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Language)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Language)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Language)
$cgmapT :: (forall b. Data b => b -> b) -> Language -> Language
gmapT :: (forall b. Data b => b -> b) -> Language -> Language
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Language -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Language -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Language -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Language -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Language -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Language -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Language -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Language -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Language -> m Language
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Language -> m Language
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Language -> m Language
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Language -> m Language
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Language -> m Language
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Language -> m Language
Data, Typeable)
knownLanguages :: [Language]
knownLanguages :: [Language]
knownLanguages = [Language
Haskell98, Language
Haskell2010]
classifyLanguage :: String -> Language
classifyLanguage :: String -> Language
classifyLanguage String
str = Language -> Maybe Language -> Language
forall a. a -> Maybe a -> a
fromMaybe (String -> Language
UnknownLanguage String
str) (Maybe Language -> Language) -> Maybe Language -> Language
forall a b. (a -> b) -> a -> b
$ String -> [(String, Language)] -> Maybe Language
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup String
str [(String, Language)]
langTable
where
langTable :: [(String, Language)]
langTable = [ (Language -> String
forall a. Show a => a -> String
show Language
lang, Language
lang)
| Language
lang <- [Language]
knownLanguages ]
prettyLanguage :: Language -> String
prettyLanguage :: Language -> String
prettyLanguage (UnknownLanguage String
name) = String
name
prettyLanguage Language
lang = Language -> String
forall a. Show a => a -> String
show Language
lang
data Extension =
EnableExtension KnownExtension
| DisableExtension KnownExtension
| UnknownExtension String
deriving (Int -> Extension -> ShowS
[Extension] -> ShowS
Extension -> String
(Int -> Extension -> ShowS)
-> (Extension -> String)
-> ([Extension] -> ShowS)
-> Show Extension
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Extension -> ShowS
showsPrec :: Int -> Extension -> ShowS
$cshow :: Extension -> String
show :: Extension -> String
$cshowList :: [Extension] -> ShowS
showList :: [Extension] -> ShowS
Show, ReadPrec [Extension]
ReadPrec Extension
Int -> ReadS Extension
ReadS [Extension]
(Int -> ReadS Extension)
-> ReadS [Extension]
-> ReadPrec Extension
-> ReadPrec [Extension]
-> Read Extension
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Extension
readsPrec :: Int -> ReadS Extension
$creadList :: ReadS [Extension]
readList :: ReadS [Extension]
$creadPrec :: ReadPrec Extension
readPrec :: ReadPrec Extension
$creadListPrec :: ReadPrec [Extension]
readListPrec :: ReadPrec [Extension]
Read, Extension -> Extension -> Bool
(Extension -> Extension -> Bool)
-> (Extension -> Extension -> Bool) -> Eq Extension
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Extension -> Extension -> Bool
== :: Extension -> Extension -> Bool
$c/= :: Extension -> Extension -> Bool
/= :: Extension -> Extension -> Bool
Eq, Eq Extension
Eq Extension =>
(Extension -> Extension -> Ordering)
-> (Extension -> Extension -> Bool)
-> (Extension -> Extension -> Bool)
-> (Extension -> Extension -> Bool)
-> (Extension -> Extension -> Bool)
-> (Extension -> Extension -> Extension)
-> (Extension -> Extension -> Extension)
-> Ord Extension
Extension -> Extension -> Bool
Extension -> Extension -> Ordering
Extension -> Extension -> Extension
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Extension -> Extension -> Ordering
compare :: Extension -> Extension -> Ordering
$c< :: Extension -> Extension -> Bool
< :: Extension -> Extension -> Bool
$c<= :: Extension -> Extension -> Bool
<= :: Extension -> Extension -> Bool
$c> :: Extension -> Extension -> Bool
> :: Extension -> Extension -> Bool
$c>= :: Extension -> Extension -> Bool
>= :: Extension -> Extension -> Bool
$cmax :: Extension -> Extension -> Extension
max :: Extension -> Extension -> Extension
$cmin :: Extension -> Extension -> Extension
min :: Extension -> Extension -> Extension
Ord)
data KnownExtension =
OverlappingInstances
| UndecidableInstances
| IncoherentInstances
| InstanceSigs
| DoRec
| RecursiveDo
| ParallelListComp
| MultiParamTypeClasses
| MonomorphismRestriction
| FunctionalDependencies
| Rank2Types
| RankNTypes
| PolymorphicComponents
| ExistentialQuantification
| ScopedTypeVariables
| PatternSignatures
| ImplicitParams
| FlexibleContexts
| FlexibleInstances
| EmptyDataDecls
| CPP
| KindSignatures
| BangPatterns
| TypeSynonymInstances
| TemplateHaskell
| ForeignFunctionInterface
| Arrows
| Generics
| ImplicitPrelude
| NamedFieldPuns
| PatternGuards
| GeneralizedNewtypeDeriving
| DeriveAnyClass
| ExtensibleRecords
| RestrictedTypeSynonyms
| HereDocuments
| MagicHash
| BinaryLiterals
| TypeFamilies
| StandaloneDeriving
| UnicodeSyntax
| UnliftedFFITypes
| LiberalTypeSynonyms
| TypeOperators
| ParallelArrays
| RecordWildCards
| RecordPuns
| DisambiguateRecordFields
| OverloadedStrings
| GADTs
| MonoPatBinds
| RelaxedPolyRec
| ExtendedDefaultRules
| UnboxedTuples
| DeriveDataTypeable
| ConstrainedClassMethods
| PackageImports
| LambdaCase
| EmptyCase
| ImpredicativeTypes
| NewQualifiedOperators
| PostfixOperators
| QuasiQuotes
| TransformListComp
| ViewPatterns
| XmlSyntax
| RegularPatterns
| TupleSections
| GHCForeignImportPrim
| NPlusKPatterns
| DoAndIfThenElse
| RebindableSyntax
| ExplicitForAll
| DatatypeContexts
| MonoLocalBinds
| DeriveFunctor
| DeriveGeneric
| DeriveTraversable
| DeriveFoldable
| NondecreasingIndentation
| InterruptibleFFI
| CApiFFI
| JavaScriptFFI
| ExplicitNamespaces
| DataKinds
| PolyKinds
| MultiWayIf
| SafeImports
| Safe
| Trustworthy
| DefaultSignatures
| ConstraintKinds
| RoleAnnotations
| PatternSynonyms
| PartialTypeSignatures
| NamedWildCards
| TypeApplications
| TypeFamilyDependencies
| OverloadedLabels
| DerivingStrategies
| UnboxedSums
| TypeInType
| Strict
| StrictData
| DerivingVia
| QuantifiedConstraints
| BlockArguments
deriving (Int -> KnownExtension -> ShowS
[KnownExtension] -> ShowS
KnownExtension -> String
(Int -> KnownExtension -> ShowS)
-> (KnownExtension -> String)
-> ([KnownExtension] -> ShowS)
-> Show KnownExtension
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> KnownExtension -> ShowS
showsPrec :: Int -> KnownExtension -> ShowS
$cshow :: KnownExtension -> String
show :: KnownExtension -> String
$cshowList :: [KnownExtension] -> ShowS
showList :: [KnownExtension] -> ShowS
Show, ReadPrec [KnownExtension]
ReadPrec KnownExtension
Int -> ReadS KnownExtension
ReadS [KnownExtension]
(Int -> ReadS KnownExtension)
-> ReadS [KnownExtension]
-> ReadPrec KnownExtension
-> ReadPrec [KnownExtension]
-> Read KnownExtension
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS KnownExtension
readsPrec :: Int -> ReadS KnownExtension
$creadList :: ReadS [KnownExtension]
readList :: ReadS [KnownExtension]
$creadPrec :: ReadPrec KnownExtension
readPrec :: ReadPrec KnownExtension
$creadListPrec :: ReadPrec [KnownExtension]
readListPrec :: ReadPrec [KnownExtension]
Read, KnownExtension -> KnownExtension -> Bool
(KnownExtension -> KnownExtension -> Bool)
-> (KnownExtension -> KnownExtension -> Bool) -> Eq KnownExtension
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: KnownExtension -> KnownExtension -> Bool
== :: KnownExtension -> KnownExtension -> Bool
$c/= :: KnownExtension -> KnownExtension -> Bool
/= :: KnownExtension -> KnownExtension -> Bool
Eq, Eq KnownExtension
Eq KnownExtension =>
(KnownExtension -> KnownExtension -> Ordering)
-> (KnownExtension -> KnownExtension -> Bool)
-> (KnownExtension -> KnownExtension -> Bool)
-> (KnownExtension -> KnownExtension -> Bool)
-> (KnownExtension -> KnownExtension -> Bool)
-> (KnownExtension -> KnownExtension -> KnownExtension)
-> (KnownExtension -> KnownExtension -> KnownExtension)
-> Ord KnownExtension
KnownExtension -> KnownExtension -> Bool
KnownExtension -> KnownExtension -> Ordering
KnownExtension -> KnownExtension -> KnownExtension
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: KnownExtension -> KnownExtension -> Ordering
compare :: KnownExtension -> KnownExtension -> Ordering
$c< :: KnownExtension -> KnownExtension -> Bool
< :: KnownExtension -> KnownExtension -> Bool
$c<= :: KnownExtension -> KnownExtension -> Bool
<= :: KnownExtension -> KnownExtension -> Bool
$c> :: KnownExtension -> KnownExtension -> Bool
> :: KnownExtension -> KnownExtension -> Bool
$c>= :: KnownExtension -> KnownExtension -> Bool
>= :: KnownExtension -> KnownExtension -> Bool
$cmax :: KnownExtension -> KnownExtension -> KnownExtension
max :: KnownExtension -> KnownExtension -> KnownExtension
$cmin :: KnownExtension -> KnownExtension -> KnownExtension
min :: KnownExtension -> KnownExtension -> KnownExtension
Ord, Int -> KnownExtension
KnownExtension -> Int
KnownExtension -> [KnownExtension]
KnownExtension -> KnownExtension
KnownExtension -> KnownExtension -> [KnownExtension]
KnownExtension
-> KnownExtension -> KnownExtension -> [KnownExtension]
(KnownExtension -> KnownExtension)
-> (KnownExtension -> KnownExtension)
-> (Int -> KnownExtension)
-> (KnownExtension -> Int)
-> (KnownExtension -> [KnownExtension])
-> (KnownExtension -> KnownExtension -> [KnownExtension])
-> (KnownExtension -> KnownExtension -> [KnownExtension])
-> (KnownExtension
-> KnownExtension -> KnownExtension -> [KnownExtension])
-> Enum KnownExtension
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: KnownExtension -> KnownExtension
succ :: KnownExtension -> KnownExtension
$cpred :: KnownExtension -> KnownExtension
pred :: KnownExtension -> KnownExtension
$ctoEnum :: Int -> KnownExtension
toEnum :: Int -> KnownExtension
$cfromEnum :: KnownExtension -> Int
fromEnum :: KnownExtension -> Int
$cenumFrom :: KnownExtension -> [KnownExtension]
enumFrom :: KnownExtension -> [KnownExtension]
$cenumFromThen :: KnownExtension -> KnownExtension -> [KnownExtension]
enumFromThen :: KnownExtension -> KnownExtension -> [KnownExtension]
$cenumFromTo :: KnownExtension -> KnownExtension -> [KnownExtension]
enumFromTo :: KnownExtension -> KnownExtension -> [KnownExtension]
$cenumFromThenTo :: KnownExtension
-> KnownExtension -> KnownExtension -> [KnownExtension]
enumFromThenTo :: KnownExtension
-> KnownExtension -> KnownExtension -> [KnownExtension]
Enum, KnownExtension
KnownExtension -> KnownExtension -> Bounded KnownExtension
forall a. a -> a -> Bounded a
$cminBound :: KnownExtension
minBound :: KnownExtension
$cmaxBound :: KnownExtension
maxBound :: KnownExtension
Bounded, Typeable KnownExtension
Typeable KnownExtension =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KnownExtension -> c KnownExtension)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KnownExtension)
-> (KnownExtension -> Constr)
-> (KnownExtension -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KnownExtension))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c KnownExtension))
-> ((forall b. Data b => b -> b)
-> KnownExtension -> KnownExtension)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KnownExtension -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KnownExtension -> r)
-> (forall u.
(forall d. Data d => d -> u) -> KnownExtension -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> KnownExtension -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension)
-> Data KnownExtension
KnownExtension -> Constr
KnownExtension -> DataType
(forall b. Data b => b -> b) -> KnownExtension -> KnownExtension
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> KnownExtension -> u
forall u. (forall d. Data d => d -> u) -> KnownExtension -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KnownExtension -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KnownExtension -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KnownExtension
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KnownExtension -> c KnownExtension
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KnownExtension)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c KnownExtension)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KnownExtension -> c KnownExtension
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KnownExtension -> c KnownExtension
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KnownExtension
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KnownExtension
$ctoConstr :: KnownExtension -> Constr
toConstr :: KnownExtension -> Constr
$cdataTypeOf :: KnownExtension -> DataType
dataTypeOf :: KnownExtension -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KnownExtension)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KnownExtension)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c KnownExtension)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c KnownExtension)
$cgmapT :: (forall b. Data b => b -> b) -> KnownExtension -> KnownExtension
gmapT :: (forall b. Data b => b -> b) -> KnownExtension -> KnownExtension
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KnownExtension -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KnownExtension -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KnownExtension -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KnownExtension -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> KnownExtension -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> KnownExtension -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> KnownExtension -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> KnownExtension -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> KnownExtension -> m KnownExtension
Data, Typeable)
impliesExts :: [KnownExtension] -> [KnownExtension]
impliesExts :: [KnownExtension] -> [KnownExtension]
impliesExts = [KnownExtension] -> [KnownExtension]
go
where go :: [KnownExtension] -> [KnownExtension]
go [] = []
go [KnownExtension]
es = let xs :: [KnownExtension]
xs = (KnownExtension -> [KnownExtension])
-> [KnownExtension] -> [KnownExtension]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap KnownExtension -> [KnownExtension]
implE [KnownExtension]
es
ys :: [KnownExtension]
ys = (KnownExtension -> Bool) -> [KnownExtension] -> [KnownExtension]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (KnownExtension -> Bool) -> KnownExtension -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (KnownExtension -> [KnownExtension] -> Bool)
-> [KnownExtension] -> KnownExtension -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip KnownExtension -> [KnownExtension] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem [KnownExtension]
es) [KnownExtension]
xs
in [KnownExtension]
es [KnownExtension] -> [KnownExtension] -> [KnownExtension]
forall a. [a] -> [a] -> [a]
++ [KnownExtension] -> [KnownExtension]
go [KnownExtension]
ys
implE :: KnownExtension -> [KnownExtension]
implE KnownExtension
e = case KnownExtension
e of
KnownExtension
TypeFamilies -> [KnownExtension
KindSignatures]
KnownExtension
ScopedTypeVariables -> [KnownExtension
TypeOperators, KnownExtension
ExplicitForAll]
KnownExtension
XmlSyntax -> [KnownExtension
RegularPatterns]
KnownExtension
RegularPatterns -> [KnownExtension
PatternGuards]
KnownExtension
RankNTypes -> [KnownExtension
Rank2Types, KnownExtension
ExplicitForAll]
KnownExtension
Rank2Types -> [KnownExtension
PolymorphicComponents, KnownExtension
ExplicitForAll]
KnownExtension
PolymorphicComponents -> [KnownExtension
ExplicitForAll]
KnownExtension
LiberalTypeSynonyms -> [KnownExtension
ExplicitForAll]
KnownExtension
ExistentialQuantification -> [KnownExtension
ExplicitForAll]
KnownExtension
ImpredicativeTypes -> [KnownExtension
ExplicitForAll]
KnownExtension
PolyKinds -> [KnownExtension
KindSignatures]
KnownExtension
TypeFamilyDependencies -> [KnownExtension
TypeFamilies]
KnownExtension
TypeInType -> [KnownExtension
PolyKinds, KnownExtension
DataKinds, KnownExtension
KindSignatures]
KnownExtension
TypeOperators -> [KnownExtension
ExplicitNamespaces]
KnownExtension
RecordPuns -> [KnownExtension
NamedFieldPuns]
KnownExtension
PatternSignatures -> [KnownExtension
ScopedTypeVariables]
KnownExtension
DerivingVia -> [KnownExtension
DerivingStrategies]
KnownExtension
_ -> []
glasgowExts :: [Extension]
glasgowExts :: [Extension]
glasgowExts = (KnownExtension -> Extension) -> [KnownExtension] -> [Extension]
forall a b. (a -> b) -> [a] -> [b]
map KnownExtension -> Extension
EnableExtension [
KnownExtension
ForeignFunctionInterface
, KnownExtension
UnliftedFFITypes
, KnownExtension
GADTs
, KnownExtension
ImplicitParams
, KnownExtension
ScopedTypeVariables
, KnownExtension
UnboxedTuples
, KnownExtension
TypeSynonymInstances
, KnownExtension
StandaloneDeriving
, KnownExtension
DeriveDataTypeable
, KnownExtension
FlexibleContexts
, KnownExtension
FlexibleInstances
, KnownExtension
ConstrainedClassMethods
, KnownExtension
MultiParamTypeClasses
, KnownExtension
FunctionalDependencies
, KnownExtension
MagicHash
, KnownExtension
PolymorphicComponents
, KnownExtension
ExistentialQuantification
, KnownExtension
UnicodeSyntax
, KnownExtension
PostfixOperators
, KnownExtension
PatternGuards
, KnownExtension
LiberalTypeSynonyms
, KnownExtension
RankNTypes
, KnownExtension
ImpredicativeTypes
, KnownExtension
TypeOperators
, KnownExtension
RecursiveDo
, KnownExtension
ParallelListComp
, KnownExtension
EmptyDataDecls
, KnownExtension
KindSignatures
, KnownExtension
GeneralizedNewtypeDeriving
, KnownExtension
TypeFamilies
]
allLangDefault :: [KnownExtension]
allLangDefault :: [KnownExtension]
allLangDefault = [KnownExtension
MonomorphismRestriction, KnownExtension
MonoPatBinds, KnownExtension
ImplicitPrelude]
ghcDefault :: [Extension]
ghcDefault :: [Extension]
ghcDefault = (KnownExtension -> Extension) -> [KnownExtension] -> [Extension]
forall a b. (a -> b) -> [a] -> [b]
map KnownExtension -> Extension
EnableExtension (KnownExtension
NondecreasingIndentationKnownExtension -> [KnownExtension] -> [KnownExtension]
forall a. a -> [a] -> [a]
:[KnownExtension]
allLangDefault)
knownExtensions :: [Extension]
knownExtensions :: [Extension]
knownExtensions =
[[Extension]] -> [Extension]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [ [KnownExtension -> Extension
EnableExtension KnownExtension
x, KnownExtension -> Extension
DisableExtension KnownExtension
x] | KnownExtension
x <- [KnownExtension
forall a. Bounded a => a
minBound..KnownExtension
forall a. Bounded a => a
maxBound] ]
deprecatedExtensions :: [(Extension, Maybe Extension)]
deprecatedExtensions :: [(Extension, Maybe Extension)]
deprecatedExtensions =
[ (KnownExtension -> Extension
EnableExtension KnownExtension
RecordPuns, Extension -> Maybe Extension
forall a. a -> Maybe a
Just (KnownExtension -> Extension
EnableExtension KnownExtension
NamedFieldPuns))
, (KnownExtension -> Extension
EnableExtension KnownExtension
PatternSignatures, Extension -> Maybe Extension
forall a. a -> Maybe a
Just (KnownExtension -> Extension
EnableExtension KnownExtension
ScopedTypeVariables))
]
classifyExtension :: String -> Extension
classifyExtension :: String -> Extension
classifyExtension String
string
= case String -> Maybe KnownExtension
classifyKnownExtension String
string of
Just KnownExtension
ext -> KnownExtension -> Extension
EnableExtension KnownExtension
ext
Maybe KnownExtension
Nothing ->
case String
string of
Char
'N':Char
'o':String
string' ->
case String -> Maybe KnownExtension
classifyKnownExtension String
string' of
Just KnownExtension
ext -> KnownExtension -> Extension
DisableExtension KnownExtension
ext
Maybe KnownExtension
Nothing -> String -> Extension
UnknownExtension String
string
String
_ -> String -> Extension
UnknownExtension String
string
classifyKnownExtension :: String -> Maybe KnownExtension
classifyKnownExtension :: String -> Maybe KnownExtension
classifyKnownExtension String
"" = Maybe KnownExtension
forall a. Maybe a
Nothing
classifyKnownExtension string :: String
string@(Char
c : String
_)
| (Char, Char) -> Char -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (Array Char [(String, KnownExtension)] -> (Char, Char)
forall i e. Array i e -> (i, i)
bounds Array Char [(String, KnownExtension)]
knownExtensionTable) Char
c
= String -> [(String, KnownExtension)] -> Maybe KnownExtension
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup String
string (Array Char [(String, KnownExtension)]
knownExtensionTable Array Char [(String, KnownExtension)]
-> Char -> [(String, KnownExtension)]
forall i e. Ix i => Array i e -> i -> e
! Char
c)
| Bool
otherwise = Maybe KnownExtension
forall a. Maybe a
Nothing
knownExtensionTable :: Array Char [(String, KnownExtension)]
knownExtensionTable :: Array Char [(String, KnownExtension)]
knownExtensionTable =
([(String, KnownExtension)]
-> (String, KnownExtension) -> [(String, KnownExtension)])
-> [(String, KnownExtension)]
-> (Char, Char)
-> [(Char, (String, KnownExtension))]
-> Array Char [(String, KnownExtension)]
forall i e a.
Ix i =>
(e -> a -> e) -> e -> (i, i) -> [(i, a)] -> Array i e
accumArray (((String, KnownExtension)
-> [(String, KnownExtension)] -> [(String, KnownExtension)])
-> [(String, KnownExtension)]
-> (String, KnownExtension)
-> [(String, KnownExtension)]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (:)) [] (Char
'A', Char
'Z')
[ (String -> Char
forall a. HasCallStack => [a] -> a
head String
str, (String
str, KnownExtension
extension))
| KnownExtension
extension <- [Int -> KnownExtension
forall a. Enum a => Int -> a
toEnum Int
0 ..]
, let str :: String
str = KnownExtension -> String
forall a. Show a => a -> String
show KnownExtension
extension ]
parseExtension :: String -> Extension
parseExtension :: String -> Extension
parseExtension String
str = Extension -> Maybe Extension -> Extension
forall a. a -> Maybe a -> a
fromMaybe (String -> Extension
UnknownExtension String
str) (Maybe Extension -> Extension) -> Maybe Extension -> Extension
forall a b. (a -> b) -> a -> b
$
KnownExtension -> Extension
EnableExtension (KnownExtension -> Extension)
-> Maybe KnownExtension -> Maybe Extension
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> Maybe KnownExtension
forall a. Read a => String -> Maybe a
readMay String
str
Maybe Extension -> Maybe Extension -> Maybe Extension
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> KnownExtension -> Extension
DisableExtension (KnownExtension -> Extension)
-> Maybe KnownExtension -> Maybe Extension
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (String -> Maybe KnownExtension
forall a. Read a => String -> Maybe a
readMay (String -> Maybe KnownExtension)
-> Maybe String -> Maybe KnownExtension
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< String -> Maybe String
dropNo String
str)
where
dropNo :: String -> Maybe String
dropNo (Char
'N':Char
'o':String
rest) = String -> Maybe String
forall a. a -> Maybe a
Just String
rest
dropNo String
_ = Maybe String
forall a. Maybe a
Nothing
prettyExtension :: Extension -> String
prettyExtension :: Extension -> String
prettyExtension (EnableExtension KnownExtension
ext) = KnownExtension -> String
forall a. Show a => a -> String
show KnownExtension
ext
prettyExtension (DisableExtension KnownExtension
ext) = String
"No" String -> ShowS
forall a. [a] -> [a] -> [a]
++ KnownExtension -> String
forall a. Show a => a -> String
show KnownExtension
ext
prettyExtension (UnknownExtension String
str) = String
str
readMay :: Read a => String -> Maybe a
readMay :: forall a. Read a => String -> Maybe a
readMay String
s = case [a
x | (a
x,String
t) <- ReadS a
forall a. Read a => ReadS a
reads String
s, (String
"",String
"") <- ReadS String
lex String
t] of
[a
x] -> a -> Maybe a
forall a. a -> Maybe a
Just a
x
[a]
_ -> Maybe a
forall a. Maybe a
Nothing
toExtensionList :: Language -> [Extension] -> [KnownExtension]
toExtensionList :: Language -> [Extension] -> [KnownExtension]
toExtensionList Language
lang [Extension]
exts' =
let langKes :: [KnownExtension]
langKes = case Language
lang of
Language
Haskell98 -> KnownExtension
NPlusKPatternsKnownExtension -> [KnownExtension] -> [KnownExtension]
forall a. a -> [a] -> [a]
:[KnownExtension]
allLangDefault
Language
Haskell2010 -> [KnownExtension
DoAndIfThenElse
, KnownExtension
PatternGuards
, KnownExtension
ForeignFunctionInterface
, KnownExtension
EmptyDataDecls
] [KnownExtension] -> [KnownExtension] -> [KnownExtension]
forall a. [a] -> [a] -> [a]
++ [KnownExtension]
allLangDefault
Language
HaskellAllDisabled -> []
UnknownLanguage String
s ->
String -> [KnownExtension]
forall a. HasCallStack => String -> a
error (String -> [KnownExtension]) -> String -> [KnownExtension]
forall a b. (a -> b) -> a -> b
$ String
"toExtensionList: Unknown language " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
in [KnownExtension] -> [KnownExtension]
impliesExts ([KnownExtension] -> [KnownExtension])
-> [KnownExtension] -> [KnownExtension]
forall a b. (a -> b) -> a -> b
$ [KnownExtension] -> [KnownExtension]
forall a. Eq a => [a] -> [a]
nub ([KnownExtension] -> [KnownExtension])
-> [KnownExtension] -> [KnownExtension]
forall a b. (a -> b) -> a -> b
$ [KnownExtension] -> [Extension] -> [KnownExtension]
go [KnownExtension]
langKes [Extension]
exts'
where go :: [KnownExtension] -> [Extension] -> [KnownExtension]
go :: [KnownExtension] -> [Extension] -> [KnownExtension]
go [KnownExtension]
acc [] = [KnownExtension]
acc
go [KnownExtension]
acc (DisableExtension KnownExtension
x : [Extension]
exts) = [KnownExtension] -> [Extension] -> [KnownExtension]
go ((KnownExtension -> Bool) -> [KnownExtension] -> [KnownExtension]
forall a. (a -> Bool) -> [a] -> [a]
filter (KnownExtension -> KnownExtension -> Bool
forall a. Eq a => a -> a -> Bool
/= KnownExtension
x) [KnownExtension]
acc) [Extension]
exts
go [KnownExtension]
acc (EnableExtension KnownExtension
x : [Extension]
exts) = [KnownExtension] -> [Extension] -> [KnownExtension]
go (KnownExtension
x KnownExtension -> [KnownExtension] -> [KnownExtension]
forall a. a -> [a] -> [a]
: [KnownExtension]
acc) [Extension]
exts
go [KnownExtension]
acc (Extension
_ : [Extension]
exts) = [KnownExtension] -> [Extension] -> [KnownExtension]
go [KnownExtension]
acc [Extension]
exts