{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NegativeLiterals #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}

{-| Utilities to manipulate Haskell AST -}
module Proto3.Suite.DotProto.Generate.Syntax where

import Data.Functor ((<&>))
import Data.Maybe (maybeToList)
#if !MIN_VERSION_ghc_lib_parser(9,12,0)
import GHC.Data.Bag (listToBag)
#endif
import GHC.Data.FastString (mkFastString)
import qualified GHC.Hs as GHC
         (HsDecl(..), HsDerivingClause(..), HsModule(..), HsTyVarBndr(..), HsType(..))

import GHC.Types.Basic (Origin(..))
import GHC.Types.Name.Occurrence (NameSpace, dataName, mkOccName, tcName, tvName, varName)
import GHC.Types.Name.Reader (mkRdrQual, mkRdrUnqual, rdrNameSpace)
import GHC.Types.SrcLoc (GenLocated(..), SrcSpan, generatedSrcSpan)

#if MIN_VERSION_ghc_lib_parser(9,10,0)
import GHC.Types.Basic (GenReason(OtherExpansion))
#endif
#if MIN_VERSION_ghc_lib_parser(9,8,0)
import Control.Arrow ((***))
import Data.Bool (bool)
import Data.Ratio ((%))
import Data.Void (Void)
import GHC.Hs hiding (HsBind, HsDecl, HsDerivingClause, HsOuterFamEqnTyVarBndrs,
                      HsOuterSigTyVarBndrs, HsTyVarBndr, HsType)
import qualified GHC.Hs as GHC (HsOuterFamEqnTyVarBndrs, HsOuterSigTyVarBndrs)
import GHC.Types.Basic (DoPmc(..), TopLevelFlag(..))
import GHC.Types.Fixity (LexicalFixity(..))
import GHC.Types.PkgQual (RawPkgQual(..))
import GHC.Types.SourceText
         (IntegralLit(..), FractionalExponentBase(..), FractionalLit(..), SourceText(..))
#elif MIN_VERSION_ghc_lib_parser(9,6,0)
import Control.Arrow ((***))
import Data.Bool (bool)
import Data.Ratio ((%))
import Data.Void (Void)
import GHC.Hs hiding (HsBind, HsDecl, HsDerivingClause, HsOuterFamEqnTyVarBndrs,
                      HsOuterSigTyVarBndrs, HsTyVarBndr, HsType)
import qualified GHC.Hs as GHC (HsOuterFamEqnTyVarBndrs, HsOuterSigTyVarBndrs)
import GHC.Types.Basic (TopLevelFlag(..))
import GHC.Types.Fixity (LexicalFixity(..))
import GHC.Types.PkgQual (RawPkgQual(..))
import GHC.Types.SourceText
         (IntegralLit(..), FractionalExponentBase(..), FractionalLit(..), SourceText(..))
#elif MIN_VERSION_ghc_lib_parser(9,4,0)
import Data.Ratio ((%))
import Data.Void (Void)
import GHC.Hs hiding (HsBind, HsDecl, HsDerivingClause, HsOuterFamEqnTyVarBndrs,
                      HsOuterSigTyVarBndrs, HsTyVarBndr, HsType)
import qualified GHC.Hs as GHC (HsOuterFamEqnTyVarBndrs, HsOuterSigTyVarBndrs)
import GHC.Types.Basic (PromotionFlag(..), TopLevelFlag(..))
import GHC.Types.Fixity (LexicalFixity(..))
import GHC.Types.PkgQual (RawPkgQual(..))
import GHC.Types.SourceText
         (IntegralLit(..), FractionalExponentBase(..), FractionalLit(..), SourceText(..))
import GHC.Types.SrcLoc (LayoutInfo(..))
import GHC.Unit (IsBootInterface(..))
import GHC.Unit.Module (ModuleName, mkModuleName)
#else
import Data.Ratio ((%))
import Data.Void (Void)
import GHC.Hs hiding (HsBind, HsDecl, HsDerivingClause, HsOuterFamEqnTyVarBndrs,
                      HsOuterSigTyVarBndrs, HsTyVarBndr, HsType)
import qualified GHC.Hs as GHC (HsOuterFamEqnTyVarBndrs, HsOuterSigTyVarBndrs)
import GHC.Types.Basic (PromotionFlag(..), TopLevelFlag(..))
import GHC.Types.Fixity (LexicalFixity(..))
import GHC.Types.SourceText
         (IntegralLit(..), FractionalExponentBase(..), FractionalLit(..), SourceText(..))
import GHC.Types.SrcLoc (LayoutInfo(..), noLoc)
import GHC.Unit (IsBootInterface(..))
import GHC.Unit.Module (ModuleName, mkModuleName)
#endif

#if MIN_VERSION_base(4,16,0)
import GHC.Exts (considerAccessible)
#endif

type HsAlt = LMatch GhcPs HsExp
type HsBangType = LBangType GhcPs
type HsBind = LHsBind GhcPs
type HsConDecl = LConDecl GhcPs
type HsDecl = LHsDecl GhcPs
type HsDerivStrategy = LDerivStrategy GhcPs
type HsDerivingClause = LHsDerivingClause GhcPs
type HsExp = LHsExpr GhcPs
type HsExportSpec = LIE GhcPs
type HsGrhs = LGRHS GhcPs HsExp
type HsGuardedAlts = GRHSs GhcPs HsExp
type HsImportDecl = LImportDecl GhcPs
type HsImportSpec = LIE GhcPs
type HsMatch = LMatch GhcPs HsExp
type HsName = LIdP GhcPs
type HsOuterFamEqnTyVarBndrs = GHC.HsOuterFamEqnTyVarBndrs GhcPs
type HsOuterSigTyVarBndrs = GHC.HsOuterSigTyVarBndrs GhcPs
type HsPat = LPat GhcPs
type HsQName = LIdP GhcPs
type HsQOp = LHsExpr GhcPs
type HsSig = LSig GhcPs
type HsTyVarBndrU = LHsTyVarBndr () GhcPs
type HsTyVarBndrV = LHsTyVarBndr
#if MIN_VERSION_ghc_lib_parser(9,8,0)
                                 (HsBndrVis GhcPs)
#else
                                 ()
#endif
                                                   GhcPs
type HsType = LHsType GhcPs
type Module = ModuleName

#if MIN_VERSION_ghc_lib_parser(9,10,0)

pattern VirtualBraces :: Int -> EpLayout
pattern $mVirtualBraces :: forall {r}. EpLayout -> (Int -> r) -> ((# #) -> r) -> r
$bVirtualBraces :: Int -> EpLayout
VirtualBraces indentation = EpVirtualBraces indentation

#endif

class SyntaxDefault a
  where
    synDef :: a

instance SyntaxDefault ()
  where
    synDef :: ()
synDef = ()

instance (SyntaxDefault a, SyntaxDefault b, SyntaxDefault c) => SyntaxDefault (a, b, c)
  where
    synDef :: (a, b, c)
synDef = (a
forall a. SyntaxDefault a => a
synDef, b
forall a. SyntaxDefault a => a
synDef, c
forall a. SyntaxDefault a => a
synDef)

instance SyntaxDefault (Maybe a)
  where
    synDef :: Maybe a
synDef = Maybe a
forall a. Maybe a
Nothing

instance SyntaxDefault [a]
  where
    synDef :: [a]
synDef = []

instance (SyntaxDefault a, SyntaxDefault b) => SyntaxDefault (a, b)
  where
    synDef :: (a, b)
synDef = (a
forall a. SyntaxDefault a => a
synDef, b
forall a. SyntaxDefault a => a
synDef)

instance SyntaxDefault NoExtField
  where
    synDef :: NoExtField
synDef = NoExtField
NoExtField

instance SyntaxDefault SourceText
  where
    synDef :: SourceText
synDef = SourceText
NoSourceText

instance SyntaxDefault SrcSpan
  where
    synDef :: SrcSpan
synDef = SrcSpan
generatedSrcSpan

#if MIN_VERSION_ghc_lib_parser(9,10,0)

instance SyntaxDefault AnnParen
  where
    synDef :: AnnParen
synDef = AnnParen
forall a. NoAnn a => a
noAnn

instance SyntaxDefault AnnPragma
  where
    synDef :: AnnPragma
synDef = AnnPragma
forall a. NoAnn a => a
noAnn

instance SyntaxDefault AnnSig
  where
    synDef :: AnnSig
synDef = AnnSig
forall a. NoAnn a => a
noAnn

instance SyntaxDefault AnnsIf
  where
    synDef :: AnnsIf
synDef = AnnsIf
forall a. NoAnn a => a
noAnn

instance SyntaxDefault (AnnSortKey tag)
  where
    synDef :: AnnSortKey tag
synDef = AnnSortKey tag
forall tag. AnnSortKey tag
NoAnnSortKey

instance NoAnn a => SyntaxDefault (EpAnn a)
  where
    synDef :: EpAnn a
synDef = EpAnn a
forall a. NoAnn a => a
noAnn

instance SyntaxDefault EpAnnHsCase
  where
    synDef :: EpAnnHsCase
synDef = EpAnnHsCase
forall a. NoAnn a => a
noAnn

instance SyntaxDefault (EpToken token)
  where
    synDef :: EpToken token
synDef = EpToken token
forall (token :: Symbol). EpToken token
NoEpTok

instance SyntaxDefault (EpUniToken token utoken)
  where
    synDef :: EpUniToken token utoken
synDef = EpUniToken token utoken
forall (token :: Symbol) (utoken :: Symbol).
EpUniToken token utoken
NoEpUniTok

instance SyntaxDefault (HsBndrVis GhcPs)
  where
    synDef :: HsBndrVis GhcPs
synDef = XBndrRequired GhcPs -> HsBndrVis GhcPs
forall pass. XBndrRequired pass -> HsBndrVis pass
HsBndrRequired NoExtField
XBndrRequired GhcPs
forall a. SyntaxDefault a => a
synDef

#endif

#if MIN_VERSION_ghc_lib_parser(9,8,0) && !MIN_VERSION_ghc_lib_parser(9,10,0)

instance SyntaxDefault (HsBndrVis GhcPs)
  where
    synDef = HsBndrRequired

#endif

#if MIN_VERSION_ghc_lib_parser(9,4,0)

instance SyntaxDefault a => SyntaxDefault (GenLocated TokenLocation a)
  where
    synDef :: GenLocated TokenLocation a
synDef = TokenLocation -> a -> GenLocated TokenLocation a
forall l e. l -> e -> GenLocated l e
L TokenLocation
NoTokenLoc a
forall a. SyntaxDefault a => a
synDef

#endif

#if MIN_VERSION_ghc_lib_parser(9,4,0) && !MIN_VERSION_ghc_lib_parser(9,10,0)

instance SyntaxDefault (SrcAnn a)
  where
    synDef = noSrcSpanA

instance SyntaxDefault (HsToken tok)
  where
    synDef = HsTok

instance SyntaxDefault (HsUniToken tok utok)
  where
    synDef = HsNormalTok

#else

instance SyntaxDefault IsUnicodeSyntax
  where
    synDef :: IsUnicodeSyntax
synDef = IsUnicodeSyntax
NormalSyntax

#endif

pattern PfxCon :: [arg] -> HsConDetails Void arg r
pattern $mPfxCon :: forall {r} {arg} {r}.
HsConDetails Void arg r -> ([arg] -> r) -> ((# #) -> r) -> r
$bPfxCon :: forall arg r. [arg] -> HsConDetails Void arg r
PfxCon args = PrefixCon [] args

#if !MIN_VERSION_ghc_lib_parser(9,10,0)

instance SyntaxDefault e => SyntaxDefault (GenLocated (SrcAnn a) e)
  where
    synDef = noLocA synDef

instance SyntaxDefault (EpAnn a)
  where
    synDef = EpAnnNotUsed

instance SyntaxDefault EpAnnComments
  where
    synDef = emptyComments

instance SyntaxDefault AnnSortKey
  where
    synDef = NoAnnSortKey

#endif

#if !MIN_VERSION_ghc_lib_parser(9,4,0)

dataConCantHappen :: NoExtCon -> a
dataConCantHappen = noExtCon

#endif

haskellName, jsonpbName, grpcName, lrName, protobufName,
  protobufASTName, protobufFormName, proxyName ::
  NameSpace -> String -> HsQName
haskellName :: NameSpace -> String -> HsQName
haskellName      = ModuleName -> NameSpace -> String -> HsQName
qual_ ModuleName
haskellNS
jsonpbName :: NameSpace -> String -> HsQName
jsonpbName       = ModuleName -> NameSpace -> String -> HsQName
qual_ (String -> ModuleName
mkModuleName String
"HsJSONPB")
grpcName :: NameSpace -> String -> HsQName
grpcName         = ModuleName -> NameSpace -> String -> HsQName
qual_ (String -> ModuleName
mkModuleName String
"HsGRPC")
lrName :: NameSpace -> String -> HsQName
lrName           = ModuleName -> NameSpace -> String -> HsQName
qual_ (String -> ModuleName
mkModuleName String
"LR")
protobufName :: NameSpace -> String -> HsQName
protobufName     = ModuleName -> NameSpace -> String -> HsQName
qual_ (String -> ModuleName
mkModuleName String
"HsProtobuf")
protobufASTName :: NameSpace -> String -> HsQName
protobufASTName  = ModuleName -> NameSpace -> String -> HsQName
qual_ (String -> ModuleName
mkModuleName String
"HsProtobufAST")
protobufFormName :: NameSpace -> String -> HsQName
protobufFormName = ModuleName -> NameSpace -> String -> HsQName
qual_ ModuleName
protobufFormNS
proxyName :: NameSpace -> String -> HsQName
proxyName        = ModuleName -> NameSpace -> String -> HsQName
qual_ (String -> ModuleName
mkModuleName String
"Proxy")

haskellNS :: ModuleName
haskellNS :: ModuleName
haskellNS = String -> ModuleName
mkModuleName String
"Hs"

protobufFormNS :: ModuleName
protobufFormNS :: ModuleName
protobufFormNS = String -> ModuleName
mkModuleName String
"HsProtobufForm"

protobufFormType :: NameSpace -> String -> HsType
protobufFormType :: NameSpace -> String -> HsType
protobufFormType NameSpace
ns = HsQName -> HsType
GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (HsType GhcPs)
typeNamed_ (GenLocated SrcSpanAnnN RdrName
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (String -> GenLocated SrcSpanAnnN RdrName)
-> String
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpace -> String -> HsQName
protobufFormName NameSpace
ns

formProtoTypeT :: HsType
formProtoTypeT :: HsType
formProtoTypeT = NameSpace -> String -> HsType
protobufFormType NameSpace
tcName String
"ProtoType"

formNamesOf, formNumberOf, formOneOfOf, formCardinalityOf, formProtoTypeOf :: HsQName
formNamesOf :: HsQName
formNamesOf = NameSpace -> String -> HsQName
protobufFormName NameSpace
tcName String
"NamesOf"
formNumberOf :: HsQName
formNumberOf = NameSpace -> String -> HsQName
protobufFormName NameSpace
tcName String
"NumberOf"
formOneOfOf :: HsQName
formOneOfOf = NameSpace -> String -> HsQName
protobufFormName NameSpace
tcName String
"OneOfOf"
formCardinalityOf :: HsQName
formCardinalityOf = NameSpace -> String -> HsQName
protobufFormName NameSpace
tcName String
"CardinalityOf"
formProtoTypeOf :: HsQName
formProtoTypeOf = NameSpace -> String -> HsQName
protobufFormName NameSpace
tcName String
"ProtoTypeOf"

formFieldNotFound, formFieldOrOneOfNotFound :: HsType
formFieldNotFound :: HsType
formFieldNotFound = NameSpace -> String -> HsType
protobufFormType NameSpace
tcName String
"FieldNotFound"
formFieldOrOneOfNotFound :: HsType
formFieldOrOneOfNotFound = NameSpace -> String -> HsType
protobufFormType NameSpace
tcName String
"FieldOrOneOfNotFound"

formUnpackedT, formPackedT :: HsType
formUnpackedT :: HsType
formUnpackedT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Unpacked"
formPackedT :: HsType
formPackedT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Packed"

formCardinalityT, formImplicitT, formOptionalT, formRepeatedT :: HsType
formCardinalityT :: HsType
formCardinalityT = NameSpace -> String -> HsType
protobufFormType NameSpace
tcName String
"Cardinality"
formImplicitT :: HsType
formImplicitT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Implicit"
formOptionalT :: HsType
formOptionalT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Optional"
formRepeatedT :: HsType
formRepeatedT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Repeated"

formInt32T, formInt64T, formSInt32T, formSInt64T, formUInt32T, formUInt64T,
  formFixed32T, formFixed64T, formSFixed32T, formSFixed64T,
  formStringT, formBytesT, formBoolT, formFloatT, formDoubleT,
  formEnumerationT, formMessageT, formMapT :: HsType
formInt32T :: HsType
formInt32T = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Int32"
formInt64T :: HsType
formInt64T = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Int64"
formSInt32T :: HsType
formSInt32T = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"SInt32"
formSInt64T :: HsType
formSInt64T = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"SInt64"
formUInt32T :: HsType
formUInt32T = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"UInt32"
formUInt64T :: HsType
formUInt64T = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"UInt64"
formFixed32T :: HsType
formFixed32T = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Fixed32"
formFixed64T :: HsType
formFixed64T = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Fixed64"
formSFixed32T :: HsType
formSFixed32T = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"SFixed32"
formSFixed64T :: HsType
formSFixed64T = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"SFixed64"
formStringT :: HsType
formStringT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"String"
formBytesT :: HsType
formBytesT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Bytes"
formBoolT :: HsType
formBoolT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Bool"
formFloatT :: HsType
formFloatT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Float"
formDoubleT :: HsType
formDoubleT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Double"
formEnumerationT :: HsType
formEnumerationT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Enumeration"
formMessageT :: HsType
formMessageT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Message"
formMapT :: HsType
formMapT = NameSpace -> String -> HsType
protobufFormType NameSpace
dataName String
"Map"

formWrapperT :: HsType
formWrapperT :: HsType
formWrapperT = NameSpace -> String -> HsType
protobufFormType NameSpace
tcName String
"Wrapper"

--------------------------------------------------------------------------------
--
-- * Wrappers around ghc constructors
--

app :: HsExp -> HsExp -> HsExp
app :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
app LHsExpr GhcPs
f LHsExpr GhcPs
x = LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
forall (id :: Pass).
LHsExpr (GhcPass id)
-> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkHsApp LHsExpr GhcPs
f (LHsExpr GhcPs -> LHsExpr GhcPs
paren LHsExpr GhcPs
x)

apply :: HsExp -> [HsExp] -> HsExp
apply :: LHsExpr GhcPs -> [LHsExpr GhcPs] -> LHsExpr GhcPs
apply LHsExpr GhcPs
f [LHsExpr GhcPs]
xs = LHsExpr GhcPs -> [LHsExpr GhcPs] -> LHsExpr GhcPs
forall (id :: Pass).
LHsExpr (GhcPass id)
-> [LHsExpr (GhcPass id)] -> LHsExpr (GhcPass id)
mkHsApps LHsExpr GhcPs
f ((LocatedA (HsExpr GhcPs) -> LocatedA (HsExpr GhcPs))
-> [LocatedA (HsExpr GhcPs)] -> [LocatedA (HsExpr GhcPs)]
forall a b. (a -> b) -> [a] -> [b]
map LHsExpr GhcPs -> LHsExpr GhcPs
LocatedA (HsExpr GhcPs) -> LocatedA (HsExpr GhcPs)
paren [LHsExpr GhcPs]
[LocatedA (HsExpr GhcPs)]
xs)

appAt :: HsExp -> HsType -> HsExp
appAt :: LHsExpr GhcPs -> HsType -> LHsExpr GhcPs
appAt LHsExpr GhcPs
f HsType
t = HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (XAppTypeE GhcPs
-> LHsExpr GhcPs -> LHsWcType (NoGhcTc GhcPs) -> HsExpr GhcPs
forall p.
XAppTypeE p -> LHsExpr p -> LHsWcType (NoGhcTc p) -> HsExpr p
HsAppType XAppTypeE GhcPs
EpToken "@"
forall a. SyntaxDefault a => a
synDef LHsExpr GhcPs
f
#if MIN_VERSION_ghc_lib_parser(9,6,0) && !MIN_VERSION_ghc_lib_parser(9,10,0)
                                       synDef
#endif
                                              (XHsWC GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
forall pass thing.
XHsWC pass thing -> thing -> HsWildCardBndrs pass thing
HsWC XHsWC GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
NoExtField
NoExtField (HsType -> HsType
parenTy HsType
t)))

applyAt :: HsExp -> [HsType] -> HsExp
applyAt :: LHsExpr GhcPs -> [HsType] -> LHsExpr GhcPs
applyAt LHsExpr GhcPs
f = LHsExpr GhcPs -> LHsExpr GhcPs
LocatedA (HsExpr GhcPs) -> LocatedA (HsExpr GhcPs)
paren (LocatedA (HsExpr GhcPs) -> LocatedA (HsExpr GhcPs))
-> ([GenLocated SrcSpanAnnA (HsType GhcPs)]
    -> LocatedA (HsExpr GhcPs))
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> LocatedA (HsExpr GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LocatedA (HsExpr GhcPs)
 -> GenLocated SrcSpanAnnA (HsType GhcPs)
 -> LocatedA (HsExpr GhcPs))
-> LocatedA (HsExpr GhcPs)
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> LocatedA (HsExpr GhcPs)
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl LHsExpr GhcPs -> HsType -> LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs) -> LocatedA (HsExpr GhcPs)
appAt LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
f

opApp :: HsExp -> HsQOp -> HsExp -> HsExp
opApp :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
opApp LHsExpr GhcPs
x LHsExpr GhcPs
op LHsExpr GhcPs
y = HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsExpr GhcPs -> LocatedA (HsExpr GhcPs))
-> HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall a b. (a -> b) -> a -> b
$ XOpApp GhcPs
-> LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> HsExpr GhcPs
forall p.
XOpApp p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
OpApp [AddEpAnn]
XOpApp GhcPs
forall a. SyntaxDefault a => a
synDef LHsExpr GhcPs
x LHsExpr GhcPs
op LHsExpr GhcPs
y

maybeModify :: HsExp -> Maybe HsExp -> HsExp
maybeModify :: LHsExpr GhcPs -> Maybe (LHsExpr GhcPs) -> LHsExpr GhcPs
maybeModify LHsExpr GhcPs
x Maybe (LHsExpr GhcPs)
Nothing = LHsExpr GhcPs
x
maybeModify LHsExpr GhcPs
x (Just LHsExpr GhcPs
f) = LHsExpr GhcPs -> LHsExpr GhcPs
paren (LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
app LHsExpr GhcPs
f LHsExpr GhcPs
x)

paren :: HsExp -> HsExp
paren :: LHsExpr GhcPs -> LHsExpr GhcPs
paren = LHsExpr GhcPs -> LHsExpr GhcPs
forall (id :: Pass).
IsPass id =>
LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkLHsPar

parenPat :: HsPat -> HsPat
parenPat :: HsPat -> HsPat
parenPat = HsPat -> HsPat
forall (p :: Pass).
IsPass p =>
LPat (GhcPass p) -> LPat (GhcPass p)
mkParPat

parenTy :: HsType -> HsType
parenTy :: HsType -> HsType
parenTy t :: HsType
t@(L SrcSpanAnnA
_ (GHC.HsParTy {})) = HsType
t
parenTy t :: HsType
t@(L SrcSpanAnnA
_ (GHC.HsTyVar {})) = HsType
t
parenTy t :: HsType
t@(L SrcSpanAnnA
_ (GHC.HsTupleTy {})) = HsType
t
parenTy HsType
t = HsType -> HsType
forall (p :: Pass). LHsType (GhcPass p) -> LHsType (GhcPass p)
nlHsParTy HsType
t

applicativeApply :: HsExp -> [HsExp] -> HsExp
applicativeApply :: LHsExpr GhcPs -> [LHsExpr GhcPs] -> LHsExpr GhcPs
applicativeApply LHsExpr GhcPs
f = (LocatedA (HsExpr GhcPs)
 -> LocatedA (HsExpr GhcPs) -> LocatedA (HsExpr GhcPs))
-> LocatedA (HsExpr GhcPs)
-> [LocatedA (HsExpr GhcPs)]
-> LocatedA (HsExpr GhcPs)
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl LocatedA (HsExpr GhcPs)
-> LocatedA (HsExpr GhcPs) -> LocatedA (HsExpr GhcPs)
forall {e}.
HasAnnotation e =>
LocatedA (HsExpr GhcPs)
-> LocatedA (HsExpr GhcPs) -> GenLocated e (HsExpr GhcPs)
snoc LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
nil
  where
    nil :: LHsExpr GhcPs
nil = LHsExpr GhcPs -> [LHsExpr GhcPs] -> LHsExpr GhcPs
apply LHsExpr GhcPs
pureE [LHsExpr GhcPs
f]
    snoc :: LHsExpr GhcPs
-> LocatedA (HsExpr GhcPs) -> GenLocated e (HsExpr GhcPs)
snoc LHsExpr GhcPs
g LocatedA (HsExpr GhcPs)
x = HsExpr GhcPs -> GenLocated e (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (XOpApp GhcPs
-> LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> HsExpr GhcPs
forall p.
XOpApp p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
OpApp XOpApp GhcPs
forall a. SyntaxDefault a => a
synDef LHsExpr GhcPs
g LHsExpr GhcPs
apOp LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
x)

tyApp :: HsType -> HsType -> HsType
tyApp :: HsType -> HsType -> HsType
tyApp HsType
f = HsType -> HsType
GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
parenTy (GenLocated SrcSpanAnnA (HsType GhcPs)
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (GenLocated SrcSpanAnnA (HsType GhcPs)
    -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsType -> HsType -> HsType
forall (p :: Pass).
LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p)
mkHsAppTy (HsType -> HsType
parenTy HsType
f) (GenLocated SrcSpanAnnA (HsType GhcPs)
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (GenLocated SrcSpanAnnA (HsType GhcPs)
    -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsType -> HsType
GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
parenTy

tyApply :: HsType -> [HsType] -> HsType
tyApply :: HsType -> [HsType] -> HsType
tyApply = (GenLocated SrcSpanAnnA (HsType GhcPs)
 -> GenLocated SrcSpanAnnA (HsType GhcPs)
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl HsType -> HsType -> HsType
GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
tyApp

-- | Whenever @f@ is not itself a type application,
-- @'splitTyApp' ('tyApply' f as) = (f, as)@.
splitTyApp :: HsType -> (HsType, [HsType])
splitTyApp :: HsType -> (HsType, [HsType])
splitTyApp (L SrcSpanAnnA
_ (GHC.HsParTy XParTy GhcPs
_ HsType
x)) = HsType -> (HsType, [HsType])
splitTyApp HsType
x
splitTyApp (L SrcSpanAnnA
_ (GHC.HsAppTy XAppTy GhcPs
NoExtField
NoExtField HsType
x HsType
y)) = ([GenLocated SrcSpanAnnA (HsType GhcPs)]
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
forall a. [a] -> [a] -> [a]
++ [HsType
GenLocated SrcSpanAnnA (HsType GhcPs)
y]) ([GenLocated SrcSpanAnnA (HsType GhcPs)]
 -> [GenLocated SrcSpanAnnA (HsType GhcPs)])
-> (GenLocated SrcSpanAnnA (HsType GhcPs),
    [GenLocated SrcSpanAnnA (HsType GhcPs)])
-> (GenLocated SrcSpanAnnA (HsType GhcPs),
    [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HsType -> (HsType, [HsType])
splitTyApp HsType
x
splitTyApp HsType
x = (HsType
x, [])

tyConApp :: HsName -> HsType -> HsType
tyConApp :: HsQName -> HsType -> HsType
tyConApp = HsType -> HsType -> HsType
GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
tyApp (GenLocated SrcSpanAnnA (HsType GhcPs)
 -> GenLocated SrcSpanAnnA (HsType GhcPs)
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (GenLocated SrcSpanAnnN RdrName
    -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsQName -> HsType
GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (HsType GhcPs)
typeNamed_

tyConApply :: HsName -> [HsType] -> HsType
tyConApply :: HsQName -> [HsType] -> HsType
tyConApply = HsType -> [HsType] -> HsType
GenLocated SrcSpanAnnA (HsType GhcPs)
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> GenLocated SrcSpanAnnA (HsType GhcPs)
tyApply (GenLocated SrcSpanAnnA (HsType GhcPs)
 -> [GenLocated SrcSpanAnnA (HsType GhcPs)]
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (GenLocated SrcSpanAnnN RdrName
    -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated SrcSpanAnnN RdrName
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsQName -> HsType
GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (HsType GhcPs)
typeNamed_

-- | @'splitTyConApp' ('tyApply' (L _ (GHC.HsTyVar _ NotPromoted tc)) as) = Just (tc, as)@.
splitTyConApp :: HsType -> Maybe (HsName, [HsType])
splitTyConApp :: HsType -> Maybe (HsQName, [HsType])
splitTyConApp HsType
x = case HsType -> (HsType, [HsType])
splitTyApp HsType
x of
  (L SrcSpanAnnA
_ (GHC.HsTyVar XTyVar GhcPs
_ PromotionFlag
NotPromoted HsQName
tc), [HsType]
as) -> (GenLocated SrcSpanAnnN RdrName,
 [GenLocated SrcSpanAnnA (HsType GhcPs)])
-> Maybe
     (GenLocated SrcSpanAnnN RdrName,
      [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall a. a -> Maybe a
Just (HsQName
GenLocated SrcSpanAnnN RdrName
tc, [HsType]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
as)
  (HsType, [HsType])
_ -> Maybe (HsQName, [HsType])
Maybe
  (GenLocated SrcSpanAnnN RdrName,
   [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall a. Maybe a
Nothing

funTy :: HsType -> HsType -> HsType
funTy :: HsType -> HsType -> HsType
funTy HsType
a HsType
b = HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (XFunTy GhcPs -> HsArrow GhcPs -> HsType -> HsType -> HsType GhcPs
forall pass.
XFunTy pass
-> HsArrow pass -> LHsType pass -> LHsType pass -> HsType pass
GHC.HsFunTy XFunTy GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef HsArrow GhcPs
unrestrictedArrow_ HsType
a HsType
b)

unrestrictedArrow_ :: HsArrow GhcPs
unrestrictedArrow_ :: HsArrow GhcPs
unrestrictedArrow_ = XUnrestrictedArrow GhcPs -> HsArrow GhcPs
forall pass. XUnrestrictedArrow pass -> HsArrow pass
HsUnrestrictedArrow EpUniToken "->" "\8594"
XUnrestrictedArrow GhcPs
forall a. SyntaxDefault a => a
synDef

unbangedTy_ :: HsType -> HsBangType
#if MIN_VERSION_ghc_lib_parser(9,12,0)
unbangedTy_ = noLocA . GHC.HsBangTy noAnn (HsBang NoSrcUnpack NoSrcStrict) . parenTy
#else
unbangedTy_ :: HsType -> HsType
unbangedTy_ = HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (GenLocated SrcSpanAnnA (HsType GhcPs) -> HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XBangTy GhcPs -> HsSrcBang -> HsType -> HsType GhcPs
forall pass.
XBangTy pass -> HsSrcBang -> LHsType pass -> HsType pass
GHC.HsBangTy [AddEpAnn]
XBangTy GhcPs
forall a. SyntaxDefault a => a
synDef (SourceText -> SrcUnpackedness -> SrcStrictness -> HsSrcBang
HsSrcBang SourceText
forall a. SyntaxDefault a => a
synDef SrcUnpackedness
NoSrcUnpack SrcStrictness
NoSrcStrict) (GenLocated SrcSpanAnnA (HsType GhcPs) -> HsType GhcPs)
-> (GenLocated SrcSpanAnnA (HsType GhcPs)
    -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> HsType GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsType -> HsType
GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
parenTy
#endif

#if MIN_VERSION_ghc_lib_parser(9,6,0)
-- https://hackage.haskell.org/package/ghc-lib-parser-9.6.2.20231121/docs/GHC-Hs.html#t:HsModule
module_ :: ModuleName -> Maybe [HsExportSpec] -> [HsImportDecl] -> [HsDecl] -> GHC.HsModule GhcPs
module_ :: ModuleName
-> Maybe [HsExportSpec]
-> [HsImportDecl]
-> [HsDecl]
-> HsModule GhcPs
module_ ModuleName
moduleName Maybe [HsExportSpec]
maybeExports [HsImportDecl]
imports [HsDecl]
decls =
  GHC.HsModule
  { hsmodExt :: XCModule GhcPs
hsmodExt = XModulePs
    { hsmodAnn :: EpAnn AnnsModule
hsmodAnn = EpAnn AnnsModule
forall a. SyntaxDefault a => a
synDef
    , hsmodLayout :: EpLayout
hsmodLayout = Int -> EpLayout
VirtualBraces Int
2
    , hsmodDeprecMessage :: Maybe (LWarningTxt GhcPs)
hsmodDeprecMessage = Maybe (LWarningTxt GhcPs)
Maybe (GenLocated SrcSpanAnnP (WarningTxt GhcPs))
forall a. Maybe a
Nothing
    , hsmodHaddockModHeader :: Maybe (LHsDoc GhcPs)
hsmodHaddockModHeader = Maybe (LHsDoc GhcPs)
forall a. Maybe a
Nothing
    }
  , hsmodName :: Maybe (XRec GhcPs ModuleName)
hsmodName = XRec GhcPs ModuleName -> Maybe (XRec GhcPs ModuleName)
forall a. a -> Maybe a
Just (XRec GhcPs ModuleName -> Maybe (XRec GhcPs ModuleName))
-> XRec GhcPs ModuleName -> Maybe (XRec GhcPs ModuleName)
forall a b. (a -> b) -> a -> b
$ ModuleName -> GenLocated SrcSpanAnnA ModuleName
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA ModuleName
moduleName
  , hsmodExports :: Maybe (XRec GhcPs [HsExportSpec])
hsmodExports = [GenLocated SrcSpanAnnA (IE GhcPs)]
-> GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA ([GenLocated SrcSpanAnnA (IE GhcPs)]
 -> GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
-> Maybe [GenLocated SrcSpanAnnA (IE GhcPs)]
-> Maybe
     (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe [HsExportSpec]
Maybe [GenLocated SrcSpanAnnA (IE GhcPs)]
maybeExports
  , hsmodImports :: [HsImportDecl]
hsmodImports = [HsImportDecl]
imports
  , hsmodDecls :: [HsDecl]
hsmodDecls = [HsDecl]
decls
  }
#else
-- https://hackage.haskell.org/package/ghc-lib-parser-9.2.2.20220307/docs/GHC-Hs.html#t:HsModule
module_ :: ModuleName -> Maybe [HsExportSpec] -> [HsImportDecl] -> [HsDecl] -> GHC.HsModule
module_ moduleName maybeExports imports decls =
  GHC.HsModule
  { hsmodAnn = synDef
  , hsmodLayout = VirtualBraces 2
  , hsmodName = Just $ noLocA moduleName
  , hsmodExports = noLocA <$> maybeExports
  , hsmodImports = imports
  , hsmodDecls = decls
  , hsmodDeprecMessage = Nothing
  , hsmodHaddockModHeader = Nothing
  }
#endif

importDecl_ ::
  ModuleName ->
  Bool ->
  Maybe ModuleName ->
  Maybe (Bool, [HsImportSpec]) ->
  HsImportDecl
importDecl_ :: ModuleName
-> Bool
-> Maybe ModuleName
-> Maybe (Bool, [HsExportSpec])
-> HsImportDecl
importDecl_ ModuleName
moduleName Bool
qualified Maybe ModuleName
maybeAs Maybe (Bool, [HsExportSpec])
details = ImportDecl GhcPs -> GenLocated SrcSpanAnnA (ImportDecl GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA ImportDecl
  {
#if MIN_VERSION_ghc_lib_parser(9,6,0)
    ideclExt :: XCImportDecl GhcPs
ideclExt = XImportDeclPass
      { ideclAnn :: EpAnn EpAnnImportDecl
ideclAnn = EpAnn EpAnnImportDecl
forall a. SyntaxDefault a => a
synDef
      , ideclSourceText :: SourceText
ideclSourceText = SourceText
forall a. SyntaxDefault a => a
synDef
      , ideclImplicit :: Bool
ideclImplicit = Bool
False
      }
#else
    ideclExt = synDef
  , ideclSourceSrc = NoSourceText
#endif
  , ideclName :: XRec GhcPs ModuleName
ideclName = ModuleName -> GenLocated SrcSpanAnnA ModuleName
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA ModuleName
moduleName
  , ideclPkgQual :: ImportDeclPkgQual GhcPs
ideclPkgQual =
#if MIN_VERSION_ghc_lib_parser(9,4,0)
      ImportDeclPkgQual GhcPs
RawPkgQual
NoRawPkgQual
#else
      Nothing
#endif
  , ideclSource :: IsBootInterface
ideclSource = IsBootInterface
NotBoot
  , ideclSafe :: Bool
ideclSafe = Bool
False
  , ideclQualified :: ImportDeclQualifiedStyle
ideclQualified = if Bool
qualified then ImportDeclQualifiedStyle
QualifiedPre else ImportDeclQualifiedStyle
NotQualified
#if !MIN_VERSION_ghc_lib_parser(9,6,0)
  , ideclImplicit = False
#endif
  , ideclAs :: Maybe (XRec GhcPs ModuleName)
ideclAs = ModuleName -> GenLocated SrcSpanAnnA ModuleName
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (ModuleName -> GenLocated SrcSpanAnnA ModuleName)
-> Maybe ModuleName -> Maybe (GenLocated SrcSpanAnnA ModuleName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe ModuleName
maybeAs
#if MIN_VERSION_ghc_lib_parser(9,6,0)
  , ideclImportList :: Maybe (ImportListInterpretation, XRec GhcPs [HsExportSpec])
ideclImportList = (ImportListInterpretation
-> ImportListInterpretation -> Bool -> ImportListInterpretation
forall a. a -> a -> Bool -> a
bool ImportListInterpretation
Exactly ImportListInterpretation
EverythingBut (Bool -> ImportListInterpretation)
-> ([GenLocated SrcSpanAnnA (IE GhcPs)]
    -> GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
-> (Bool, [GenLocated SrcSpanAnnA (IE GhcPs)])
-> (ImportListInterpretation,
    GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
forall b c b' c'. (b -> c) -> (b' -> c') -> (b, b') -> (c, c')
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** [GenLocated SrcSpanAnnA (IE GhcPs)]
-> GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA) ((Bool, [GenLocated SrcSpanAnnA (IE GhcPs)])
 -> (ImportListInterpretation,
     GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
-> Maybe (Bool, [GenLocated SrcSpanAnnA (IE GhcPs)])
-> Maybe
     (ImportListInterpretation,
      GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Bool, [HsExportSpec])
Maybe (Bool, [GenLocated SrcSpanAnnA (IE GhcPs)])
details
#else
  , ideclHiding = fmap noLocA <$> details
#endif
  }

ieName_ :: HsName -> HsImportSpec
ieName_ :: HsQName -> HsExportSpec
ieName_ =
  IE GhcPs -> GenLocated SrcSpanAnnA (IE GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (IE GhcPs -> GenLocated SrcSpanAnnA (IE GhcPs))
-> (GenLocated SrcSpanAnnN RdrName -> IE GhcPs)
-> GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (IE GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
#if MIN_VERSION_ghc_lib_parser(9,10,0)
  (GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
 -> Maybe (LHsDoc GhcPs) -> IE GhcPs)
-> Maybe (LHsDoc GhcPs)
-> GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
-> IE GhcPs
forall a b c. (a -> b -> c) -> b -> a -> c
flip (XIEVar GhcPs
-> LIEWrappedName GhcPs -> Maybe (LHsDoc GhcPs) -> IE GhcPs
forall pass.
XIEVar pass
-> LIEWrappedName pass -> Maybe (ExportDoc pass) -> IE pass
IEVar Maybe (GenLocated SrcSpanAnnP (WarningTxt GhcPs))
XIEVar GhcPs
forall a. SyntaxDefault a => a
synDef) Maybe (LHsDoc GhcPs)
forall a. Maybe a
Nothing (GenLocated SrcSpanAnnA (IEWrappedName GhcPs) -> IE GhcPs)
-> (GenLocated SrcSpanAnnN RdrName
    -> GenLocated SrcSpanAnnA (IEWrappedName GhcPs))
-> GenLocated SrcSpanAnnN RdrName
-> IE GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
#else
  IEVar synDef .
#endif
  IEWrappedName GhcPs -> GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (IEWrappedName GhcPs
 -> GenLocated SrcSpanAnnA (IEWrappedName GhcPs))
-> (GenLocated SrcSpanAnnN RdrName -> IEWrappedName GhcPs)
-> GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  XIEName GhcPs -> HsQName -> IEWrappedName GhcPs
forall p. XIEName p -> LIdP p -> IEWrappedName p
IEName
#if MIN_VERSION_ghc_lib_parser(9,6,0)
         XIEName GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef
#endif

ieNameAll_ :: HsName -> HsImportSpec
ieNameAll_ :: HsQName -> HsExportSpec
ieNameAll_ =
  IE GhcPs -> GenLocated SrcSpanAnnA (IE GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (IE GhcPs -> GenLocated SrcSpanAnnA (IE GhcPs))
-> (GenLocated SrcSpanAnnN RdrName -> IE GhcPs)
-> GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (IE GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
#if MIN_VERSION_ghc_lib_parser(9,10,0)
  (GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
 -> Maybe (LHsDoc GhcPs) -> IE GhcPs)
-> Maybe (LHsDoc GhcPs)
-> GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
-> IE GhcPs
forall a b c. (a -> b -> c) -> b -> a -> c
flip (XIEThingAll GhcPs
-> LIEWrappedName GhcPs -> Maybe (LHsDoc GhcPs) -> IE GhcPs
forall pass.
XIEThingAll pass
-> LIEWrappedName pass -> Maybe (ExportDoc pass) -> IE pass
IEThingAll (Maybe (GenLocated SrcSpanAnnP (WarningTxt GhcPs)), [AddEpAnn])
XIEThingAll GhcPs
forall a. SyntaxDefault a => a
synDef) Maybe (LHsDoc GhcPs)
forall a. Maybe a
Nothing (GenLocated SrcSpanAnnA (IEWrappedName GhcPs) -> IE GhcPs)
-> (GenLocated SrcSpanAnnN RdrName
    -> GenLocated SrcSpanAnnA (IEWrappedName GhcPs))
-> GenLocated SrcSpanAnnN RdrName
-> IE GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
#else
  (IEThingAll synDef) .
#endif
  IEWrappedName GhcPs -> GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (IEWrappedName GhcPs
 -> GenLocated SrcSpanAnnA (IEWrappedName GhcPs))
-> (GenLocated SrcSpanAnnN RdrName -> IEWrappedName GhcPs)
-> GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  XIEName GhcPs -> HsQName -> IEWrappedName GhcPs
forall p. XIEName p -> LIdP p -> IEWrappedName p
IEName
#if MIN_VERSION_ghc_lib_parser(9,6,0)
         XIEName GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef
#endif

dataDecl_ :: String -> [HsTyVarBndrV] -> [HsConDecl] -> [HsQName] -> HsDecl
dataDecl_ :: String -> [HsTyVarBndrV] -> [HsConDecl] -> [HsQName] -> HsDecl
dataDecl_ String
messageName [HsTyVarBndrV]
bndrs [HsConDecl]
constructors [HsQName]
derivedInstances = HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs))
-> HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall a b. (a -> b) -> a -> b
$ XTyClD GhcPs -> TyClDecl GhcPs -> HsDecl GhcPs
forall p. XTyClD p -> TyClDecl p -> HsDecl p
GHC.TyClD XTyClD GhcPs
NoExtField
NoExtField DataDecl
    { tcdDExt :: XDataDecl GhcPs
tcdDExt = [AddEpAnn]
XDataDecl GhcPs
forall a. SyntaxDefault a => a
synDef
    , tcdLName :: HsQName
tcdLName = NameSpace -> String -> HsQName
unqual_ NameSpace
tcName String
messageName
    , tcdTyVars :: LHsQTyVars GhcPs
tcdTyVars = XHsQTvs GhcPs -> [HsTyVarBndrV] -> LHsQTyVars GhcPs
forall pass.
XHsQTvs pass
-> [LHsTyVarBndr (HsBndrVis pass) pass] -> LHsQTyVars pass
HsQTvs XHsQTvs GhcPs
NoExtField
NoExtField [HsTyVarBndrV]
bndrs
    , tcdFixity :: LexicalFixity
tcdFixity = LexicalFixity
Prefix
    , tcdDataDefn :: HsDataDefn GhcPs
tcdDataDefn = HsDataDefn
#if MIN_VERSION_ghc_lib_parser(9,12,0)
        { dd_ext = noAnn
#else
        { dd_ext :: XCHsDataDefn GhcPs
dd_ext = XCHsDataDefn GhcPs
NoExtField
NoExtField
#endif
#if !MIN_VERSION_ghc_lib_parser(9,6,0)
        , dd_ND = maybe DataType (const NewType) newtypeCtor
#endif
        , dd_ctxt :: Maybe (LHsContext GhcPs)
dd_ctxt = Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall a. SyntaxDefault a => a
synDef
        , dd_cType :: Maybe (XRec GhcPs CType)
dd_cType = Maybe (XRec GhcPs CType)
Maybe (GenLocated SrcSpanAnnP CType)
forall a. Maybe a
Nothing
        , dd_kindSig :: Maybe HsType
dd_kindSig = Maybe HsType
Maybe (GenLocated SrcSpanAnnA (HsType GhcPs))
forall a. Maybe a
Nothing
        , dd_cons :: DataDefnCons HsConDecl
dd_cons =
#if MIN_VERSION_ghc_lib_parser(9,6,0)
            DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
-> (GenLocated SrcSpanAnnA (ConDecl GhcPs)
    -> DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs)))
-> Maybe (GenLocated SrcSpanAnnA (ConDecl GhcPs))
-> DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Bool
-> [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
-> DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall a. Bool -> [a] -> DataDefnCons a
DataTypeCons Bool
False [HsConDecl]
[GenLocated SrcSpanAnnA (ConDecl GhcPs)]
constructors) GenLocated SrcSpanAnnA (ConDecl GhcPs)
-> DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall a. a -> DataDefnCons a
NewTypeCon Maybe (GenLocated SrcSpanAnnA (ConDecl GhcPs))
newtypeCtor
#else
            constructors
#endif

        , dd_derivs :: HsDeriving GhcPs
dd_derivs =
              Maybe (LHsDerivingClause GhcPs) -> HsDeriving GhcPs
forall a. Maybe a -> [a]
maybeToList (Maybe (LHsDerivingClause GhcPs) -> HsDeriving GhcPs)
-> Maybe (LHsDerivingClause GhcPs) -> HsDeriving GhcPs
forall a b. (a -> b) -> a -> b
$ Maybe HsDerivStrategy
-> [(HsOuterSigTyVarBndrs, HsType)]
-> Maybe (LHsDerivingClause GhcPs)
derivingClause_ Maybe HsDerivStrategy
Maybe (GenLocated (EpAnn NoEpAnns) (DerivStrategy GhcPs))
forall a. Maybe a
Nothing ([(HsOuterSigTyVarBndrs, HsType)]
 -> Maybe (LHsDerivingClause GhcPs))
-> [(HsOuterSigTyVarBndrs, HsType)]
-> Maybe (LHsDerivingClause GhcPs)
forall a b. (a -> b) -> a -> b
$ [HsQName]
[GenLocated SrcSpanAnnN RdrName]
derivedInstances [GenLocated SrcSpanAnnN RdrName]
-> (GenLocated SrcSpanAnnN RdrName
    -> (HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs)))
-> [(HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \GenLocated SrcSpanAnnN RdrName
className ->
                (HsOuterSigTyVarBndrs
implicitOuterSigTyVarBinders_, HsQName -> HsType
typeNamed_ HsQName
GenLocated SrcSpanAnnN RdrName
className)
        }
    }
  where
    -- TO DO: Support GADT syntax, assuming we ever start to use it in generated code.
    newtypeCtor :: Maybe (GenLocated SrcSpanAnnA (ConDecl GhcPs))
newtypeCtor = case [HsConDecl]
constructors of
      [ con :: HsConDecl
con@( L SrcSpanAnnA
_ ( ConDeclH98 { con_forall :: forall pass. ConDecl pass -> Bool
con_forall = Bool
False
                               , con_ex_tvs :: forall pass. ConDecl pass -> [LHsTyVarBndr Specificity pass]
con_ex_tvs = []
                               , con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (LHsContext GhcPs)
Nothing
                               , con_args :: forall pass. ConDecl pass -> HsConDeclH98Details pass
con_args = HsConDeclH98Details GhcPs
args
                               } ) ) ] -> case HsConDeclH98Details GhcPs
args of
        PfxCon [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
_] -> GenLocated SrcSpanAnnA (ConDecl GhcPs)
-> Maybe (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall a. a -> Maybe a
Just HsConDecl
GenLocated SrcSpanAnnA (ConDecl GhcPs)
con
        RecCon (L SrcSpanAnnL
_ [L SrcSpanAnnA
_ ConDeclField { cd_fld_names :: forall pass. ConDeclField pass -> [LFieldOcc pass]
cd_fld_names = [LFieldOcc GhcPs
_] }]) -> GenLocated SrcSpanAnnA (ConDecl GhcPs)
-> Maybe (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall a. a -> Maybe a
Just HsConDecl
GenLocated SrcSpanAnnA (ConDecl GhcPs)
con
        HsConDeclH98Details GhcPs
_ -> Maybe (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall a. Maybe a
Nothing
      [HsConDecl]
_ -> Maybe (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall a. Maybe a
Nothing

recDecl_ :: HsName -> [([HsName], HsBangType)] -> HsConDecl
recDecl_ :: HsQName -> [([HsQName], HsType)] -> HsConDecl
recDecl_ HsQName
name [([HsQName], HsType)]
fields = ConDecl GhcPs -> GenLocated SrcSpanAnnA (ConDecl GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA ConDeclH98
#if MIN_VERSION_ghc_lib_parser(9,12,0)
  { con_ext = noAnn
#else
  { con_ext :: XConDeclH98 GhcPs
con_ext = [AddEpAnn]
XConDeclH98 GhcPs
forall a. SyntaxDefault a => a
synDef
#endif
  , con_name :: HsQName
con_name = HsQName
name
  , con_forall :: Bool
con_forall = Bool
False
  , con_ex_tvs :: [LHsTyVarBndr Specificity GhcPs]
con_ex_tvs = []
  , con_mb_cxt :: Maybe (LHsContext GhcPs)
con_mb_cxt = Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall a. Maybe a
Nothing
  , con_args :: HsConDeclH98Details GhcPs
con_args = XRec GhcPs [LConDeclField GhcPs] -> HsConDeclH98Details GhcPs
forall tyarg arg rec. rec -> HsConDetails tyarg arg rec
RecCon (XRec GhcPs [LConDeclField GhcPs] -> HsConDeclH98Details GhcPs)
-> XRec GhcPs [LConDeclField GhcPs] -> HsConDeclH98Details GhcPs
forall a b. (a -> b) -> a -> b
$ [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA ([GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
 -> GenLocated
      SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
-> [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
forall a b. (a -> b) -> a -> b
$ [([HsQName], HsType)]
[([GenLocated SrcSpanAnnN RdrName],
  GenLocated SrcSpanAnnA (HsType GhcPs))]
fields [([GenLocated SrcSpanAnnN RdrName],
  GenLocated SrcSpanAnnA (HsType GhcPs))]
-> (([GenLocated SrcSpanAnnN RdrName],
     GenLocated SrcSpanAnnA (HsType GhcPs))
    -> GenLocated SrcSpanAnnA (ConDeclField GhcPs))
-> [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \([GenLocated SrcSpanAnnN RdrName]
names, GenLocated SrcSpanAnnA (HsType GhcPs)
bangTy) -> ConDeclField GhcPs -> GenLocated SrcSpanAnnA (ConDeclField GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA ConDeclField
      { cd_fld_ext :: XConDeclField GhcPs
cd_fld_ext = [AddEpAnn]
XConDeclField GhcPs
forall a. SyntaxDefault a => a
synDef
      , cd_fld_names :: [LFieldOcc GhcPs]
cd_fld_names =
#if MIN_VERSION_ghc_lib_parser(9,4,0)
          FieldOcc GhcPs -> GenLocated SrcSpanAnnA (FieldOcc GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA
#else
          noLoc
#endif
          (FieldOcc GhcPs -> GenLocated SrcSpanAnnA (FieldOcc GhcPs))
-> (GenLocated SrcSpanAnnN RdrName -> FieldOcc GhcPs)
-> GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (FieldOcc GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XCFieldOcc GhcPs -> XRec GhcPs RdrName -> FieldOcc GhcPs
forall pass. XCFieldOcc pass -> XRec pass RdrName -> FieldOcc pass
FieldOcc XCFieldOcc GhcPs
NoExtField
NoExtField (GenLocated SrcSpanAnnN RdrName
 -> GenLocated SrcSpanAnnA (FieldOcc GhcPs))
-> [GenLocated SrcSpanAnnN RdrName]
-> [GenLocated SrcSpanAnnA (FieldOcc GhcPs)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [GenLocated SrcSpanAnnN RdrName]
names
      , cd_fld_type :: HsType
cd_fld_type = HsType
GenLocated SrcSpanAnnA (HsType GhcPs)
bangTy
      , cd_fld_doc :: Maybe (LHsDoc GhcPs)
cd_fld_doc = Maybe (LHsDoc GhcPs)
forall a. Maybe a
Nothing
      }
  , con_doc :: Maybe (LHsDoc GhcPs)
con_doc = Maybe (LHsDoc GhcPs)
forall a. Maybe a
Nothing
  }

conDecl_ :: HsName -> [HsBangType] -> HsConDecl
conDecl_ :: HsQName -> [HsType] -> HsConDecl
conDecl_ HsQName
name [HsType]
fields = ConDecl GhcPs -> GenLocated SrcSpanAnnA (ConDecl GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA ConDeclH98
#if MIN_VERSION_ghc_lib_parser(9,12,0)
  { con_ext = noAnn
#else
  { con_ext :: XConDeclH98 GhcPs
con_ext = [AddEpAnn]
XConDeclH98 GhcPs
forall a. SyntaxDefault a => a
synDef
#endif
  , con_name :: HsQName
con_name = HsQName
name
  , con_forall :: Bool
con_forall = Bool
False
  , con_ex_tvs :: [LHsTyVarBndr Specificity GhcPs]
con_ex_tvs = []
  , con_mb_cxt :: Maybe (LHsContext GhcPs)
con_mb_cxt = Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall a. Maybe a
Nothing
  , con_args :: HsConDeclH98Details GhcPs
con_args = [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
-> HsConDetails
     Void
     (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
     (GenLocated
        SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
forall arg r. [arg] -> HsConDetails Void arg r
PfxCon (HsArrow GhcPs
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
forall pass a. HsArrow pass -> a -> HsScaled pass a
HsScaled HsArrow GhcPs
unrestrictedArrow_ (GenLocated SrcSpanAnnA (HsType GhcPs)
 -> HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [HsType]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
fields)
  , con_doc :: Maybe (LHsDoc GhcPs)
con_doc = Maybe (LHsDoc GhcPs)
forall a. Maybe a
Nothing
  }

derivingClause_ ::
  Maybe HsDerivStrategy ->
  [(HsOuterSigTyVarBndrs, HsType)] ->
  Maybe HsDerivingClause
derivingClause_ :: Maybe HsDerivStrategy
-> [(HsOuterSigTyVarBndrs, HsType)]
-> Maybe (LHsDerivingClause GhcPs)
derivingClause_ Maybe HsDerivStrategy
_ [] = Maybe (LHsDerivingClause GhcPs)
Maybe (GenLocated (EpAnn NoEpAnns) (HsDerivingClause GhcPs))
forall a. Maybe a
Nothing
derivingClause_ Maybe HsDerivStrategy
strategy [(HsOuterSigTyVarBndrs, HsType)]
classTypes = LHsDerivingClause GhcPs -> Maybe (LHsDerivingClause GhcPs)
forall a. a -> Maybe a
Just (LHsDerivingClause GhcPs -> Maybe (LHsDerivingClause GhcPs))
-> LHsDerivingClause GhcPs -> Maybe (LHsDerivingClause GhcPs)
forall a b. (a -> b) -> a -> b
$ EpAnn NoEpAnns
-> HsDerivingClause GhcPs
-> GenLocated (EpAnn NoEpAnns) (HsDerivingClause GhcPs)
forall l e. l -> e -> GenLocated l e
L EpAnn NoEpAnns
forall a. SyntaxDefault a => a
synDef (HsDerivingClause GhcPs
 -> GenLocated (EpAnn NoEpAnns) (HsDerivingClause GhcPs))
-> HsDerivingClause GhcPs
-> GenLocated (EpAnn NoEpAnns) (HsDerivingClause GhcPs)
forall a b. (a -> b) -> a -> b
$
  GHC.HsDerivingClause
    { deriv_clause_ext :: XCHsDerivingClause GhcPs
GHC.deriv_clause_ext = [AddEpAnn]
XCHsDerivingClause GhcPs
forall a. SyntaxDefault a => a
synDef
    , deriv_clause_strategy :: Maybe HsDerivStrategy
GHC.deriv_clause_strategy = Maybe HsDerivStrategy
strategy
    , deriv_clause_tys :: LDerivClauseTys GhcPs
GHC.deriv_clause_tys = DerivClauseTys GhcPs
-> GenLocated SrcSpanAnnC (DerivClauseTys GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (DerivClauseTys GhcPs
 -> GenLocated SrcSpanAnnC (DerivClauseTys GhcPs))
-> DerivClauseTys GhcPs
-> GenLocated SrcSpanAnnC (DerivClauseTys GhcPs)
forall a b. (a -> b) -> a -> b
$ XDctMulti GhcPs -> [LHsSigType GhcPs] -> DerivClauseTys GhcPs
forall pass.
XDctMulti pass -> [LHsSigType pass] -> DerivClauseTys pass
DctMulti XDctMulti GhcPs
NoExtField
NoExtField ([LHsSigType GhcPs] -> DerivClauseTys GhcPs)
-> [LHsSigType GhcPs] -> DerivClauseTys GhcPs
forall a b. (a -> b) -> a -> b
$
        HsSigType GhcPs -> GenLocated SrcSpanAnnA (HsSigType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsSigType GhcPs -> GenLocated SrcSpanAnnA (HsSigType GhcPs))
-> ((HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))
    -> HsSigType GhcPs)
-> (HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated SrcSpanAnnA (HsSigType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HsOuterSigTyVarBndrs
 -> GenLocated SrcSpanAnnA (HsType GhcPs) -> HsSigType GhcPs)
-> (HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))
-> HsSigType GhcPs
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (XHsSig GhcPs -> HsOuterSigTyVarBndrs -> HsType -> HsSigType GhcPs
forall pass.
XHsSig pass
-> HsOuterSigTyVarBndrs pass -> LHsType pass -> HsSigType pass
HsSig XHsSig GhcPs
NoExtField
NoExtField) ((HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))
 -> GenLocated SrcSpanAnnA (HsSigType GhcPs))
-> [(HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))]
-> [GenLocated SrcSpanAnnA (HsSigType GhcPs)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(HsOuterSigTyVarBndrs, HsType)]
[(HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))]
classTypes
    }

splitDerivingClause ::
  HsDerivingClause ->
  (Maybe HsDerivStrategy, [(HsOuterSigTyVarBndrs, HsType)])
splitDerivingClause :: LHsDerivingClause GhcPs
-> (Maybe HsDerivStrategy, [(HsOuterSigTyVarBndrs, HsType)])
splitDerivingClause (L EpAnn NoEpAnns
_ GHC.HsDerivingClause
                           { deriv_clause_strategy :: forall pass. HsDerivingClause pass -> Maybe (LDerivStrategy pass)
GHC.deriv_clause_strategy = Maybe HsDerivStrategy
strategy
                           , deriv_clause_tys :: forall pass. HsDerivingClause pass -> LDerivClauseTys pass
GHC.deriv_clause_tys = L SrcSpanAnnC
_ DerivClauseTys GhcPs
clauseTypes
                           }) =
    case DerivClauseTys GhcPs
clauseTypes of
      DctSingle XDctSingle GhcPs
_ LHsSigType GhcPs
sig -> (Maybe HsDerivStrategy
strategy, [GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> (HsOuterSigTyVarBndrs, HsType)
forall {pass} {l}.
(XXHsSigType pass ~ DataConCantHappen) =>
GenLocated l (HsSigType pass)
-> (HsOuterSigTyVarBndrs pass, XRec pass (HsType pass))
splitSig LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
sig])
      DctMulti XDctMulti GhcPs
_ [LHsSigType GhcPs]
sigs -> (Maybe HsDerivStrategy
strategy, (GenLocated SrcSpanAnnA (HsSigType GhcPs)
 -> (HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs)))
-> [GenLocated SrcSpanAnnA (HsSigType GhcPs)]
-> [(HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> (HsOuterSigTyVarBndrs, HsType)
GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> (HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))
forall {pass} {l}.
(XXHsSigType pass ~ DataConCantHappen) =>
GenLocated l (HsSigType pass)
-> (HsOuterSigTyVarBndrs pass, XRec pass (HsType pass))
splitSig [LHsSigType GhcPs]
[GenLocated SrcSpanAnnA (HsSigType GhcPs)]
sigs)
  where
    splitSig :: GenLocated l (HsSigType pass)
-> (HsOuterSigTyVarBndrs pass, XRec pass (HsType pass))
splitSig (L l
_ HsSigType pass
sig) = case HsSigType pass
sig of
      HsSig XHsSig pass
_ HsOuterSigTyVarBndrs pass
binders XRec pass (HsType pass)
classType -> (HsOuterSigTyVarBndrs pass
binders, XRec pass (HsType pass)
classType)
      XHsSigType XXHsSigType pass
impossible
#if MIN_VERSION_base(4,16,0)
        | Bool
considerAccessible
            -- We use 'considerAccessible' because GHC 9.4.6 will issue the warning
            -- "Pattern match is redundant" (-Woverlapping-patterns) if we provide
            -- this match *and* use its strict field 'impossible', and yet
            -- if we omit this match then GHC 9.4.6 will issue the warning
            -- "Pattern match(es) are non-exhaustive" (-Wincomplete-patterns).
            -- We cannot avoid the warning without either 'considerAccessible'
            -- or avoiding any use of 'impossible', which would require 'error'
            -- or similar to handle this impossible case match.
#endif
          -> DataConCantHappen
-> (HsOuterSigTyVarBndrs pass, XRec pass (HsType pass))
forall a. DataConCantHappen -> a
dataConCantHappen XXHsSigType pass
DataConCantHappen
impossible

instDecl_ :: HsQName -> [HsType] -> [HsBind] -> HsDecl
instDecl_ :: HsQName -> [HsType] -> [HsBind] -> HsDecl
instDecl_ HsQName
className [HsType]
classArgs [HsBind]
binds = HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs))
-> HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall a b. (a -> b) -> a -> b
$ XInstD GhcPs -> InstDecl GhcPs -> HsDecl GhcPs
forall p. XInstD p -> InstDecl p -> HsDecl p
GHC.InstD XInstD GhcPs
NoExtField
NoExtField ClsInstD
  { cid_d_ext :: XClsInstD GhcPs
cid_d_ext = XClsInstD GhcPs
NoExtField
NoExtField
  , cid_inst :: ClsInstDecl GhcPs
cid_inst = ClsInstDecl
#if MIN_VERSION_ghc_lib_parser(9,12,0)
      { cid_ext = (Nothing, noAnn, NoAnnSortKey)
#else
      { cid_ext :: XCClsInstDecl GhcPs
cid_ext = (Maybe (GenLocated SrcSpanAnnP (WarningTxt GhcPs)), [AddEpAnn],
 AnnSortKey DeclTag)
XCClsInstDecl GhcPs
forall a. SyntaxDefault a => a
synDef
#endif
      , cid_poly_ty :: LHsSigType GhcPs
cid_poly_ty = HsSigType GhcPs -> GenLocated SrcSpanAnnA (HsSigType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsSigType GhcPs -> GenLocated SrcSpanAnnA (HsSigType GhcPs))
-> HsSigType GhcPs -> GenLocated SrcSpanAnnA (HsSigType GhcPs)
forall a b. (a -> b) -> a -> b
$ XHsSig GhcPs -> HsOuterSigTyVarBndrs -> HsType -> HsSigType GhcPs
forall pass.
XHsSig pass
-> HsOuterSigTyVarBndrs pass -> LHsType pass -> HsSigType pass
HsSig XHsSig GhcPs
NoExtField
NoExtField HsOuterSigTyVarBndrs
implicitOuterSigTyVarBinders_ (HsQName -> [HsType] -> HsType
tyConApply HsQName
className [HsType]
classArgs)
#if MIN_VERSION_ghc_lib_parser(9,12,0)
      , cid_binds = binds
#else
      , cid_binds :: LHsBinds GhcPs
cid_binds = [GenLocated SrcSpanAnnA (HsBindLR GhcPs GhcPs)]
-> Bag (GenLocated SrcSpanAnnA (HsBindLR GhcPs GhcPs))
forall a. [a] -> Bag a
listToBag [HsBind]
[GenLocated SrcSpanAnnA (HsBindLR GhcPs GhcPs)]
binds
#endif
      , cid_sigs :: [LSig GhcPs]
cid_sigs = []
      , cid_tyfam_insts :: [LTyFamInstDecl GhcPs]
cid_tyfam_insts = []
      , cid_datafam_insts :: [LDataFamInstDecl GhcPs]
cid_datafam_insts = []
      , cid_overlap_mode :: Maybe (XRec GhcPs OverlapMode)
cid_overlap_mode = Maybe (XRec GhcPs OverlapMode)
Maybe (GenLocated SrcSpanAnnP OverlapMode)
forall a. Maybe a
Nothing
      }
  }

typeOfInstDecl :: HsDecl -> Maybe (HsOuterSigTyVarBndrs, HsType)
typeOfInstDecl :: HsDecl -> Maybe (HsOuterSigTyVarBndrs, HsType)
typeOfInstDecl ( L SrcSpanAnnA
_ ( GHC.InstD XInstD GhcPs
_ ClsInstD
                       { cid_inst :: forall pass. InstDecl pass -> ClsInstDecl pass
cid_inst = ClsInstDecl
                         { cid_poly_ty :: forall pass. ClsInstDecl pass -> LHsSigType pass
cid_poly_ty = L SrcSpanAnnA
_ (HsSig XHsSig GhcPs
_ HsOuterSigTyVarBndrs
binders HsType
classType)
                         } } ) ) =
  (HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))
-> Maybe
     (HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))
forall a. a -> Maybe a
Just (HsOuterSigTyVarBndrs
binders, HsType
GenLocated SrcSpanAnnA (HsType GhcPs)
classType)
typeOfInstDecl HsDecl
_ =
  Maybe (HsOuterSigTyVarBndrs, HsType)
Maybe (HsOuterSigTyVarBndrs, GenLocated SrcSpanAnnA (HsType GhcPs))
forall a. Maybe a
Nothing

closedTyFamDecl_ ::
  HsQName ->
  [HsTyVarBndrV] ->
  HsType ->
  [(Maybe [HsTyVarBndrU], [HsType], HsType)] ->
  HsDecl
closedTyFamDecl_ :: HsQName
-> [HsTyVarBndrV]
-> HsType
-> [(Maybe [HsTyVarBndrU], [HsType], HsType)]
-> HsDecl
closedTyFamDecl_ HsQName
tyFamName [HsTyVarBndrV]
famBndrs HsType
resultKind [(Maybe [HsTyVarBndrU], [HsType], HsType)]
eqns =
  HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs))
-> HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall a b. (a -> b) -> a -> b
$ XTyClD GhcPs -> TyClDecl GhcPs -> HsDecl GhcPs
forall p. XTyClD p -> TyClDecl p -> HsDecl p
GHC.TyClD XTyClD GhcPs
NoExtField
NoExtField (TyClDecl GhcPs -> HsDecl GhcPs) -> TyClDecl GhcPs -> HsDecl GhcPs
forall a b. (a -> b) -> a -> b
$ XFamDecl GhcPs -> FamilyDecl GhcPs -> TyClDecl GhcPs
forall pass. XFamDecl pass -> FamilyDecl pass -> TyClDecl pass
FamDecl XFamDecl GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef (FamilyDecl GhcPs -> TyClDecl GhcPs)
-> FamilyDecl GhcPs -> TyClDecl GhcPs
forall a b. (a -> b) -> a -> b
$ FamilyDecl
#if MIN_VERSION_ghc_lib_parser(9,12,0)
    { fdExt = noAnn
#else
    { fdExt :: XCFamilyDecl GhcPs
fdExt = [AddEpAnn]
XCFamilyDecl GhcPs
forall a. SyntaxDefault a => a
synDef
#endif
    , fdInfo :: FamilyInfo GhcPs
fdInfo = Maybe [LTyFamInstEqn GhcPs] -> FamilyInfo GhcPs
forall pass. Maybe [LTyFamInstEqn pass] -> FamilyInfo pass
ClosedTypeFamily ([GenLocated
   SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
-> Maybe
     [GenLocated
        SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
forall a. a -> Maybe a
Just (((Maybe [XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))],
  [HsType], GenLocated SrcSpanAnnA (HsType GhcPs))
 -> GenLocated
      SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))))
-> [(Maybe [XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))],
     [HsType], GenLocated SrcSpanAnnA (HsType GhcPs))]
-> [GenLocated
      SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
forall a b. (a -> b) -> [a] -> [b]
map (Maybe [XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))],
 [HsType], GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated
     SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
onEqn [(Maybe [XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))],
  [HsType], GenLocated SrcSpanAnnA (HsType GhcPs))]
[(Maybe [HsTyVarBndrU], [HsType], HsType)]
eqns))
    , fdTopLevel :: TopLevelFlag
fdTopLevel = TopLevelFlag
TopLevel
    , fdLName :: HsQName
fdLName = HsQName
tyFamName
    , fdTyVars :: LHsQTyVars GhcPs
fdTyVars = XHsQTvs GhcPs -> [HsTyVarBndrV] -> LHsQTyVars GhcPs
forall pass.
XHsQTvs pass
-> [LHsTyVarBndr (HsBndrVis pass) pass] -> LHsQTyVars pass
HsQTvs XHsQTvs GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef [HsTyVarBndrV]
famBndrs
    , fdFixity :: LexicalFixity
fdFixity = LexicalFixity
Prefix
    , fdResultSig :: LFamilyResultSig GhcPs
fdResultSig =
#if MIN_VERSION_ghc_lib_parser(9,4,0)
        FamilyResultSig GhcPs
-> GenLocated (EpAnn NoEpAnns) (FamilyResultSig GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (FamilyResultSig GhcPs
 -> GenLocated (EpAnn NoEpAnns) (FamilyResultSig GhcPs))
-> FamilyResultSig GhcPs
-> GenLocated (EpAnn NoEpAnns) (FamilyResultSig GhcPs)
forall a b. (a -> b) -> a -> b
$
#else
        noLoc $
#endif
          XCKindSig GhcPs -> HsType -> FamilyResultSig GhcPs
forall pass. XCKindSig pass -> LHsKind pass -> FamilyResultSig pass
KindSig XCKindSig GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef HsType
resultKind
    , fdInjectivityAnn :: Maybe (LInjectivityAnn GhcPs)
fdInjectivityAnn = Maybe (LInjectivityAnn GhcPs)
Maybe (GenLocated (EpAnn NoEpAnns) (InjectivityAnn GhcPs))
forall a. Maybe a
Nothing
    }
  where
    onEqn :: (Maybe [XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))],
 [HsType], GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated
     SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
onEqn (Maybe [XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))]
eqnBndrs, [HsType]
pats, GenLocated SrcSpanAnnA (HsType GhcPs)
rhs) = FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated
     SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
 -> GenLocated
      SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))))
-> FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> GenLocated
     SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall a b. (a -> b) -> a -> b
$
        FamEqn
          { feqn_ext :: XCFamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
feqn_ext = XCFamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
forall a. SyntaxDefault a => a
synDef
          , feqn_tycon :: HsQName
feqn_tycon = HsQName
tyFamName
          , feqn_bndrs :: HsOuterFamEqnTyVarBndrs GhcPs
feqn_bndrs = HsOuterFamEqnTyVarBndrs GhcPs
-> ([XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))]
    -> HsOuterFamEqnTyVarBndrs GhcPs)
-> Maybe [XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))]
-> HsOuterFamEqnTyVarBndrs GhcPs
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (XHsOuterImplicit GhcPs -> HsOuterFamEqnTyVarBndrs GhcPs
forall flag pass.
XHsOuterImplicit pass -> HsOuterTyVarBndrs flag pass
HsOuterImplicit XHsOuterImplicit GhcPs
NoExtField
NoExtField) (XHsOuterExplicit GhcPs ()
-> [XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))]
-> HsOuterFamEqnTyVarBndrs GhcPs
forall flag pass.
XHsOuterExplicit pass flag
-> [LHsTyVarBndr flag (NoGhcTc pass)]
-> HsOuterTyVarBndrs flag pass
HsOuterExplicit XHsOuterExplicit GhcPs ()
forall a. SyntaxDefault a => a
synDef) Maybe [XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))]
eqnBndrs
          , feqn_pats :: HsFamEqnPats GhcPs
feqn_pats = (HsType -> HsArg GhcPs HsType HsType)
-> [HsType] -> HsFamEqnPats GhcPs
forall a b. (a -> b) -> [a] -> [b]
map
              (XValArg GhcPs -> HsType -> HsArg GhcPs HsType HsType
forall p tm ty. XValArg p -> tm -> HsArg p tm ty
HsValArg
#if MIN_VERSION_ghc_lib_parser(9,10,0)
                        XValArg GhcPs
forall a. SyntaxDefault a => a
synDef
#endif
              ) [HsType]
pats
          , feqn_fixity :: LexicalFixity
feqn_fixity = LexicalFixity
Prefix
          , feqn_rhs :: GenLocated SrcSpanAnnA (HsType GhcPs)
feqn_rhs = GenLocated SrcSpanAnnA (HsType GhcPs)
rhs
          }

tyFamInstDecl_ :: HsQName -> Maybe [HsTyVarBndrU] -> [HsType] -> HsType -> HsDecl
tyFamInstDecl_ :: HsQName -> Maybe [HsTyVarBndrU] -> [HsType] -> HsType -> HsDecl
tyFamInstDecl_ HsQName
tyFamName Maybe [HsTyVarBndrU]
bndrs [HsType]
pats HsType
rhs = HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs))
-> HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall a b. (a -> b) -> a -> b
$ XInstD GhcPs -> InstDecl GhcPs -> HsDecl GhcPs
forall p. XInstD p -> InstDecl p -> HsDecl p
GHC.InstD XInstD GhcPs
NoExtField
NoExtField TyFamInstD
  { tfid_ext :: XTyFamInstD GhcPs
tfid_ext = XTyFamInstD GhcPs
NoExtField
NoExtField
  , tfid_inst :: TyFamInstDecl GhcPs
tfid_inst = TyFamInstDecl
      { tfid_xtn :: XCTyFamInstDecl GhcPs
tfid_xtn = [AddEpAnn]
XCTyFamInstDecl GhcPs
forall a. SyntaxDefault a => a
synDef
      , tfid_eqn :: TyFamInstEqn GhcPs
tfid_eqn = FamEqn
            { feqn_ext :: XCFamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
feqn_ext = [AddEpAnn]
XCFamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
forall a. SyntaxDefault a => a
synDef
            , feqn_tycon :: HsQName
feqn_tycon = HsQName
tyFamName
            , feqn_bndrs :: HsOuterFamEqnTyVarBndrs GhcPs
feqn_bndrs = HsOuterFamEqnTyVarBndrs GhcPs
-> ([GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
    -> HsOuterFamEqnTyVarBndrs GhcPs)
-> Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> HsOuterFamEqnTyVarBndrs GhcPs
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (XHsOuterImplicit GhcPs -> HsOuterFamEqnTyVarBndrs GhcPs
forall flag pass.
XHsOuterImplicit pass -> HsOuterTyVarBndrs flag pass
HsOuterImplicit XHsOuterImplicit GhcPs
NoExtField
NoExtField) (XHsOuterExplicit GhcPs ()
-> [XRec (NoGhcTc GhcPs) (HsTyVarBndr () (NoGhcTc GhcPs))]
-> HsOuterFamEqnTyVarBndrs GhcPs
forall flag pass.
XHsOuterExplicit pass flag
-> [LHsTyVarBndr flag (NoGhcTc pass)]
-> HsOuterTyVarBndrs flag pass
HsOuterExplicit XHsOuterExplicit GhcPs ()
EpAnnForallTy
forall a. SyntaxDefault a => a
synDef) Maybe [HsTyVarBndrU]
Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
bndrs
            , feqn_pats :: HsFamEqnPats GhcPs
feqn_pats = (GenLocated SrcSpanAnnA (HsType GhcPs)
 -> HsArg
      GhcPs
      (GenLocated SrcSpanAnnA (HsType GhcPs))
      (GenLocated SrcSpanAnnA (HsType GhcPs)))
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> [HsArg
      GhcPs
      (GenLocated SrcSpanAnnA (HsType GhcPs))
      (GenLocated SrcSpanAnnA (HsType GhcPs))]
forall a b. (a -> b) -> [a] -> [b]
map
                (XValArg GhcPs
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> HsArg
     GhcPs
     (GenLocated SrcSpanAnnA (HsType GhcPs))
     (GenLocated SrcSpanAnnA (HsType GhcPs))
forall p tm ty. XValArg p -> tm -> HsArg p tm ty
HsValArg
#if MIN_VERSION_ghc_lib_parser(9,10,0)
                          NoExtField
XValArg GhcPs
forall a. SyntaxDefault a => a
synDef
#endif
                ) [HsType]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
pats
            , feqn_fixity :: LexicalFixity
feqn_fixity = LexicalFixity
Prefix
            , feqn_rhs :: GenLocated SrcSpanAnnA (HsType GhcPs)
feqn_rhs = HsType
GenLocated SrcSpanAnnA (HsType GhcPs)
rhs
            }
      }
  }

-- | 'HsBind' includes a location, and this is one of the few places
-- where we do not need a location.  Rather than distinguishing in
-- the type between bindings that have a location and those that
-- do not, we simply ignore any binding location given here.
valDecl_ :: HsBind -> HsDecl
valDecl_ :: HsBind -> HsDecl
valDecl_ (L SrcSpanAnnA
_ HsBindLR GhcPs GhcPs
b) = HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (XValD GhcPs -> HsBindLR GhcPs GhcPs -> HsDecl GhcPs
forall p. XValD p -> HsBind p -> HsDecl p
GHC.ValD XValD GhcPs
NoExtField
NoExtField HsBindLR GhcPs GhcPs
b)

patBind_ :: HsPat -> HsExp -> HsBind
patBind_ :: HsPat -> LHsExpr GhcPs -> HsBind
patBind_ (L SrcSpanAnnA
_ (VarPat XVarPat GhcPs
_ HsQName
nm)) LHsExpr GhcPs
rhs =
  HsQName -> [([HsPat], LHsExpr GhcPs)] -> HsBind
function_ HsQName
nm [([], LHsExpr GhcPs
rhs)]  -- The comments at 'HsBindLR' say to use 'FunBind'.
patBind_ (L SrcSpanAnnA
_ (BangPat XBangPat GhcPs
_ (L SrcSpanAnnA
_ (VarPat XVarPat GhcPs
_ HsQName
nm)))) LHsExpr GhcPs
rhs =
  SrcStrictness -> HsQName -> [([HsPat], LHsExpr GhcPs)] -> HsBind
functionLike_ SrcStrictness
SrcStrict HsQName
nm [([], LHsExpr GhcPs
rhs)]  -- The comments at 'HsBindLR' say to use 'FunBind'.
patBind_ (L SrcSpanAnnA
_ (LazyPat XLazyPat GhcPs
_ (L SrcSpanAnnA
_ (VarPat XVarPat GhcPs
_ HsQName
nm)))) LHsExpr GhcPs
rhs =
  SrcStrictness -> HsQName -> [([HsPat], LHsExpr GhcPs)] -> HsBind
functionLike_ SrcStrictness
SrcLazy HsQName
nm [([], LHsExpr GhcPs
rhs)]  -- The comments at 'HsBindLR' say to use 'FunBind'.
patBind_ HsPat
pat LHsExpr GhcPs
rhs = HsBindLR GhcPs GhcPs
-> GenLocated SrcSpanAnnA (HsBindLR GhcPs GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA PatBind
  { pat_ext :: XPatBind GhcPs GhcPs
pat_ext = XPatBind GhcPs GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef
  , pat_lhs :: HsPat
pat_lhs = HsPat
pat
#if MIN_VERSION_ghc_lib_parser(9,10,0)
  , pat_mult :: HsMultAnn GhcPs
pat_mult = XNoMultAnn GhcPs -> HsMultAnn GhcPs
forall pass. XNoMultAnn pass -> HsMultAnn pass
HsNoMultAnn NoExtField
XNoMultAnn GhcPs
forall a. SyntaxDefault a => a
synDef
#endif
  , pat_rhs :: GRHSs GhcPs (LHsExpr GhcPs)
pat_rhs = SrcSpan
-> LocatedA (HsExpr GhcPs)
-> EpAnn GrhsAnn
-> GRHSs GhcPs (LocatedA (HsExpr GhcPs))
forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
 ~ EpAnn NoEpAnns) =>
SrcSpan
-> LocatedA (body (GhcPass p))
-> EpAnn GrhsAnn
-> GRHSs (GhcPass p) (LocatedA (body (GhcPass p)))
unguardedGRHSs SrcSpan
forall a. SyntaxDefault a => a
synDef LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
rhs EpAnn GrhsAnn
forall a. SyntaxDefault a => a
synDef
#if !MIN_VERSION_ghc_lib_parser(9,6,0)
  , pat_ticks = synDef
#endif
  }

-- | @'functionS_' = 'function_' . 'unqual_' 'varName'@
functionS_ :: String -> [([HsPat], HsExp)] -> HsBind
functionS_ :: String -> [([HsPat], LHsExpr GhcPs)] -> HsBind
functionS_ = HsQName -> [([HsPat], LHsExpr GhcPs)] -> HsBind
GenLocated SrcSpanAnnN RdrName
-> [([GenLocated SrcSpanAnnA (Pat GhcPs)],
     LocatedA (HsExpr GhcPs))]
-> GenLocated SrcSpanAnnA (HsBindLR GhcPs GhcPs)
function_ (GenLocated SrcSpanAnnN RdrName
 -> [([GenLocated SrcSpanAnnA (Pat GhcPs)],
      LocatedA (HsExpr GhcPs))]
 -> GenLocated SrcSpanAnnA (HsBindLR GhcPs GhcPs))
-> (String -> GenLocated SrcSpanAnnN RdrName)
-> String
-> [([GenLocated SrcSpanAnnA (Pat GhcPs)],
     LocatedA (HsExpr GhcPs))]
-> GenLocated SrcSpanAnnA (HsBindLR GhcPs GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpace -> String -> HsQName
unqual_ NameSpace
varName

-- | A function with prefix syntax (as opposed to infix).
function_ :: HsName -> [([HsPat], HsExp)] -> HsBind
function_ :: HsQName -> [([HsPat], LHsExpr GhcPs)] -> HsBind
function_ = SrcStrictness -> HsQName -> [([HsPat], LHsExpr GhcPs)] -> HsBind
functionLike_ SrcStrictness
NoSrcStrict

functionLike_ :: SrcStrictness -> HsName -> [([HsPat], HsExp)] -> HsBind
functionLike_ :: SrcStrictness -> HsQName -> [([HsPat], LHsExpr GhcPs)] -> HsBind
functionLike_ SrcStrictness
strictness HsQName
name [([HsPat], LHsExpr GhcPs)]
alts = HsBindLR GhcPs GhcPs
-> GenLocated SrcSpanAnnA (HsBindLR GhcPs GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsBindLR GhcPs GhcPs
 -> GenLocated SrcSpanAnnA (HsBindLR GhcPs GhcPs))
-> HsBindLR GhcPs GhcPs
-> GenLocated SrcSpanAnnA (HsBindLR GhcPs GhcPs)
forall a b. (a -> b) -> a -> b
$ Origin
-> GenLocated SrcSpanAnnN RdrName
-> [LMatch GhcPs (LHsExpr GhcPs)]
-> HsBindLR GhcPs GhcPs
mkFunBind Origin
generated HsQName
GenLocated SrcSpanAnnN RdrName
name ((([GenLocated SrcSpanAnnA (Pat GhcPs)], LocatedA (HsExpr GhcPs))
 -> GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs))))
-> [([GenLocated SrcSpanAnnA (Pat GhcPs)],
     LocatedA (HsExpr GhcPs))]
-> [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
forall a b. (a -> b) -> [a] -> [b]
map ([HsPat], LHsExpr GhcPs) -> LMatch GhcPs (LHsExpr GhcPs)
([GenLocated SrcSpanAnnA (Pat GhcPs)], LocatedA (HsExpr GhcPs))
-> GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))
match [([HsPat], LHsExpr GhcPs)]
[([GenLocated SrcSpanAnnA (Pat GhcPs)], LocatedA (HsExpr GhcPs))]
alts)
  where
    generated :: Origin
    generated :: Origin
generated = GenReason -> DoPmc -> Origin
Generated
#if MIN_VERSION_ghc_lib_parser(9,10,0)
                          GenReason
OtherExpansion
#endif
#if MIN_VERSION_ghc_lib_parser(9,8,0)
                                         DoPmc
DoPmc
#endif

    match :: ([HsPat], HsExp) -> HsMatch
#if MIN_VERSION_ghc_lib_parser(9,12,0)
    match (pats, rhs) = mkSimpleMatch ctxt (noLocA pats) rhs
#else
    match :: ([HsPat], LHsExpr GhcPs) -> LMatch GhcPs (LHsExpr GhcPs)
match ([HsPat]
pats, LHsExpr GhcPs
rhs) = HsMatchContext (LIdP (NoGhcTc GhcPs))
-> [HsPat]
-> LocatedA (HsExpr GhcPs)
-> LMatch GhcPs (LocatedA (HsExpr GhcPs))
forall (p :: Pass) (body :: * -> *).
(Anno (Match (GhcPass p) (LocatedA (body (GhcPass p))))
 ~ SrcSpanAnnA,
 Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
 ~ EpAnn NoEpAnns) =>
HsMatchContext (LIdP (NoGhcTc (GhcPass p)))
-> [LPat (GhcPass p)]
-> LocatedA (body (GhcPass p))
-> LMatch (GhcPass p) (LocatedA (body (GhcPass p)))
mkSimpleMatch HsMatchContext (LIdP (NoGhcTc GhcPs))
HsMatchContext (GenLocated SrcSpanAnnN RdrName)
ctxt [HsPat]
pats LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
rhs
#endif

    ctxt :: HsMatchContext (GenLocated SrcSpanAnnN RdrName)
ctxt = FunRhs
      { mc_fun :: GenLocated SrcSpanAnnN RdrName
mc_fun = HsQName
GenLocated SrcSpanAnnN RdrName
name
      , mc_fixity :: LexicalFixity
mc_fixity = LexicalFixity
Prefix
      , mc_strictness :: SrcStrictness
mc_strictness = SrcStrictness
strictness
#if MIN_VERSION_ghc_lib_parser(9,12,0)
      , mc_an = noAnn
#endif
      }

typeSig_ :: [HsName] -> HsOuterSigTyVarBndrs -> HsType -> HsDecl
typeSig_ :: [HsQName] -> HsOuterSigTyVarBndrs -> HsType -> HsDecl
typeSig_ [HsQName]
nms HsOuterSigTyVarBndrs
bndrs HsType
ty = HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs))
-> HsDecl GhcPs -> GenLocated SrcSpanAnnA (HsDecl GhcPs)
forall a b. (a -> b) -> a -> b
$ XSigD GhcPs -> Sig GhcPs -> HsDecl GhcPs
forall p. XSigD p -> Sig p -> HsDecl p
GHC.SigD XSigD GhcPs
NoExtField
NoExtField (Sig GhcPs -> HsDecl GhcPs) -> Sig GhcPs -> HsDecl GhcPs
forall a b. (a -> b) -> a -> b
$ XTypeSig GhcPs
-> [HsQName]
-> HsWildCardBndrs GhcPs (LHsSigType GhcPs)
-> Sig GhcPs
forall pass.
XTypeSig pass -> [LIdP pass] -> LHsSigWcType pass -> Sig pass
TypeSig XTypeSig GhcPs
AnnSig
forall a. SyntaxDefault a => a
synDef [HsQName]
nms (HsWildCardBndrs GhcPs (LHsSigType GhcPs) -> Sig GhcPs)
-> HsWildCardBndrs GhcPs (LHsSigType GhcPs) -> Sig GhcPs
forall a b. (a -> b) -> a -> b
$
  XHsWC GhcPs (LHsSigType GhcPs)
-> LHsSigType GhcPs -> HsWildCardBndrs GhcPs (LHsSigType GhcPs)
forall pass thing.
XHsWC pass thing -> thing -> HsWildCardBndrs pass thing
HsWC XHsWC GhcPs (LHsSigType GhcPs)
NoExtField
NoExtField (LHsSigType GhcPs -> HsWildCardBndrs GhcPs (LHsSigType GhcPs))
-> LHsSigType GhcPs -> HsWildCardBndrs GhcPs (LHsSigType GhcPs)
forall a b. (a -> b) -> a -> b
$
  HsSigType GhcPs -> GenLocated SrcSpanAnnA (HsSigType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsSigType GhcPs -> GenLocated SrcSpanAnnA (HsSigType GhcPs))
-> HsSigType GhcPs -> GenLocated SrcSpanAnnA (HsSigType GhcPs)
forall a b. (a -> b) -> a -> b
$
  XHsSig GhcPs -> HsOuterSigTyVarBndrs -> HsType -> HsSigType GhcPs
forall pass.
XHsSig pass
-> HsOuterSigTyVarBndrs pass -> LHsType pass -> HsSigType pass
HsSig XHsSig GhcPs
NoExtField
NoExtField HsOuterSigTyVarBndrs
bndrs HsType
ty

implicitOuterFamEqnTyVarBinders_ :: HsOuterFamEqnTyVarBndrs
implicitOuterFamEqnTyVarBinders_ :: HsOuterFamEqnTyVarBndrs GhcPs
implicitOuterFamEqnTyVarBinders_ = XHsOuterImplicit GhcPs -> HsOuterFamEqnTyVarBndrs GhcPs
forall flag pass.
XHsOuterImplicit pass -> HsOuterTyVarBndrs flag pass
HsOuterImplicit XHsOuterImplicit GhcPs
NoExtField
NoExtField

implicitOuterSigTyVarBinders_ :: HsOuterSigTyVarBndrs
implicitOuterSigTyVarBinders_ :: HsOuterSigTyVarBndrs
implicitOuterSigTyVarBinders_ = XHsOuterImplicit GhcPs -> HsOuterSigTyVarBndrs
forall flag pass.
XHsOuterImplicit pass -> HsOuterTyVarBndrs flag pass
HsOuterImplicit XHsOuterImplicit GhcPs
NoExtField
NoExtField

userTyVar_ :: flag -> HsName -> LHsTyVarBndr flag GhcPs
#if MIN_VERSION_ghc_lib_parser(9,12,0)
userTyVar_ flag nm = noLocA $ GHC.HsTvb noAnn flag (HsBndrVar NoExtField nm) (HsBndrNoKind NoExtField)
#else
userTyVar_ :: forall flag. flag -> HsQName -> LHsTyVarBndr flag GhcPs
userTyVar_ flag
flag HsQName
nm = HsTyVarBndr flag GhcPs
-> GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsTyVarBndr flag GhcPs
 -> GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs))
-> HsTyVarBndr flag GhcPs
-> GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs)
forall a b. (a -> b) -> a -> b
$ XUserTyVar GhcPs -> flag -> HsQName -> HsTyVarBndr flag GhcPs
forall flag pass.
XUserTyVar pass -> flag -> LIdP pass -> HsTyVarBndr flag pass
GHC.UserTyVar [AddEpAnn]
XUserTyVar GhcPs
forall a. SyntaxDefault a => a
synDef flag
flag HsQName
nm
#endif

kindedTyVar_ :: flag -> HsName -> HsType -> LHsTyVarBndr flag GhcPs
#if MIN_VERSION_ghc_lib_parser(9,12,0)
kindedTyVar_ flag nm ty = noLocA $ GHC.HsTvb noAnn flag (HsBndrVar NoExtField nm) (HsBndrKind NoExtField ty)
#else
kindedTyVar_ :: forall flag. flag -> HsQName -> HsType -> LHsTyVarBndr flag GhcPs
kindedTyVar_ flag
flag HsQName
nm HsType
ty = HsTyVarBndr flag GhcPs
-> GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsTyVarBndr flag GhcPs
 -> GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs))
-> HsTyVarBndr flag GhcPs
-> GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs)
forall a b. (a -> b) -> a -> b
$ XKindedTyVar GhcPs
-> flag -> HsQName -> HsType -> HsTyVarBndr flag GhcPs
forall flag pass.
XKindedTyVar pass
-> flag -> LIdP pass -> LHsKind pass -> HsTyVarBndr flag pass
GHC.KindedTyVar [AddEpAnn]
XKindedTyVar GhcPs
forall a. SyntaxDefault a => a
synDef flag
flag HsQName
nm HsType
ty
#endif

wild_ :: HsPat
wild_ :: HsPat
wild_ = Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs))
-> Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs)
forall a b. (a -> b) -> a -> b
$ XWildPat GhcPs -> Pat GhcPs
forall p. XWildPat p -> Pat p
WildPat XWildPat GhcPs
NoExtField
NoExtField

qual_ :: ModuleName -> NameSpace -> String -> HsQName
qual_ :: ModuleName -> NameSpace -> String -> HsQName
qual_ ModuleName
m NameSpace
ns String
name = RdrName -> GenLocated SrcSpanAnnN RdrName
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (RdrName -> GenLocated SrcSpanAnnN RdrName)
-> RdrName -> GenLocated SrcSpanAnnN RdrName
forall a b. (a -> b) -> a -> b
$ ModuleName -> OccName -> RdrName
mkRdrQual ModuleName
m (NameSpace -> String -> OccName
mkOccName NameSpace
ns String
name)

unqual_ :: NameSpace -> String -> HsName
unqual_ :: NameSpace -> String -> HsQName
unqual_ NameSpace
ns String
name = RdrName -> GenLocated SrcSpanAnnN RdrName
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (RdrName -> GenLocated SrcSpanAnnN RdrName)
-> RdrName -> GenLocated SrcSpanAnnN RdrName
forall a b. (a -> b) -> a -> b
$ OccName -> RdrName
mkRdrUnqual (NameSpace -> String -> OccName
mkOccName NameSpace
ns String
name)

uvar_ :: String -> HsExp
uvar_ :: String -> LHsExpr GhcPs
uvar_ = HsQName -> LHsExpr GhcPs
GenLocated SrcSpanAnnN RdrName -> LocatedA (HsExpr GhcPs)
var_ (GenLocated SrcSpanAnnN RdrName -> LocatedA (HsExpr GhcPs))
-> (String -> GenLocated SrcSpanAnnN RdrName)
-> String
-> LocatedA (HsExpr GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpace -> String -> HsQName
unqual_ NameSpace
varName

var_ :: HsQName -> HsExp
var_ :: HsQName -> LHsExpr GhcPs
var_ = HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsExpr GhcPs -> LocatedA (HsExpr GhcPs))
-> (GenLocated SrcSpanAnnN RdrName -> HsExpr GhcPs)
-> GenLocated SrcSpanAnnN RdrName
-> LocatedA (HsExpr GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XVar GhcPs -> HsQName -> HsExpr GhcPs
forall p. XVar p -> LIdP p -> HsExpr p
HsVar XVar GhcPs
NoExtField
NoExtField

fieldBind_ :: HsName -> HsExp -> LHsRecField GhcPs HsExp
fieldBind_ :: HsQName -> LHsExpr GhcPs -> LHsRecField GhcPs (LHsExpr GhcPs)
fieldBind_ HsQName
nm LHsExpr GhcPs
val = HsFieldBind
  (GenLocated SrcSpanAnnA (FieldOcc GhcPs)) (LocatedA (HsExpr GhcPs))
-> GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated SrcSpanAnnA (FieldOcc GhcPs))
        (LocatedA (HsExpr GhcPs)))
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA
#if MIN_VERSION_ghc_lib_parser(9,4,0)
  HsFieldBind
    { hfbAnn :: XHsFieldBind (GenLocated SrcSpanAnnA (FieldOcc GhcPs))
hfbAnn = [AddEpAnn]
XHsFieldBind (GenLocated SrcSpanAnnA (FieldOcc GhcPs))
forall a. SyntaxDefault a => a
synDef
    , hfbLHS :: GenLocated SrcSpanAnnA (FieldOcc GhcPs)
hfbLHS = FieldOcc GhcPs -> GenLocated SrcSpanAnnA (FieldOcc GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (FieldOcc GhcPs -> GenLocated SrcSpanAnnA (FieldOcc GhcPs))
-> FieldOcc GhcPs -> GenLocated SrcSpanAnnA (FieldOcc GhcPs)
forall a b. (a -> b) -> a -> b
$ XCFieldOcc GhcPs -> XRec GhcPs RdrName -> FieldOcc GhcPs
forall pass. XCFieldOcc pass -> XRec pass RdrName -> FieldOcc pass
FieldOcc XCFieldOcc GhcPs
NoExtField
NoExtField HsQName
XRec GhcPs RdrName
nm
    , hfbRHS :: LocatedA (HsExpr GhcPs)
hfbRHS = LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
val
    , hfbPun :: Bool
hfbPun = Bool
False
    }
#else
  HsRecField
    { hsRecFieldAnn = synDef
    , hsRecFieldLbl = noLoc $ FieldOcc NoExtField nm
    , hsRecFieldArg = val
    , hsRecPun = False
    }
#endif

recordCtor_ :: HsName -> [LHsRecField GhcPs HsExp] -> HsExp
recordCtor_ :: HsQName -> [LHsRecField GhcPs (LHsExpr GhcPs)] -> LHsExpr GhcPs
recordCtor_ HsQName
nm [LHsRecField GhcPs (LHsExpr GhcPs)]
fields = HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA RecordCon
  { rcon_ext :: XRecordCon GhcPs
rcon_ext = [AddEpAnn]
XRecordCon GhcPs
forall a. SyntaxDefault a => a
synDef
  , rcon_con :: XRec GhcPs (ConLikeP GhcPs)
rcon_con = HsQName
XRec GhcPs (ConLikeP GhcPs)
nm
  , rcon_flds :: HsRecordBinds GhcPs
rcon_flds = HsRecFields
      { rec_flds :: [LHsRecField GhcPs (LocatedA (HsExpr GhcPs))]
rec_flds = [LHsRecField GhcPs (LHsExpr GhcPs)]
[LHsRecField GhcPs (LocatedA (HsExpr GhcPs))]
fields
      , rec_dotdot :: Maybe (XRec GhcPs RecFieldsDotDot)
rec_dotdot = Maybe (XRec GhcPs RecFieldsDotDot)
Maybe (GenLocated EpaLocation RecFieldsDotDot)
forall a. Maybe a
Nothing
#if MIN_VERSION_ghc_lib_parser(9,12,0)
      , rec_ext = NoExtField
#endif
      }
  }

fieldUpd_ :: HsName -> HsExp -> LHsRecUpdField GhcPs
#if MIN_VERSION_ghc_lib_parser(9,8,0)
                                                     GhcPs
#endif
fieldUpd_ :: HsQName -> LHsExpr GhcPs -> LHsRecUpdField GhcPs GhcPs
fieldUpd_ HsQName
nm LHsExpr GhcPs
val = HsFieldBind
  (GenLocated SrcSpanAnnA (AmbiguousFieldOcc GhcPs))
  (LocatedA (HsExpr GhcPs))
-> GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated SrcSpanAnnA (AmbiguousFieldOcc GhcPs))
        (LocatedA (HsExpr GhcPs)))
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA
#if MIN_VERSION_ghc_lib_parser(9,4,0)
  HsFieldBind
    { hfbAnn :: XHsFieldBind (GenLocated SrcSpanAnnA (AmbiguousFieldOcc GhcPs))
hfbAnn = [AddEpAnn]
XHsFieldBind (GenLocated SrcSpanAnnA (AmbiguousFieldOcc GhcPs))
forall a. SyntaxDefault a => a
synDef
#if MIN_VERSION_ghc_lib_parser(9,12,0)
    , hfbLHS = noLocA $ FieldOcc NoExtField nm
#else
    , hfbLHS :: GenLocated SrcSpanAnnA (AmbiguousFieldOcc GhcPs)
hfbLHS = AmbiguousFieldOcc GhcPs
-> GenLocated SrcSpanAnnA (AmbiguousFieldOcc GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (AmbiguousFieldOcc GhcPs
 -> GenLocated SrcSpanAnnA (AmbiguousFieldOcc GhcPs))
-> AmbiguousFieldOcc GhcPs
-> GenLocated SrcSpanAnnA (AmbiguousFieldOcc GhcPs)
forall a b. (a -> b) -> a -> b
$ XAmbiguous GhcPs -> XRec GhcPs RdrName -> AmbiguousFieldOcc GhcPs
forall pass.
XAmbiguous pass -> XRec pass RdrName -> AmbiguousFieldOcc pass
Ambiguous XAmbiguous GhcPs
NoExtField
NoExtField HsQName
XRec GhcPs RdrName
nm
#endif
    , hfbRHS :: LocatedA (HsExpr GhcPs)
hfbRHS = LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
val
    , hfbPun :: Bool
hfbPun = Bool
False
    }
#else
  HsRecField
    { hsRecFieldAnn = synDef
    , hsRecFieldLbl = noLoc $ Ambiguous NoExtField nm
    , hsRecFieldArg = val
    , hsRecPun = False
    }
#endif

recordUpd_ :: HsExp -> [ LHsRecUpdField GhcPs
#if MIN_VERSION_ghc_lib_parser(9,8,0)
                                              GhcPs
#endif
                       ] -> HsExp
recordUpd_ :: LHsExpr GhcPs -> [LHsRecUpdField GhcPs GhcPs] -> LHsExpr GhcPs
recordUpd_ LHsExpr GhcPs
r [LHsRecUpdField GhcPs GhcPs]
fields = HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA RecordUpd
  { rupd_ext :: XRecordUpd GhcPs
rupd_ext = [AddEpAnn]
XRecordUpd GhcPs
forall a. SyntaxDefault a => a
synDef
  , rupd_expr :: LHsExpr GhcPs
rupd_expr = LHsExpr GhcPs
r
  , rupd_flds :: LHsRecUpdFields GhcPs
rupd_flds =
#if MIN_VERSION_ghc_lib_parser(9,8,0)
      XLHsRecUpdLabels GhcPs
-> [LHsRecUpdField GhcPs GhcPs] -> LHsRecUpdFields GhcPs
forall p.
XLHsRecUpdLabels p -> [LHsRecUpdField p p] -> LHsRecUpdFields p
RegularRecUpdFields XLHsRecUpdLabels GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef
#else
      Left
#endif
        [LHsRecUpdField GhcPs GhcPs]
fields
  }

protobufType_, primType_, protobufStringType_, protobufBytesType_ :: String -> HsType
protobufType_ :: String -> HsType
protobufType_ = HsQName -> HsType
GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (HsType GhcPs)
typeNamed_ (GenLocated SrcSpanAnnN RdrName
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (String -> GenLocated SrcSpanAnnN RdrName)
-> String
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpace -> String -> HsQName
protobufName NameSpace
tcName
primType_ :: String -> HsType
primType_ = HsQName -> HsType
GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (HsType GhcPs)
typeNamed_ (GenLocated SrcSpanAnnN RdrName
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (String -> GenLocated SrcSpanAnnN RdrName)
-> String
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpace -> String -> HsQName
haskellName NameSpace
tcName
protobufStringType_ :: String -> HsType
protobufStringType_ = HsType -> HsType -> HsType
tyApp (String -> HsType
protobufType_ String
"String") (GenLocated SrcSpanAnnA (HsType GhcPs)
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (String -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> String
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsQName -> HsType
GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (HsType GhcPs)
typeNamed_ (GenLocated SrcSpanAnnN RdrName
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (String -> GenLocated SrcSpanAnnN RdrName)
-> String
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpace -> String -> HsQName
haskellName NameSpace
tcName
protobufBytesType_ :: String -> HsType
protobufBytesType_ = HsType -> HsType -> HsType
tyApp (String -> HsType
protobufType_ String
"Bytes") (GenLocated SrcSpanAnnA (HsType GhcPs)
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (String -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> String
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsQName -> HsType
GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (HsType GhcPs)
typeNamed_ (GenLocated SrcSpanAnnN RdrName
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (String -> GenLocated SrcSpanAnnN RdrName)
-> String
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpace -> String -> HsQName
haskellName NameSpace
tcName

protobufFixedType_, protobufSignedType_, protobufWrappedType_ :: HsType -> HsType
protobufFixedType_ :: HsType -> HsType
protobufFixedType_ = HsType -> HsType -> HsType
tyApp (String -> HsType
protobufType_ String
"Fixed")
protobufSignedType_ :: HsType -> HsType
protobufSignedType_ = HsType -> HsType -> HsType
tyApp (String -> HsType
protobufType_ String
"Signed")
protobufWrappedType_ :: HsType -> HsType
protobufWrappedType_ = HsType -> HsType -> HsType
tyApp (String -> HsType
protobufType_ String
"Wrapped")

typeNamed_ :: HsName -> HsType
typeNamed_ :: HsQName -> HsType
typeNamed_ nm :: HsQName
nm@(L SrcSpanAnnN
_ RdrName
r) = HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs)
forall a b. (a -> b) -> a -> b
$ XTyVar GhcPs -> PromotionFlag -> HsQName -> HsType GhcPs
forall pass.
XTyVar pass -> PromotionFlag -> LIdP pass -> HsType pass
GHC.HsTyVar [AddEpAnn]
XTyVar GhcPs
forall a. SyntaxDefault a => a
synDef PromotionFlag
promotion HsQName
nm
  where
    promotion :: PromotionFlag
promotion
      | RdrName -> NameSpace
rdrNameSpace RdrName
r NameSpace -> NameSpace -> Bool
forall a. Eq a => a -> a -> Bool
== NameSpace
dataName = PromotionFlag
IsPromoted
      | Bool
otherwise = PromotionFlag
NotPromoted

type_ :: String -> HsType
type_ :: String -> HsType
type_ = HsQName -> HsType
GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (HsType GhcPs)
typeNamed_ (GenLocated SrcSpanAnnN RdrName
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (String -> GenLocated SrcSpanAnnN RdrName)
-> String
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpace -> String -> HsQName
unqual_ NameSpace
tcName

tvarn_ :: String -> HsName
tvarn_ :: String -> HsQName
tvarn_ = NameSpace -> String -> HsQName
unqual_ NameSpace
tvName

tvar_ :: String -> HsType
tvar_ :: String -> HsType
tvar_ = HsQName -> HsType
GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnA (HsType GhcPs)
typeNamed_ (GenLocated SrcSpanAnnN RdrName
 -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (String -> GenLocated SrcSpanAnnN RdrName)
-> String
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> HsQName
String -> GenLocated SrcSpanAnnN RdrName
tvarn_

kindSig_ :: HsType -> HsType -> HsType
kindSig_ :: HsType -> HsType -> HsType
kindSig_ HsType
ty = HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (GenLocated SrcSpanAnnA (HsType GhcPs) -> HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XKindSig GhcPs -> HsType -> HsType -> HsType GhcPs
forall pass.
XKindSig pass -> LHsType pass -> LHsType pass -> HsType pass
GHC.HsKindSig [AddEpAnn]
XKindSig GhcPs
forall a. SyntaxDefault a => a
synDef HsType
ty

tupleType_ :: [HsType] -> HsType
tupleType_ :: [HsType] -> HsType
tupleType_ = HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> ([GenLocated SrcSpanAnnA (HsType GhcPs)] -> HsType GhcPs)
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XTupleTy GhcPs -> HsTupleSort -> [HsType] -> HsType GhcPs
forall pass.
XTupleTy pass -> HsTupleSort -> [LHsType pass] -> HsType pass
GHC.HsTupleTy XTupleTy GhcPs
AnnParen
forall a. SyntaxDefault a => a
synDef HsTupleSort
HsBoxedOrConstraintTuple

patVar :: String -> HsPat
patVar :: String -> HsPat
patVar = Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs))
-> (String -> Pat GhcPs)
-> String
-> GenLocated SrcSpanAnnA (Pat GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XVarPat GhcPs -> HsQName -> Pat GhcPs
forall p. XVarPat p -> LIdP p -> Pat p
VarPat XVarPat GhcPs
NoExtField
NoExtField (GenLocated SrcSpanAnnN RdrName -> Pat GhcPs)
-> (String -> GenLocated SrcSpanAnnN RdrName)
-> String
-> Pat GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NameSpace -> String -> HsQName
unqual_ NameSpace
varName

conPat :: HsQName -> [HsPat] -> HsPat
conPat :: HsQName -> [HsPat] -> HsPat
conPat (L SrcSpanAnnN
_ RdrName
ctor) = RdrName -> [HsPat] -> HsPat
nlConPat RdrName
ctor

recPat :: HsQName -> [LHsRecField GhcPs HsPat] -> HsPat
recPat :: HsQName -> [LHsRecField GhcPs HsPat] -> HsPat
recPat HsQName
ctor [LHsRecField GhcPs HsPat]
fields = Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs))
-> Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs)
forall a b. (a -> b) -> a -> b
$ XConPat GhcPs
-> XRec GhcPs (ConLikeP GhcPs)
-> HsConPatDetails GhcPs
-> Pat GhcPs
forall p.
XConPat p -> XRec p (ConLikeP p) -> HsConPatDetails p -> Pat p
ConPat [AddEpAnn]
XConPat GhcPs
forall a. SyntaxDefault a => a
synDef HsQName
XRec GhcPs (ConLikeP GhcPs)
ctor (HsConPatDetails GhcPs -> Pat GhcPs)
-> HsConPatDetails GhcPs -> Pat GhcPs
forall a b. (a -> b) -> a -> b
$ HsRecFields GhcPs HsPat -> HsConPatDetails GhcPs
forall tyarg arg rec. rec -> HsConDetails tyarg arg rec
RecCon (HsRecFields GhcPs HsPat -> HsConPatDetails GhcPs)
-> HsRecFields GhcPs HsPat -> HsConPatDetails GhcPs
forall a b. (a -> b) -> a -> b
$ HsRecFields
  { rec_flds :: [LHsRecField GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))]
rec_flds = [LHsRecField GhcPs HsPat]
[LHsRecField GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))]
fields
  , rec_dotdot :: Maybe (XRec GhcPs RecFieldsDotDot)
rec_dotdot = Maybe (XRec GhcPs RecFieldsDotDot)
Maybe (GenLocated EpaLocation RecFieldsDotDot)
forall a. Maybe a
Nothing
#if MIN_VERSION_ghc_lib_parser(9,12,0)
  , rec_ext = NoExtField
#endif
  }

fieldPunPat :: HsName -> LHsRecField GhcPs HsPat
fieldPunPat :: HsQName -> LHsRecField GhcPs HsPat
fieldPunPat HsQName
nm = HsFieldBind
  (GenLocated SrcSpanAnnA (FieldOcc GhcPs))
  (GenLocated SrcSpanAnnA (Pat GhcPs))
-> GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated SrcSpanAnnA (FieldOcc GhcPs))
        (GenLocated SrcSpanAnnA (Pat GhcPs)))
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA
#if MIN_VERSION_ghc_lib_parser(9,4,0)
  HsFieldBind
    { hfbAnn :: XHsFieldBind (GenLocated SrcSpanAnnA (FieldOcc GhcPs))
hfbAnn = [AddEpAnn]
XHsFieldBind (GenLocated SrcSpanAnnA (FieldOcc GhcPs))
forall a. SyntaxDefault a => a
synDef
    , hfbLHS :: GenLocated SrcSpanAnnA (FieldOcc GhcPs)
hfbLHS = FieldOcc GhcPs -> GenLocated SrcSpanAnnA (FieldOcc GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (FieldOcc GhcPs -> GenLocated SrcSpanAnnA (FieldOcc GhcPs))
-> FieldOcc GhcPs -> GenLocated SrcSpanAnnA (FieldOcc GhcPs)
forall a b. (a -> b) -> a -> b
$ XCFieldOcc GhcPs -> XRec GhcPs RdrName -> FieldOcc GhcPs
forall pass. XCFieldOcc pass -> XRec pass RdrName -> FieldOcc pass
FieldOcc XCFieldOcc GhcPs
NoExtField
NoExtField HsQName
XRec GhcPs RdrName
nm
    , hfbRHS :: GenLocated SrcSpanAnnA (Pat GhcPs)
hfbRHS = Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs))
-> Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs)
forall a b. (a -> b) -> a -> b
$ XVarPat GhcPs -> HsQName -> Pat GhcPs
forall p. XVarPat p -> LIdP p -> Pat p
VarPat XVarPat GhcPs
NoExtField
NoExtField HsQName
nm
    , hfbPun :: Bool
hfbPun = Bool
True
    }
#else
  HsRecField
    { hsRecFieldAnn = synDef
    , hsRecFieldLbl = noLoc $ FieldOcc NoExtField nm
    , hsRecFieldArg = noLocA $ VarPat NoExtField nm
    , hsRecPun = True
    }
#endif

alt_ :: HsPat -> HsExp -> HsAlt
alt_ :: HsPat -> LHsExpr GhcPs -> LMatch GhcPs (LHsExpr GhcPs)
alt_ = HsPat -> LHsExpr GhcPs -> LMatch GhcPs (LHsExpr GhcPs)
HsPat
-> LocatedA (HsExpr GhcPs)
-> LMatch GhcPs (LocatedA (HsExpr GhcPs))
forall (p :: Pass) (body :: * -> *).
(Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
 ~ EpAnn NoEpAnns,
 Anno (Match (GhcPass p) (LocatedA (body (GhcPass p))))
 ~ SrcSpanAnnA) =>
LPat (GhcPass p)
-> LocatedA (body (GhcPass p))
-> LMatch (GhcPass p) (LocatedA (body (GhcPass p)))
mkHsCaseAlt

case_ :: HsExp -> [HsAlt] -> HsExp
case_ :: LHsExpr GhcPs -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsExpr GhcPs
case_ LHsExpr GhcPs
e = HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsExpr GhcPs -> LocatedA (HsExpr GhcPs))
-> ([GenLocated
       SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
    -> HsExpr GhcPs)
-> [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
-> LocatedA (HsExpr GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XCase GhcPs
-> LHsExpr GhcPs
-> MatchGroup GhcPs (LHsExpr GhcPs)
-> HsExpr GhcPs
forall p.
XCase p -> LHsExpr p -> MatchGroup p (LHsExpr p) -> HsExpr p
HsCase XCase GhcPs
EpAnnHsCase
forall a. SyntaxDefault a => a
synDef LHsExpr GhcPs
e (MatchGroup GhcPs (LocatedA (HsExpr GhcPs)) -> HsExpr GhcPs)
-> ([GenLocated
       SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
    -> MatchGroup GhcPs (LocatedA (HsExpr GhcPs)))
-> [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
-> HsExpr GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Origin
-> LocatedL
     [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
-> MatchGroup GhcPs (LocatedA (HsExpr GhcPs))
forall (p :: Pass) (body :: * -> *).
AnnoBody p body =>
Origin
-> LocatedL
     [LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
-> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
mkMatchGroup Origin
generated (LocatedL
   [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
 -> MatchGroup GhcPs (LocatedA (HsExpr GhcPs)))
-> ([GenLocated
       SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
    -> LocatedL
         [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))])
-> [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
-> MatchGroup GhcPs (LocatedA (HsExpr GhcPs))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
-> LocatedL
     [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsExpr GhcPs)))]
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA
  where
    generated :: Origin
    generated :: Origin
generated = GenReason -> DoPmc -> Origin
Generated
#if MIN_VERSION_ghc_lib_parser(9,10,0)
                          GenReason
OtherExpansion
#endif
#if MIN_VERSION_ghc_lib_parser(9,8,0)
                                         DoPmc
DoPmc
#endif

-- | Simple let expression for ordinary bindings.
let_ :: [HsBind] -> HsExp -> HsExp
let_ :: [HsBind] -> LHsExpr GhcPs -> LHsExpr GhcPs
let_ [HsBind]
locals LHsExpr GhcPs
e =
#if MIN_VERSION_ghc_lib_parser(9,10,0)
    HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsExpr GhcPs -> LocatedA (HsExpr GhcPs))
-> HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall a b. (a -> b) -> a -> b
$ XLet GhcPs -> HsLocalBinds GhcPs -> LHsExpr GhcPs -> HsExpr GhcPs
forall p. XLet p -> HsLocalBinds p -> LHsExpr p -> HsExpr p
HsLet (EpToken "let", EpToken "in")
XLet GhcPs
forall a. SyntaxDefault a => a
synDef HsLocalBinds GhcPs
binds LHsExpr GhcPs
e
#elif MIN_VERSION_ghc_lib_parser(9,4,0)
    noLocA $ HsLet synDef synDef binds synDef e
#else
    noLocA $ HsLet synDef binds e
#endif
  where
#if MIN_VERSION_ghc_lib_parser(9,12,0)
    binds = HsValBinds synDef (ValBinds synDef locals [])
#else
    binds :: HsLocalBinds GhcPs
binds = XHsValBinds GhcPs GhcPs
-> HsValBindsLR GhcPs GhcPs -> HsLocalBinds GhcPs
forall idL idR.
XHsValBinds idL idR
-> HsValBindsLR idL idR -> HsLocalBindsLR idL idR
HsValBinds XHsValBinds GhcPs GhcPs
forall a. SyntaxDefault a => a
synDef (XValBinds GhcPs GhcPs
-> LHsBinds GhcPs -> [LSig GhcPs] -> HsValBindsLR GhcPs GhcPs
forall idL idR.
XValBinds idL idR
-> LHsBindsLR idL idR -> [LSig idR] -> HsValBindsLR idL idR
ValBinds XValBinds GhcPs GhcPs
forall a. SyntaxDefault a => a
synDef ([HsBind] -> LHsBinds GhcPs
forall a. [a] -> Bag a
listToBag [HsBind]
locals) [])
#endif

-- | Lambda abstraction.
lambda_ :: [HsPat] -> HsExp -> HsExp
#if MIN_VERSION_ghc_lib_parser(9,12,0)
lambda_ = mkHsLam . noLocA
#else
lambda_ :: [HsPat] -> LHsExpr GhcPs -> LHsExpr GhcPs
lambda_ = [HsPat] -> LHsExpr GhcPs -> LHsExpr GhcPs
forall (p :: Pass).
(IsPass p, XMG (GhcPass p) (LHsExpr (GhcPass p)) ~ Origin) =>
[LPat (GhcPass p)] -> LHsExpr (GhcPass p) -> LHsExpr (GhcPass p)
mkHsLam
#endif

if_ :: HsExp -> HsExp -> HsExp -> HsExp
if_ :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
if_ LHsExpr GhcPs
c LHsExpr GhcPs
t LHsExpr GhcPs
f = HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsExpr GhcPs -> LocatedA (HsExpr GhcPs))
-> HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall a b. (a -> b) -> a -> b
$ LHsExpr GhcPs
-> LHsExpr GhcPs -> LHsExpr GhcPs -> AnnsIf -> HsExpr GhcPs
mkHsIf LHsExpr GhcPs
c LHsExpr GhcPs
t LHsExpr GhcPs
f AnnsIf
forall a. SyntaxDefault a => a
synDef

-- | A boxed tuple with all components present.
tuple_ :: [HsExp] -> HsExp
#if MIN_VERSION_ghc_lib_parser(9,12,0)
tuple_ xs = mkLHsTupleExpr xs noAnn
#else
tuple_ :: [LHsExpr GhcPs] -> LHsExpr GhcPs
tuple_ [LHsExpr GhcPs]
xs = [LHsExpr GhcPs] -> XExplicitTuple GhcPs -> LHsExpr GhcPs
forall (p :: Pass).
[LHsExpr (GhcPass p)]
-> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p)
mkLHsTupleExpr [LHsExpr GhcPs]
xs [AddEpAnn]
XExplicitTuple GhcPs
forall a. SyntaxDefault a => a
synDef
#endif

-- | A promoted boxed tuple value with all components present.
tupleT_ :: [HsType] -> HsType
tupleT_ :: [HsType] -> HsType
tupleT_ = HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> ([GenLocated SrcSpanAnnA (HsType GhcPs)] -> HsType GhcPs)
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XExplicitTupleTy GhcPs -> [HsType] -> HsType GhcPs
forall pass. XExplicitTupleTy pass -> [LHsType pass] -> HsType pass
HsExplicitTupleTy [AddEpAnn]
XExplicitTupleTy GhcPs
forall a. SyntaxDefault a => a
synDef
#if MIN_VERSION_ghc_lib_parser(9,12,0)
                          NotPromoted
#endif

list_ :: [HsExp] -> HsExp
list_ :: [LHsExpr GhcPs] -> LHsExpr GhcPs
list_ = [LHsExpr GhcPs] -> LHsExpr GhcPs
nlList

listT_ :: [HsType] -> HsType
listT_ :: [HsType] -> HsType
listT_ = HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> ([GenLocated SrcSpanAnnA (HsType GhcPs)] -> HsType GhcPs)
-> [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XExplicitListTy GhcPs -> PromotionFlag -> [HsType] -> HsType GhcPs
forall pass.
XExplicitListTy pass
-> PromotionFlag -> [LHsType pass] -> HsType pass
HsExplicitListTy [AddEpAnn]
XExplicitListTy GhcPs
forall a. SyntaxDefault a => a
synDef PromotionFlag
IsPromoted

str_ :: String -> HsExp
str_ :: String -> LHsExpr GhcPs
str_ = HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsExpr GhcPs -> LocatedA (HsExpr GhcPs))
-> (String -> HsExpr GhcPs) -> String -> LocatedA (HsExpr GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XLitE GhcPs -> HsLit GhcPs -> HsExpr GhcPs
forall p. XLitE p -> HsLit p -> HsExpr p
HsLit XLitE GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef (HsLit GhcPs -> HsExpr GhcPs)
-> (String -> HsLit GhcPs) -> String -> HsExpr GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> HsLit GhcPs
forall (p :: Pass). String -> HsLit (GhcPass p)
mkHsString

strPat :: String -> HsPat
strPat :: String -> HsPat
strPat = Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs))
-> (String -> Pat GhcPs)
-> String
-> GenLocated SrcSpanAnnA (Pat GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XLitPat GhcPs -> HsLit GhcPs -> Pat GhcPs
forall p. XLitPat p -> HsLit p -> Pat p
LitPat XLitPat GhcPs
NoExtField
NoExtField (HsLit GhcPs -> Pat GhcPs)
-> (String -> HsLit GhcPs) -> String -> Pat GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XHsString GhcPs -> FastString -> HsLit GhcPs
forall x. XHsString x -> FastString -> HsLit x
HsString XHsString GhcPs
SourceText
NoSourceText (FastString -> HsLit GhcPs)
-> (String -> FastString) -> String -> HsLit GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> FastString
mkFastString

symT :: String -> HsType
symT :: String -> HsType
symT = HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (String -> HsType GhcPs)
-> String
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XTyLit GhcPs -> HsTyLit GhcPs -> HsType GhcPs
forall pass. XTyLit pass -> HsTyLit pass -> HsType pass
HsTyLit XTyLit GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef (HsTyLit GhcPs -> HsType GhcPs)
-> (String -> HsTyLit GhcPs) -> String -> HsType GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XStrTy GhcPs -> FastString -> HsTyLit GhcPs
forall pass. XStrTy pass -> FastString -> HsTyLit pass
HsStrTy XStrTy GhcPs
SourceText
NoSourceText (FastString -> HsTyLit GhcPs)
-> (String -> FastString) -> String -> HsTyLit GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> FastString
mkFastString

--------------------------------------------------------------------------------
--
-- * Common Haskell expressions, constructors, and operators
--

nothingN, justN :: HsQName

dotProtoFieldC, primC, optionalC, repeatedC, nestedRepeatedC, namedC, mapC,
  fieldNumberC, singleC, dotsC, pathC, qualifiedC, anonymousC, dotProtoOptionC,
  identifierC, stringLitC, intLitC, floatLitC, boolLitC, trueC, falseC, nothingC,
  justC, forceEmitC, encodeMessageFieldE, fromStringE, decodeMessageFieldE,
  pureE, returnE, mappendE, memptyE, msumE, atE, oneofE, fmapE :: HsExp

forceEmitT, justT, maybeT, nothingT, natT, symbolT, typeErrorT :: HsType

dotProtoFieldC :: LHsExpr GhcPs
dotProtoFieldC       = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
tcName String
"DotProtoField")
primC :: LHsExpr GhcPs
primC                = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"Prim")
optionalC :: LHsExpr GhcPs
optionalC            = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"Optional")
repeatedC :: LHsExpr GhcPs
repeatedC            = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"Repeated")
nestedRepeatedC :: LHsExpr GhcPs
nestedRepeatedC      = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"NestedRepeated")
namedC :: LHsExpr GhcPs
namedC               = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
tcName String
"Named")
mapC :: LHsExpr GhcPs
mapC                 = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName  String
"Map")
fieldNumberC :: LHsExpr GhcPs
fieldNumberC         = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufName NameSpace
dataName String
"FieldNumber")
singleC :: LHsExpr GhcPs
singleC              = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"Single")
pathC :: LHsExpr GhcPs
pathC                = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"Path")
dotsC :: LHsExpr GhcPs
dotsC                = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"Dots")
qualifiedC :: LHsExpr GhcPs
qualifiedC           = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"Qualified")
anonymousC :: LHsExpr GhcPs
anonymousC           = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"Anonymous")
dotProtoOptionC :: LHsExpr GhcPs
dotProtoOptionC      = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
tcName String
"DotProtoOption")
identifierC :: LHsExpr GhcPs
identifierC          = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"Identifier")
stringLitC :: LHsExpr GhcPs
stringLitC           = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"StringLit")
intLitC :: LHsExpr GhcPs
intLitC              = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"IntLit")
floatLitC :: LHsExpr GhcPs
floatLitC            = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"FloatLit")
boolLitC :: LHsExpr GhcPs
boolLitC             = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufASTName NameSpace
dataName String
"BoolLit")
forceEmitC :: LHsExpr GhcPs
forceEmitC           = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufName NameSpace
dataName String
"ForceEmit")
forceEmitT :: HsType
forceEmitT           = String -> HsType
protobufType_ String
"ForceEmit"
encodeMessageFieldE :: LHsExpr GhcPs
encodeMessageFieldE  = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufName NameSpace
varName String
"encodeMessageField")
decodeMessageFieldE :: LHsExpr GhcPs
decodeMessageFieldE  = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufName NameSpace
varName String
"decodeMessageField")
atE :: LHsExpr GhcPs
atE                  = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufName NameSpace
varName String
"at")
oneofE :: LHsExpr GhcPs
oneofE               = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
protobufName NameSpace
varName String
"oneof")

trueC :: LHsExpr GhcPs
trueC                = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
dataName String
"True")
falseC :: LHsExpr GhcPs
falseC               = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
dataName String
"False")
nothingC :: LHsExpr GhcPs
nothingC             = HsQName -> LHsExpr GhcPs
var_ HsQName
nothingN
nothingN :: HsQName
nothingN             = NameSpace -> String -> HsQName
haskellName NameSpace
dataName String
"Nothing"
nothingT :: HsType
nothingT             = HsQName -> HsType
typeNamed_ (NameSpace -> String -> HsQName
haskellName NameSpace
tcName String
"Nothing")
justC :: LHsExpr GhcPs
justC                = HsQName -> LHsExpr GhcPs
var_ HsQName
justN
justN :: HsQName
justN                =       NameSpace -> String -> HsQName
haskellName NameSpace
dataName String
"Just"
justT :: HsType
justT                = HsQName -> HsType
typeNamed_ (NameSpace -> String -> HsQName
haskellName NameSpace
tcName String
"Just")
maybeT :: HsType
maybeT               = HsQName -> HsType
typeNamed_ (NameSpace -> String -> HsQName
haskellName NameSpace
tcName String
"Maybe")
fromStringE :: LHsExpr GhcPs
fromStringE          = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
"fromString")
pureE :: LHsExpr GhcPs
pureE                = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
"pure")
returnE :: LHsExpr GhcPs
returnE              = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
"return")
mappendE :: LHsExpr GhcPs
mappendE             = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
"mappend")
memptyE :: LHsExpr GhcPs
memptyE              = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
"mempty")
msumE :: LHsExpr GhcPs
msumE                = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
"msum")
fmapE :: LHsExpr GhcPs
fmapE                = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
"fmap")
natT :: HsType
natT                 = HsQName -> HsType
typeNamed_ (NameSpace -> String -> HsQName
haskellName NameSpace
tcName String
"Nat")
symbolT :: HsType
symbolT              = HsQName -> HsType
typeNamed_ (NameSpace -> String -> HsQName
haskellName NameSpace
tcName String
"Symbol")
typeErrorT :: HsType
typeErrorT           = HsQName -> HsType
typeNamed_ (NameSpace -> String -> HsQName
haskellName NameSpace
tcName String
"TypeError")

apOp :: HsQOp
apOp :: LHsExpr GhcPs
apOp  = String -> LHsExpr GhcPs
uvar_ String
"<*>"

fmapOp :: HsQOp
fmapOp :: LHsExpr GhcPs
fmapOp  = String -> LHsExpr GhcPs
uvar_ String
"<$>"

composeOp :: HsQOp
composeOp :: LHsExpr GhcPs
composeOp = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
".")

fractionOp :: HsQOp
fractionOp :: LHsExpr GhcPs
fractionOp = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
"/")

bindOp :: HsQOp
bindOp :: LHsExpr GhcPs
bindOp = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
">>=")

altOp :: HsQOp
altOp :: LHsExpr GhcPs
altOp = String -> LHsExpr GhcPs
uvar_ String
"<|>"

toJSONPBOp :: HsQOp
toJSONPBOp :: LHsExpr GhcPs
toJSONPBOp = String -> LHsExpr GhcPs
uvar_ String
".="

parseJSONPBOp :: HsQOp
parseJSONPBOp :: LHsExpr GhcPs
parseJSONPBOp = String -> LHsExpr GhcPs
uvar_ String
".:"

neConsOp :: HsQOp
neConsOp :: LHsExpr GhcPs
neConsOp = HsQName -> LHsExpr GhcPs
var_ (NameSpace -> String -> HsQName
haskellName NameSpace
varName String
":|")

intE :: Integral a => a -> HsExp
intE :: forall a. Integral a => a -> LHsExpr GhcPs
intE a
x = HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsExpr GhcPs -> LocatedA (HsExpr GhcPs))
-> HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall a b. (a -> b) -> a -> b
$ XOverLitE GhcPs -> HsOverLit GhcPs -> HsExpr GhcPs
forall p. XOverLitE p -> HsOverLit p -> HsExpr p
HsOverLit XOverLitE GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef (HsOverLit GhcPs -> HsExpr GhcPs)
-> HsOverLit GhcPs -> HsExpr GhcPs
forall a b. (a -> b) -> a -> b
$ IntegralLit -> HsOverLit GhcPs
mkHsIntegral (IntegralLit -> HsOverLit GhcPs) -> IntegralLit -> HsOverLit GhcPs
forall a b. (a -> b) -> a -> b
$ IL
  { il_text :: SourceText
il_text = SourceText
NoSourceText
  , il_neg :: Bool
il_neg = a
x a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
0
  , il_value :: Integer
il_value = a -> Integer
forall a. Integral a => a -> Integer
toInteger a
x
  }

intP :: Integral a => a -> HsPat
intP :: forall a. Integral a => a -> HsPat
intP a
x = Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs))
-> Pat GhcPs -> GenLocated SrcSpanAnnA (Pat GhcPs)
forall a b. (a -> b) -> a -> b
$ XNPat GhcPs
-> XRec GhcPs (HsOverLit GhcPs)
-> Maybe (SyntaxExpr GhcPs)
-> SyntaxExpr GhcPs
-> Pat GhcPs
forall p.
XNPat p
-> XRec p (HsOverLit p)
-> Maybe (SyntaxExpr p)
-> SyntaxExpr p
-> Pat p
NPat [AddEpAnn]
XNPat GhcPs
forall a. SyntaxDefault a => a
synDef XRec GhcPs (HsOverLit GhcPs)
GenLocated (EpAnn NoEpAnns) (HsOverLit GhcPs)
overlit Maybe NoExtField
Maybe (SyntaxExpr GhcPs)
forall a. Maybe a
Nothing NoExtField
SyntaxExpr GhcPs
NoExtField
  where
    overlit :: GenLocated (EpAnn NoEpAnns) (HsOverLit GhcPs)
overlit = EpAnn NoEpAnns
-> HsOverLit GhcPs -> GenLocated (EpAnn NoEpAnns) (HsOverLit GhcPs)
forall l e. l -> e -> GenLocated l e
L EpAnn NoEpAnns
forall a. SyntaxDefault a => a
synDef (HsOverLit GhcPs -> GenLocated (EpAnn NoEpAnns) (HsOverLit GhcPs))
-> HsOverLit GhcPs -> GenLocated (EpAnn NoEpAnns) (HsOverLit GhcPs)
forall a b. (a -> b) -> a -> b
$ IntegralLit -> HsOverLit GhcPs
mkHsIntegral (IntegralLit -> HsOverLit GhcPs) -> IntegralLit -> HsOverLit GhcPs
forall a b. (a -> b) -> a -> b
$ IL
      { il_text :: SourceText
il_text = SourceText
NoSourceText
      , il_neg :: Bool
il_neg = a
x a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
0
      , il_value :: Integer
il_value = a -> Integer
forall a. Integral a => a -> Integer
toInteger a
x
      }

natTLit :: Integral a => a -> HsType
natTLit :: forall a. Integral a => a -> HsType
natTLit = HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsType GhcPs -> GenLocated SrcSpanAnnA (HsType GhcPs))
-> (a -> HsType GhcPs)
-> a
-> GenLocated SrcSpanAnnA (HsType GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XTyLit GhcPs -> HsTyLit GhcPs -> HsType GhcPs
forall pass. XTyLit pass -> HsTyLit pass -> HsType pass
HsTyLit XTyLit GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef (HsTyLit GhcPs -> HsType GhcPs)
-> (a -> HsTyLit GhcPs) -> a -> HsType GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XNumTy GhcPs -> Integer -> HsTyLit GhcPs
forall pass. XNumTy pass -> Integer -> HsTyLit pass
HsNumTy XNumTy GhcPs
SourceText
NoSourceText (Integer -> HsTyLit GhcPs) -> (a -> Integer) -> a -> HsTyLit GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Integer
forall a. Integral a => a -> Integer
toInteger

floatE :: forall f . RealFloat f => f -> HsExp
floatE :: forall f. RealFloat f => f -> LHsExpr GhcPs
floatE f
x
    | f -> Bool
forall a. RealFloat a => a -> Bool
isNaN f
x = LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
opApp LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
zero LHsExpr GhcPs
fractionOp LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
zero
    | f -> Bool
forall a. RealFloat a => a -> Bool
isInfinite f
x = LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs
opApp (if f
x f -> f -> Bool
forall a. Ord a => a -> a -> Bool
< f
0 then LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
minusOne else LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
plusOne) LHsExpr GhcPs
fractionOp LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
zero
    | Bool
otherwise = f -> LocatedA (HsExpr GhcPs)
forall {a} {e}.
(RealFloat a, HasAnnotation e) =>
a -> GenLocated e (HsExpr GhcPs)
scientific f
x
  where
    zero :: LocatedA (HsExpr GhcPs)
zero = f -> LocatedA (HsExpr GhcPs)
forall {a} {e}.
(RealFloat a, HasAnnotation e) =>
a -> GenLocated e (HsExpr GhcPs)
scientific (f
0 :: f)
    minusOne :: LocatedA (HsExpr GhcPs)
minusOne = f -> LocatedA (HsExpr GhcPs)
forall {a} {e}.
(RealFloat a, HasAnnotation e) =>
a -> GenLocated e (HsExpr GhcPs)
scientific (f
-1 :: f)
    plusOne :: LocatedA (HsExpr GhcPs)
plusOne = f -> LocatedA (HsExpr GhcPs)
forall {a} {e}.
(RealFloat a, HasAnnotation e) =>
a -> GenLocated e (HsExpr GhcPs)
scientific (f
1 :: f)
    scientific :: a -> GenLocated e (HsExpr GhcPs)
scientific a
y = HsExpr GhcPs -> GenLocated e (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsExpr GhcPs -> GenLocated e (HsExpr GhcPs))
-> HsExpr GhcPs -> GenLocated e (HsExpr GhcPs)
forall a b. (a -> b) -> a -> b
$ XOverLitE GhcPs -> HsOverLit GhcPs -> HsExpr GhcPs
forall p. XOverLitE p -> HsOverLit p -> HsExpr p
HsOverLit XOverLitE GhcPs
NoExtField
forall a. SyntaxDefault a => a
synDef HsOverLit GhcPs
overlit
      where
        (Integer
_s, Int
_e) = a -> (Integer, Int)
forall a. RealFloat a => a -> (Integer, Int)
decodeFloat (a -> a
forall a. Num a => a -> a
abs a
y)
        overlit :: HsOverLit GhcPs
overlit = FractionalLit -> HsOverLit GhcPs
mkHsFractional (FractionalLit -> HsOverLit GhcPs)
-> FractionalLit -> HsOverLit GhcPs
forall a b. (a -> b) -> a -> b
$ FL
          { fl_text :: SourceText
fl_text = SourceText
NoSourceText
          , fl_neg :: Bool
fl_neg = a
y a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
0
          , fl_signi :: Rational
fl_signi = Integer
_s Integer -> Integer -> Rational
forall a. Integral a => a -> a -> Ratio a
% Integer
1
          , fl_exp :: Integer
fl_exp = Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
_e
          , fl_exp_base :: FractionalExponentBase
fl_exp_base = case a -> Integer
forall a. RealFloat a => a -> Integer
floatRadix a
y of
              Integer
2 -> FractionalExponentBase
Base2
              Integer
10 -> FractionalExponentBase
Base10
              Integer
b -> String -> FractionalExponentBase
forall a. HasCallStack => String -> a
error (String -> FractionalExponentBase)
-> String -> FractionalExponentBase
forall a b. (a -> b) -> a -> b
$ String
"doubleE: unsupported floatRadix " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
b
          }

do_ :: [ExprLStmt GhcPs] -> HsExp
do_ :: [ExprLStmt GhcPs] -> LHsExpr GhcPs
do_ = HsExpr GhcPs -> LocatedA (HsExpr GhcPs)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsExpr GhcPs -> LocatedA (HsExpr GhcPs))
-> ([GenLocated
       SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))]
    -> HsExpr GhcPs)
-> [GenLocated
      SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))]
-> LocatedA (HsExpr GhcPs)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsDoFlavour -> LocatedL [ExprLStmt GhcPs] -> HsExpr GhcPs
mkHsDo (Maybe ModuleName -> HsDoFlavour
DoExpr Maybe ModuleName
forall a. Maybe a
Nothing) (GenLocated
   SrcSpanAnnL
   [GenLocated
      SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))]
 -> HsExpr GhcPs)
-> ([GenLocated
       SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))]
    -> GenLocated
         SrcSpanAnnL
         [GenLocated
            SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))])
-> [GenLocated
      SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))]
-> HsExpr GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [GenLocated
   SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))]
-> GenLocated
     SrcSpanAnnL
     [GenLocated
        SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))]
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA

letStmt_ :: [HsBind] -> ExprLStmt GhcPs
letStmt_ :: [HsBind] -> ExprLStmt GhcPs
letStmt_ [HsBind]
locals = StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
-> GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
 -> GenLocated
      SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))))
-> StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
-> GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
forall a b. (a -> b) -> a -> b
$ XLetStmt GhcPs GhcPs (LocatedA (HsExpr GhcPs))
-> HsLocalBinds GhcPs
-> StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
forall idL idR body.
XLetStmt idL idR body
-> HsLocalBindsLR idL idR -> StmtLR idL idR body
LetStmt [AddEpAnn]
XLetStmt GhcPs GhcPs (LocatedA (HsExpr GhcPs))
forall a. SyntaxDefault a => a
synDef HsLocalBinds GhcPs
binds
  where
#if MIN_VERSION_ghc_lib_parser(9,12,0)
    binds = HsValBinds synDef (ValBinds synDef locals [])
#else
    binds :: HsLocalBinds GhcPs
binds = XHsValBinds GhcPs GhcPs
-> HsValBindsLR GhcPs GhcPs -> HsLocalBinds GhcPs
forall idL idR.
XHsValBinds idL idR
-> HsValBindsLR idL idR -> HsLocalBindsLR idL idR
HsValBinds XHsValBinds GhcPs GhcPs
forall a. SyntaxDefault a => a
synDef (XValBinds GhcPs GhcPs
-> LHsBinds GhcPs -> [LSig GhcPs] -> HsValBindsLR GhcPs GhcPs
forall idL idR.
XValBinds idL idR
-> LHsBindsLR idL idR -> [LSig idR] -> HsValBindsLR idL idR
ValBinds XValBinds GhcPs GhcPs
forall a. SyntaxDefault a => a
synDef ([HsBind] -> LHsBinds GhcPs
forall a. [a] -> Bag a
listToBag [HsBind]
locals) [])
#endif

bindStmt_ :: HsPat -> HsExp -> ExprLStmt GhcPs
bindStmt_ :: HsPat -> LHsExpr GhcPs -> ExprLStmt GhcPs
bindStmt_ HsPat
p LHsExpr GhcPs
e = StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
-> GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
 -> GenLocated
      SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))))
-> StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
-> GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
forall a b. (a -> b) -> a -> b
$ [AddEpAnn]
-> HsPat
-> LocatedA (HsExpr GhcPs)
-> StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
forall (bodyR :: * -> *).
[AddEpAnn]
-> HsPat
-> LocatedA (bodyR GhcPs)
-> StmtLR GhcPs GhcPs (LocatedA (bodyR GhcPs))
mkPsBindStmt [AddEpAnn]
forall a. SyntaxDefault a => a
synDef HsPat
p LHsExpr GhcPs
LocatedA (HsExpr GhcPs)
e

lastStmt_ :: HsExp -> ExprLStmt GhcPs
lastStmt_ :: LHsExpr GhcPs -> ExprLStmt GhcPs
lastStmt_ = StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
-> GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
 -> GenLocated
      SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))))
-> (LocatedA (HsExpr GhcPs)
    -> StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
-> LocatedA (HsExpr GhcPs)
-> GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocatedA (HsExpr GhcPs)
-> StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
forall (idR :: Pass) (bodyR :: * -> *) (idL :: Pass).
IsPass idR =>
LocatedA (bodyR (GhcPass idR))
-> StmtLR
     (GhcPass idL) (GhcPass idR) (LocatedA (bodyR (GhcPass idR)))
mkLastStmt

bodyStmt_ :: HsExp -> ExprLStmt GhcPs
bodyStmt_ :: LHsExpr GhcPs -> ExprLStmt GhcPs
bodyStmt_ = StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
-> GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
 -> GenLocated
      SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))))
-> (LocatedA (HsExpr GhcPs)
    -> StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
-> LocatedA (HsExpr GhcPs)
-> GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocatedA (HsExpr GhcPs)
-> StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs))
forall (bodyR :: * -> *) (idL :: Pass).
LocatedA (bodyR GhcPs)
-> StmtLR (GhcPass idL) GhcPs (LocatedA (bodyR GhcPs))
mkBodyStmt