{-# LANGUAGE CPP #-}
{- |
  Module      :  Language.Haskell.Meta.Parse
  Copyright   :  (c) Serokell 2022, Adam Bergmark 2022
  License     :  BSD3
  Maintainer  :  Adam Bergmark <adam@bergmark.nl>
  Stability   :  experimental
  Portability :  portable (template-haskell)
-}

module Language.Haskell.Meta.Extensions (
  toExtension,
  fromExtension
 ) where

import qualified Language.Haskell.Exts.Extension as Exts
import qualified Language.Haskell.TH.Syntax      as TH


-----------------------------------------------------------------------------

-- * To template-haskell

-- | Returns @Nothing@ when the extension is not supported by template-haskell.
toExtension :: Exts.KnownExtension -> Maybe TH.Extension
toExtension :: KnownExtension -> Maybe Extension
toExtension KnownExtension
e = case KnownExtension
e of
  KnownExtension
Exts.OverlappingInstances       -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.OverlappingInstances
  KnownExtension
Exts.UndecidableInstances       -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.UndecidableInstances
  KnownExtension
Exts.IncoherentInstances        -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.IncoherentInstances
  KnownExtension
Exts.InstanceSigs               -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.InstanceSigs
  KnownExtension
Exts.DoRec                      -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.RecursiveDo                -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.RecursiveDo
  KnownExtension
Exts.ParallelListComp           -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ParallelListComp
  KnownExtension
Exts.MultiParamTypeClasses      -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.MultiParamTypeClasses
  KnownExtension
Exts.MonomorphismRestriction    -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.MonomorphismRestriction
  KnownExtension
Exts.FunctionalDependencies     -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.FunctionalDependencies
  KnownExtension
Exts.Rank2Types                 -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.RankNTypes                 -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.RankNTypes
  KnownExtension
Exts.PolymorphicComponents      -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.ExistentialQuantification  -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ExistentialQuantification
  KnownExtension
Exts.ScopedTypeVariables        -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ScopedTypeVariables
  KnownExtension
Exts.PatternSignatures          -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.ImplicitParams             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ImplicitParams
  KnownExtension
Exts.FlexibleContexts           -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.FlexibleContexts
  KnownExtension
Exts.FlexibleInstances          -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.FlexibleInstances
  KnownExtension
Exts.EmptyDataDecls             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.EmptyDataDecls
  KnownExtension
Exts.CPP                        -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.Cpp
  KnownExtension
Exts.KindSignatures             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.KindSignatures
  KnownExtension
Exts.BangPatterns               -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.BangPatterns
  KnownExtension
Exts.TypeSynonymInstances       -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.TypeSynonymInstances
  KnownExtension
Exts.TemplateHaskell            -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.TemplateHaskell
  KnownExtension
Exts.ForeignFunctionInterface   -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ForeignFunctionInterface
  KnownExtension
Exts.Arrows                     -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.Arrows
  KnownExtension
Exts.Generics                   -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.ImplicitPrelude            -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ImplicitPrelude
  KnownExtension
Exts.NamedFieldPuns             -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.PatternGuards              -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.PatternGuards
  KnownExtension
Exts.GeneralizedNewtypeDeriving -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.GeneralizedNewtypeDeriving
  KnownExtension
Exts.DeriveAnyClass             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DeriveAnyClass
  KnownExtension
Exts.ExtensibleRecords          -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.RestrictedTypeSynonyms     -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.HereDocuments              -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.MagicHash                  -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.MagicHash
  KnownExtension
Exts.BinaryLiterals             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.BinaryLiterals
  KnownExtension
Exts.TypeFamilies               -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.TypeFamilies
  KnownExtension
Exts.StandaloneDeriving         -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.StandaloneDeriving
  KnownExtension
Exts.UnicodeSyntax              -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.UnicodeSyntax
  KnownExtension
Exts.UnliftedFFITypes           -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.UnliftedFFITypes
  KnownExtension
Exts.LiberalTypeSynonyms        -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.LiberalTypeSynonyms
  KnownExtension
Exts.TypeOperators              -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.TypeOperators
  KnownExtension
Exts.ParallelArrays             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ParallelArrays
  KnownExtension
Exts.RecordWildCards            -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.RecordWildCards
#if __GLASGOW_HASKELL__ >= 904
  Exts.RecordPuns                 -> Just TH.NamedFieldPuns
#else
  KnownExtension
Exts.RecordPuns                 -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.RecordPuns
#endif
  KnownExtension
Exts.DisambiguateRecordFields   -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DisambiguateRecordFields
  KnownExtension
Exts.OverloadedStrings          -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.OverloadedStrings
  KnownExtension
Exts.GADTs                      -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.GADTs
  KnownExtension
Exts.MonoPatBinds               ->
#if !MIN_VERSION_template_haskell(2,18,0)
    Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.MonoPatBinds
#else
    Nothing
#endif
  KnownExtension
Exts.RelaxedPolyRec             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.RelaxedPolyRec
  KnownExtension
Exts.ExtendedDefaultRules       -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ExtendedDefaultRules
  KnownExtension
Exts.UnboxedTuples              -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.UnboxedTuples
  KnownExtension
Exts.DeriveDataTypeable         -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DeriveDataTypeable
  KnownExtension
Exts.ConstrainedClassMethods    -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ConstrainedClassMethods
  KnownExtension
Exts.PackageImports             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.PackageImports
  KnownExtension
Exts.LambdaCase                 -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.LambdaCase
  KnownExtension
Exts.EmptyCase                  -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.EmptyCase
  KnownExtension
Exts.ImpredicativeTypes         -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ImpredicativeTypes
  KnownExtension
Exts.NewQualifiedOperators      -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.PostfixOperators           -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.PostfixOperators
  KnownExtension
Exts.QuasiQuotes                -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.QuasiQuotes
  KnownExtension
Exts.TransformListComp          -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.TransformListComp
  KnownExtension
Exts.ViewPatterns               -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ViewPatterns
  KnownExtension
Exts.XmlSyntax                  -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.RegularPatterns            -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.TupleSections              -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.TupleSections
  KnownExtension
Exts.GHCForeignImportPrim       -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.GHCForeignImportPrim
  KnownExtension
Exts.NPlusKPatterns             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.NPlusKPatterns
  KnownExtension
Exts.DoAndIfThenElse            -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DoAndIfThenElse
  KnownExtension
Exts.RebindableSyntax           -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.RebindableSyntax
  KnownExtension
Exts.ExplicitForAll             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ExplicitForAll
  KnownExtension
Exts.DatatypeContexts           -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DatatypeContexts
  KnownExtension
Exts.MonoLocalBinds             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.MonoLocalBinds
  KnownExtension
Exts.DeriveFunctor              -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DeriveFunctor
  KnownExtension
Exts.DeriveGeneric              -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DeriveGeneric
  KnownExtension
Exts.DeriveTraversable          -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DeriveTraversable
  KnownExtension
Exts.DeriveFoldable             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DeriveFoldable
  KnownExtension
Exts.NondecreasingIndentation   -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.NondecreasingIndentation
  KnownExtension
Exts.InterruptibleFFI           -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.InterruptibleFFI
  KnownExtension
Exts.CApiFFI                    -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.CApiFFI
  KnownExtension
Exts.JavaScriptFFI              -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.JavaScriptFFI
  KnownExtension
Exts.ExplicitNamespaces         -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ExplicitNamespaces
  KnownExtension
Exts.DataKinds                  -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DataKinds
  KnownExtension
Exts.PolyKinds                  -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.PolyKinds
  KnownExtension
Exts.MultiWayIf                 -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.MultiWayIf
  KnownExtension
Exts.SafeImports                -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.Safe                       -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.Trustworthy                -> Maybe Extension
forall a. Maybe a
Nothing
  KnownExtension
Exts.DefaultSignatures          -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DefaultSignatures
  KnownExtension
Exts.ConstraintKinds            -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.ConstraintKinds
  KnownExtension
Exts.RoleAnnotations            -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.RoleAnnotations
  KnownExtension
Exts.PatternSynonyms            -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.PatternSynonyms
  KnownExtension
Exts.PartialTypeSignatures      -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.PartialTypeSignatures
  KnownExtension
Exts.NamedWildCards             -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.NamedWildCards
  KnownExtension
Exts.TypeApplications           -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.TypeApplications
  KnownExtension
Exts.TypeFamilyDependencies     -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.TypeFamilyDependencies
  KnownExtension
Exts.OverloadedLabels           -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.OverloadedLabels
  KnownExtension
Exts.DerivingStrategies         -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DerivingStrategies
  KnownExtension
Exts.UnboxedSums                -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.UnboxedSums
#if MIN_VERSION_haskell_src_exts(1,21,0)
  KnownExtension
Exts.TypeInType                 -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.TypeInType
#endif
  KnownExtension
Exts.Strict                     -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.Strict
  KnownExtension
Exts.StrictData                 -> Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.StrictData

#if MIN_VERSION_haskell_src_exts(1,21,0)
  KnownExtension
Exts.DerivingVia                ->
#if MIN_VERSION_template_haskell(2,14,0)
    Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.DerivingVia
#else
    Nothing
#endif
#endif

#if MIN_VERSION_haskell_src_exts(1,22,0)
  KnownExtension
Exts.QuantifiedConstraints      ->
#if MIN_VERSION_template_haskell(2,14,0)
    Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.QuantifiedConstraints
#else
    Nothing
#endif
#endif

#if MIN_VERSION_haskell_src_exts(1,23,0)
  KnownExtension
Exts.BlockArguments             ->
#if MIN_VERSION_template_haskell(2,14,0)
    Extension -> Maybe Extension
forall a. a -> Maybe a
Just Extension
TH.BlockArguments
#else
    Nothing
#endif
#endif

  -- NB: when adding a case here, you may also need to update `fromExtension`


-----------------------------------------------------------------------------

-- * From template-haskell

-- | Returns @Nothing@ when the extension is not supported by haskell-src-exts.
fromExtension :: TH.Extension -> Maybe Exts.KnownExtension
fromExtension :: Extension -> Maybe KnownExtension
fromExtension Extension
e = case Extension
e of
  Extension
TH.Cpp                               -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.CPP
  Extension
TH.OverlappingInstances              -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.OverlappingInstances
  Extension
TH.UndecidableInstances              -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.UndecidableInstances
  Extension
TH.IncoherentInstances               -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.IncoherentInstances
  Extension
TH.UndecidableSuperClasses           -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.MonomorphismRestriction           -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.MonomorphismRestriction
#if !MIN_VERSION_template_haskell(2,18,0)
  Extension
TH.MonoPatBinds                      -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.MonoPatBinds
#endif
  Extension
TH.MonoLocalBinds                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.MonoLocalBinds
  Extension
TH.RelaxedPolyRec                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.RelaxedPolyRec
  Extension
TH.ExtendedDefaultRules              -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ExtendedDefaultRules
  Extension
TH.ForeignFunctionInterface          -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ForeignFunctionInterface
  Extension
TH.UnliftedFFITypes                  -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.UnliftedFFITypes
  Extension
TH.InterruptibleFFI                  -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.InterruptibleFFI
  Extension
TH.CApiFFI                           -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.CApiFFI
  Extension
TH.GHCForeignImportPrim              -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.GHCForeignImportPrim
  Extension
TH.JavaScriptFFI                     -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.JavaScriptFFI
  Extension
TH.ParallelArrays                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ParallelArrays
  Extension
TH.Arrows                            -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.Arrows
  Extension
TH.TemplateHaskell                   -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.TemplateHaskell
  Extension
TH.TemplateHaskellQuotes             -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.QuasiQuotes                       -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.QuasiQuotes
  Extension
TH.ImplicitParams                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ImplicitParams
  Extension
TH.ImplicitPrelude                   -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ImplicitPrelude
  Extension
TH.ScopedTypeVariables               -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ScopedTypeVariables
  Extension
TH.AllowAmbiguousTypes               -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.UnboxedTuples                     -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.UnboxedTuples
  Extension
TH.UnboxedSums                       -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.UnboxedSums
  Extension
TH.BangPatterns                      -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.BangPatterns
  Extension
TH.TypeFamilies                      -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.TypeFamilies
  Extension
TH.TypeFamilyDependencies            -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.TypeFamilyDependencies
  Extension
TH.TypeInType                        ->
#if MIN_VERSION_haskell_src_exts(1,21,0)
    KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.TypeInType
#else
    Nothing
#endif
  Extension
TH.OverloadedStrings                 -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.OverloadedStrings
  Extension
TH.OverloadedLists                   -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.NumDecimals                       -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.DisambiguateRecordFields          -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DisambiguateRecordFields
  Extension
TH.RecordWildCards                   -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.RecordWildCards
#if __GLASGOW_HASKELL__ >= 904
  TH.NamedFieldPuns                    -> Just Exts.RecordPuns
  TH.QualifiedDo                       -> Nothing
  TH.UnliftedDatatypes -> Nothing
  TH.LinearTypes -> Nothing
  TH.LexicalNegation -> Nothing
  TH.FieldSelectors -> Nothing
  TH.OverloadedRecordDot -> Nothing
  TH.OverloadedRecordUpdate -> Nothing
#else
  Extension
TH.RecordPuns                        -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.RecordPuns
#endif
  Extension
TH.ViewPatterns                      -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ViewPatterns
  Extension
TH.GADTs                             -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.GADTs
  Extension
TH.GADTSyntax                        -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.NPlusKPatterns                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.NPlusKPatterns
  Extension
TH.DoAndIfThenElse                   -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DoAndIfThenElse
  Extension
TH.RebindableSyntax                  -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.RebindableSyntax
  Extension
TH.ConstraintKinds                   -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ConstraintKinds
  Extension
TH.PolyKinds                         -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.PolyKinds
  Extension
TH.DataKinds                         -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DataKinds
  Extension
TH.InstanceSigs                      -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.InstanceSigs
  Extension
TH.ApplicativeDo                     -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.StandaloneDeriving                -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.StandaloneDeriving
  Extension
TH.DeriveDataTypeable                -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DeriveDataTypeable
  Extension
TH.AutoDeriveTypeable                -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.DeriveFunctor                     -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DeriveFunctor
  Extension
TH.DeriveTraversable                 -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DeriveTraversable
  Extension
TH.DeriveFoldable                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DeriveFoldable
  Extension
TH.DeriveGeneric                     -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DeriveGeneric
  Extension
TH.DefaultSignatures                 -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DefaultSignatures
  Extension
TH.DeriveAnyClass                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DeriveAnyClass
  Extension
TH.DeriveLift                        -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.DerivingStrategies                -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DerivingStrategies
  Extension
TH.TypeSynonymInstances              -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.TypeSynonymInstances
  Extension
TH.FlexibleContexts                  -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.FlexibleContexts
  Extension
TH.FlexibleInstances                 -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.FlexibleInstances
  Extension
TH.ConstrainedClassMethods           -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ConstrainedClassMethods
  Extension
TH.MultiParamTypeClasses             -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.MultiParamTypeClasses
  Extension
TH.NullaryTypeClasses                -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.FunctionalDependencies            -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.FunctionalDependencies
  Extension
TH.UnicodeSyntax                     -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.UnicodeSyntax
  Extension
TH.ExistentialQuantification         -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ExistentialQuantification
  Extension
TH.MagicHash                         -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.MagicHash
  Extension
TH.EmptyDataDecls                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.EmptyDataDecls
  Extension
TH.KindSignatures                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.KindSignatures
  Extension
TH.RoleAnnotations                   -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.RoleAnnotations
  Extension
TH.ParallelListComp                  -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ParallelListComp
  Extension
TH.TransformListComp                 -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.TransformListComp
  Extension
TH.MonadComprehensions               -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.GeneralizedNewtypeDeriving        -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.GeneralizedNewtypeDeriving
  Extension
TH.RecursiveDo                       -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.RecursiveDo
  Extension
TH.PostfixOperators                  -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.PostfixOperators
  Extension
TH.TupleSections                     -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.TupleSections
  Extension
TH.PatternGuards                     -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.PatternGuards
  Extension
TH.LiberalTypeSynonyms               -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.LiberalTypeSynonyms
  Extension
TH.RankNTypes                        -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.RankNTypes
  Extension
TH.ImpredicativeTypes                -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ImpredicativeTypes
  Extension
TH.TypeOperators                     -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.TypeOperators
  Extension
TH.ExplicitNamespaces                -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ExplicitNamespaces
  Extension
TH.PackageImports                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.PackageImports
  Extension
TH.ExplicitForAll                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.ExplicitForAll
  Extension
TH.AlternativeLayoutRule             -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.AlternativeLayoutRuleTransitional -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.DatatypeContexts                  -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DatatypeContexts
  Extension
TH.NondecreasingIndentation          -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.NondecreasingIndentation
  Extension
TH.RelaxedLayout                     -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.TraditionalRecordSyntax           -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.LambdaCase                        -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.LambdaCase
  Extension
TH.MultiWayIf                        -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.MultiWayIf
  Extension
TH.BinaryLiterals                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.BinaryLiterals
  Extension
TH.NegativeLiterals                  -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.DuplicateRecordFields             -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.OverloadedLabels                  -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.OverloadedLabels
  Extension
TH.EmptyCase                         -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.EmptyCase
  Extension
TH.PatternSynonyms                   -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.PatternSynonyms
  Extension
TH.PartialTypeSignatures             -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.PartialTypeSignatures
  Extension
TH.NamedWildCards                    -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.NamedWildCards
  Extension
TH.StaticPointers                    -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.TypeApplications                  -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.TypeApplications
  Extension
TH.Strict                            -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.Strict
  Extension
TH.StrictData                        -> KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.StrictData
#if !MIN_VERSION_template_haskell(2,18,0)
  Extension
TH.MonadFailDesugaring               -> Maybe KnownExtension
forall a. Maybe a
Nothing
#endif

-- 2.13.0 ----------------------------------------
#if MIN_VERSION_template_haskell(2,13,0)
  Extension
TH.HexFloatLiterals                  -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.EmptyDataDeriving                 -> Maybe KnownExtension
forall a. Maybe a
Nothing
#endif

-- 2.14.0 ----------------------------------------
#if MIN_VERSION_template_haskell(2,14,0)

  Extension
TH.DerivingVia                       ->
#if MIN_VERSION_haskell_src_exts(1,21,0)
    KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.DerivingVia
#else
    Nothing
#endif

  Extension
TH.QuantifiedConstraints             ->
#if MIN_VERSION_haskell_src_exts(1,22,0)
    KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.QuantifiedConstraints
#else
    Nothing
#endif

  Extension
TH.BlockArguments                    ->
#if MIN_VERSION_haskell_src_exts(1,23,0)
    KnownExtension -> Maybe KnownExtension
forall a. a -> Maybe a
Just KnownExtension
Exts.BlockArguments
#else
    Nothing
#endif

  Extension
TH.NumericUnderscores                -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.StarIsType                        -> Maybe KnownExtension
forall a. Maybe a
Nothing
#endif

-- 2.16.0 ----------------------------------------
#if MIN_VERSION_template_haskell(2,16,0)
  Extension
TH.UnliftedNewtypes                  -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.ImportQualifiedPost               -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.CUSKs                             -> Maybe KnownExtension
forall a. Maybe a
Nothing
  Extension
TH.StandaloneKindSignatures          -> Maybe KnownExtension
forall a. Maybe a
Nothing
#endif


  -- NB: when adding a case here, you may also need to update `toExtension`

-----------------------------------------------------------------------------