    -- Copyright (c) 2020-2024, Shayne Fletcher. All rights reserved.
    -- SPDX-License-Identifier: BSD-3-Clause.

    {- ORMOLU_DISABLE -}
    {-# OPTIONS_GHC -Wno-missing-fields #-}
    {-# LANGUAGE LambdaCase #-}
    #include "ghclib_api.h"
    module Language.Haskell.GhclibParserEx.GHC.Hs.Expr(
      isTag, isDol, isDot, isReturn, isSection, isRecConstr, isRecUpdate,
      isVar, isPar, isApp, isOpApp, isAnyApp, isDo, isLexeme, isLambda, isQuasiQuote, isQuasiQuoteExpr, isQuasiQuoteSplice,  isOverLabel,
      isDotApp, isTypeApp, isWHNF, isLCase,
      isFieldPun, isFieldPunUpdate, isRecStmt, isLetStmt, isParComp, isMDo, isListComp, isMonadComp, isTupleSection, isString, isPrimLiteral,
      isSpliceDecl,
    #if !( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
      -- ghc api >= 9.6.1
      isTypedSplice, isUntypedSplice,
    #endif
      isFieldWildcard, isUnboxed, isWholeFrac, isStrictMatch, isMultiIf, isProc, isTransStmt,
      hasFieldsDotDot,
      varToStr, strToVar,
      fromChar
      ) where

    #if defined (GHC_8_8)
    import HsSyn
    import SrcLoc
    import RdrName
    import OccName
    import Name
    import BasicTypes
    import TysWiredIn
    #elif defined (GHC_8_10)
    import GHC.Hs
    import SrcLoc
    import RdrName
    import OccName
    import Name
    import BasicTypes
    import TysWiredIn
    #elif defined (GHC_9_0)
    import GHC.Hs
    import GHC.Types.SrcLoc
    import GHC.Types.Name.Reader
    import GHC.Types.Name
    import GHC.Types.Basic
    import GHC.Builtin.Types
    #elif defined (GHC_9_2) || defined (GHC_9_4)
    import GHC.Hs
    import GHC.Types.SourceText
    import GHC.Types.SrcLoc
    import GHC.Types.Name.Reader
    import GHC.Types.Name
    import GHC.Types.Basic
    import GHC.Builtin.Types
    #else
    import GHC.Hs
    import GHC.Types.SourceText
    import GHC.Types.SrcLoc
    import GHC.Types.Name.Reader
    import GHC.Types.Name
    import GHC.Types.Basic
    import GHC.Builtin.Types
    import Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader
    #endif
    import Data.Ratio

    -- 'True' if the provided expression is a variable with name 'tag'.
    isTag :: String -> LHsExpr GhcPs -> Bool
    isTag :: String -> LHsExpr GhcPs -> Bool
    isTag String
    tag = \case (L SrcSpanAnnA
    _ (HsVar XVar GhcPs
    _ (L SrcSpanAnnN
    _ RdrName
    s))) -> OccName -> String
    occNameString (RdrName -> OccName
    rdrNameOcc RdrName
    s) String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == String
    tag; LHsExpr GhcPs
    _ -> Bool
    False

    isDot, isDol, isReturn, isSection, isRecConstr, isRecUpdate,
      isVar, isPar, isApp, isOpApp, isAnyApp, isDo, isLexeme, isQuasiQuote, isQuasiQuoteExpr,
      isLambda, isDotApp, isTypeApp, isWHNF, isLCase, isOverLabel :: LHsExpr GhcPs -> Bool
    isDol :: LHsExpr GhcPs -> Bool
    isDol = String -> LHsExpr GhcPs -> Bool
    isTag String
    "$"
    isDot :: LHsExpr GhcPs -> Bool
    isDot = String -> LHsExpr GhcPs -> Bool
    isTag String
    "."
    isReturn :: LHsExpr GhcPs -> Bool
    isReturn LHsExpr GhcPs
    x = String -> LHsExpr GhcPs -> Bool
    isTag String
    "return" LHsExpr GhcPs
    x Bool -> Bool -> Bool
    || String -> LHsExpr GhcPs -> Bool
    isTag String
    "pure" LHsExpr GhcPs
    x -- Allow both 'pure' and 'return' as they have the same semantics.
    isSection :: LHsExpr GhcPs -> Bool
    isSection = \case (L SrcSpanAnnA
    _ SectionL{}) -> Bool
    True ; (L SrcSpanAnnA
    _ SectionR{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    isRecConstr :: LHsExpr GhcPs -> Bool
    isRecConstr = \case (L SrcSpanAnnA
    _ RecordCon{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    isRecUpdate :: LHsExpr GhcPs -> Bool
    isRecUpdate = \case (L SrcSpanAnnA
    _ RecordUpd{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    isVar :: LHsExpr GhcPs -> Bool
    isVar = \case (L SrcSpanAnnA
    _ HsVar{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    isPar :: LHsExpr GhcPs -> Bool
    isPar = \case (L SrcSpanAnnA
    _ HsPar{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    isApp :: LHsExpr GhcPs -> Bool
    isApp = \case (L SrcSpanAnnA
    _ HsApp{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    isOpApp :: LHsExpr GhcPs -> Bool
    isOpApp = \case (L SrcSpanAnnA
    _ OpApp{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    isAnyApp :: LHsExpr GhcPs -> Bool
    isAnyApp LHsExpr GhcPs
    x = LHsExpr GhcPs -> Bool
    isApp LHsExpr GhcPs
    x Bool -> Bool -> Bool
    || LHsExpr GhcPs -> Bool
    isOpApp LHsExpr GhcPs
    x
    isDo :: LHsExpr GhcPs -> Bool
    isDo = \case (L SrcSpanAnnA
    _ HsDo{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    isLexeme :: LHsExpr GhcPs -> Bool
    isLexeme = \case (L SrcSpanAnnA
    _ HsVar{}) -> Bool
    True; (L SrcSpanAnnA
    _ HsOverLit{}) -> Bool
    True; (L SrcSpanAnnA
    _ HsLit{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    -- 'isLambda' semantics are match form `\p -> e` exclusively
    #if ! ( defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    --ghc api >= 9.8.1
    isLambda :: LHsExpr GhcPs -> Bool
    isLambda = \case (L SrcSpanAnnA
    _ (HsLam XLam GhcPs
    _ HsLamVariant
    LamSingle MatchGroup GhcPs (LHsExpr GhcPs)
    _)) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    #else
    isLambda = \case (L _ HsLam{}) -> True; _ -> False
    #endif
    #if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.6.1
    isQuasiQuoteExpr :: LHsExpr GhcPs -> Bool
    isQuasiQuoteExpr = \case (L SrcSpanAnnA
    _ (HsUntypedSplice XUntypedSplice GhcPs
    _ HsQuasiQuote{})) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    #else
    -- ghc api < 9.6.1
    isQuasiQuoteExpr = \case (L _ (HsSpliceE _ HsQuasiQuote{})) -> True; _ -> False
    #endif
    isQuasiQuote :: LHsExpr GhcPs -> Bool
    isQuasiQuote = LHsExpr GhcPs -> Bool
    isQuasiQuoteExpr -- Backwards compat.
    isDotApp :: LHsExpr GhcPs -> Bool
    isDotApp = \case (L SrcSpanAnnA
    _ (OpApp XOpApp GhcPs
    _ LHsExpr GhcPs
    _ LHsExpr GhcPs
    op LHsExpr GhcPs
    _)) -> LHsExpr GhcPs -> Bool
    isDot LHsExpr GhcPs
    op; LHsExpr GhcPs
    _ -> Bool
    False
    isTypeApp :: LHsExpr GhcPs -> Bool
    isTypeApp = \case (L SrcSpanAnnA
    _ HsAppType{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    isWHNF :: LHsExpr GhcPs -> Bool
    isWHNF = \case
      (L SrcSpanAnnA
    _ (HsVar XVar GhcPs
    _ (L SrcSpanAnnN
    _ RdrName
    x))) -> RdrName -> Bool
    isRdrDataCon RdrName
    x
    #if ! ( defined(GHC_9_12) || defined (GHC_9_10) || defined (GHC_9_8) || defined(GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api > 9.12.1
      (L _ (HsLit _ x)) -> case x of HsString{} -> False; _ -> True
    #else
      (L SrcSpanAnnA
    _ (HsLit XLitE GhcPs
    _ HsLit GhcPs
    x)) -> case HsLit GhcPs
    x of HsString{} -> Bool
    False; HsInt{} -> Bool
    False; HsRat{} -> Bool
    False; HsLit GhcPs
    _ -> Bool
    True
    #endif
      (L SrcSpanAnnA
    _ HsLam{}) -> Bool
    True
      (L SrcSpanAnnA
    _ ExplicitTuple{}) -> Bool
    True
      (L SrcSpanAnnA
    _ ExplicitList{}) -> Bool
    True

    #if ! ( defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.8
      (L SrcSpanAnnA
    _ (HsPar XPar GhcPs
    _  LHsExpr GhcPs
    x )) -> LHsExpr GhcPs -> Bool
    isWHNF LHsExpr GhcPs
    x
    #elif ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.4
      (L _ (HsPar _ _ x _)) -> isWHNF x
    #else
      (L _ (HsPar _ x)) -> isWHNF x
    #endif
      (L SrcSpanAnnA
    _ (ExprWithTySig XExprWithTySig GhcPs
    _ LHsExpr GhcPs
    x LHsSigWcType (NoGhcTc GhcPs)
    _)) -> LHsExpr GhcPs -> Bool
    isWHNF LHsExpr GhcPs
    x
      -- Other (unknown) constructors may have bang patterns in them, so
      -- approximate.
      (L SrcSpanAnnA
    _ (HsApp XApp GhcPs
    _ (L SrcSpanAnnA
    _ (HsVar XVar GhcPs
    _ (L SrcSpanAnnN
    _ RdrName
    x))) LHsExpr GhcPs
    _))
        | OccName -> String
    occNameString (RdrName -> OccName
    rdrNameOcc RdrName
    x) String -> [String] -> Bool
    forall a. Eq a => a -> [a] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String
    "Just", String
    "Left", String
    "Right"] -> Bool
    True
      LHsExpr GhcPs
    _ -> Bool
    False
    #if ! ( defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    isLCase :: LHsExpr GhcPs -> Bool
    isLCase = \case (L SrcSpanAnnA
    _ (HsLam XLam GhcPs
    _ HsLamVariant
    LamCase MatchGroup GhcPs (LHsExpr GhcPs)
    _)) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False
    #else
    isLCase = \case (L _ HsLamCase{}) -> True; _ -> False
    #endif
    isOverLabel :: LHsExpr GhcPs -> Bool
    isOverLabel = \case (L SrcSpanAnnA
    _ HsOverLabel{}) -> Bool
    True; LHsExpr GhcPs
    _ -> Bool
    False

    #if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.6.1
    isQuasiQuoteSplice :: HsUntypedSplice GhcPs -> Bool
    #else
    isQuasiQuoteSplice :: HsSplice GhcPs -> Bool
    #endif
    isQuasiQuoteSplice :: HsUntypedSplice GhcPs -> Bool
    isQuasiQuoteSplice = \case HsQuasiQuote{} -> Bool
    True; HsUntypedSplice GhcPs
    _ -> Bool
    False

    #if ( defined (GHC_8_10) || defined (GHC_8_8) )
    isStrictMatch :: HsMatchContext RdrName -> Bool
    #elif ( defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) )
    isStrictMatch :: HsMatchContext GhcPs -> Bool
    #else
    -- ghc > 9.8.1
    isStrictMatch :: HsMatchContext (LocatedN RdrName) -> Bool
    #endif
    isStrictMatch :: HsMatchContext (GenLocated SrcSpanAnnN RdrName) -> Bool
    isStrictMatch = \case FunRhs{mc_strictness :: forall fn. HsMatchContext fn -> SrcStrictness
    mc_strictness=SrcStrictness
    SrcStrict} -> Bool
    True; HsMatchContext (GenLocated SrcSpanAnnN RdrName)
    _ -> Bool
    False

    -- Field is punned e.g. '{foo}'.
    #if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.4.1
    isFieldPun :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool
    isFieldPun :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool
    isFieldPun = \case (L SrcSpanAnnA
    _ HsFieldBind {hfbPun :: forall lhs rhs. HsFieldBind lhs rhs -> Bool
    hfbPun=Bool
    True}) -> Bool
    True; LHsFieldBind GhcPs (LFieldOcc GhcPs) (LHsExpr GhcPs)
    _ -> Bool
    False
    #else
    isFieldPun :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool
    isFieldPun = \case (L _ HsRecField {hsRecPun=True}) -> True; _ -> False
    #endif
    -- Field puns in updates have a different type to field puns in
    -- constructions.
    #if ! ( defined (GHC_9_10) || defined (GHC_9_8) || defined(GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api > 9.10.1
    isFieldPunUpdate :: HsFieldBind (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool
    isFieldPunUpdate :: HsFieldBind (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool
    isFieldPunUpdate = \case HsFieldBind {hfbPun :: forall lhs rhs. HsFieldBind lhs rhs -> Bool
    hfbPun=Bool
    True} -> Bool
    True; HsFieldBind (LFieldOcc GhcPs) (LHsExpr GhcPs)
    _ -> Bool
    False
    #elif ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.4.1 && <= 9.12.1
    isFieldPunUpdate :: HsFieldBind (LAmbiguousFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool
    isFieldPunUpdate = \case HsFieldBind {hfbPun=True} -> True; _ -> False
    #else
    isFieldPunUpdate :: HsRecField' (AmbiguousFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool
    isFieldPunUpdate = \case HsRecField {hsRecPun=True} -> True; _ -> False
    #endif

    -- Contains a '..' as in 'Foo{..}'
    hasFieldsDotDot :: HsRecFields GhcPs (LHsExpr GhcPs) -> Bool
    hasFieldsDotDot :: HsRecFields GhcPs (LHsExpr GhcPs) -> Bool
    hasFieldsDotDot = \case HsRecFields {rec_dotdot :: forall p arg. HsRecFields p arg -> Maybe (XRec p RecFieldsDotDot)
    rec_dotdot=Just XRec GhcPs RecFieldsDotDot
    _} -> Bool
    True; HsRecFields GhcPs (LHsExpr GhcPs)
    _ -> Bool
    False

    isRecStmt :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool
    isRecStmt :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool
    isRecStmt = \case RecStmt{} -> Bool
    True; StmtLR GhcPs GhcPs (LHsExpr GhcPs)
    _ -> Bool
    False

    isLetStmt :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool
    isLetStmt :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool
    isLetStmt = \case LetStmt{} -> Bool
    True; StmtLR GhcPs GhcPs (LHsExpr GhcPs)
    _ -> Bool
    False

    isParComp :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool
    isParComp :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool
    isParComp = \case ParStmt{} -> Bool
    True; StmtLR GhcPs GhcPs (LHsExpr GhcPs)
    _ -> Bool
    False

    -- TODO: Seems `HsStmtContext (HsDoRn p)` on master right now.
    #if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.4.1
    isMDo :: HsDoFlavour -> Bool
    isMDo :: HsDoFlavour -> Bool
    isMDo = \case MDoExpr Maybe ModuleName
    _ -> Bool
    True; HsDoFlavour
    _ -> Bool
    False
    isMonadComp :: HsDoFlavour -> Bool
    isMonadComp :: HsDoFlavour -> Bool
    isMonadComp = \case HsDoFlavour
    MonadComp -> Bool
    True; HsDoFlavour
    _ -> Bool
    False
    isListComp :: HsDoFlavour -> Bool
    isListComp :: HsDoFlavour -> Bool
    isListComp = \case HsDoFlavour
    ListComp -> Bool
    True; HsDoFlavour
    _ -> Bool
    False
    #elif defined (GHC_9_2) || defined (GHC_9_0)
    isMDo :: HsStmtContext GhcRn -> Bool
    isMDo = \case MDoExpr _ -> True; _ -> False
    isMonadComp :: HsStmtContext GhcRn -> Bool
    isMonadComp = \case MonadComp -> True; _ -> False
    isListComp :: HsStmtContext GhcRn -> Bool
    isListComp = \case ListComp -> True; _ -> False
    #else
    isMDo :: HsStmtContext Name -> Bool
    isMDo = \case MDoExpr -> True; _ -> False
    isMonadComp :: HsStmtContext Name -> Bool
    isMonadComp = \case MonadComp -> True; _ -> False
    isListComp :: HsStmtContext Name -> Bool
    isListComp = \case ListComp -> True; _ -> False
    #endif

    isTupleSection :: HsTupArg GhcPs -> Bool
    isTupleSection :: HsTupArg GhcPs -> Bool
    isTupleSection = \case Missing{} -> Bool
    True; HsTupArg GhcPs
    _ -> Bool
    False

    isString :: HsLit GhcPs -> Bool
    isString :: HsLit GhcPs -> Bool
    isString = \case HsString{} -> Bool
    True; HsLit GhcPs
    _ -> Bool
    False

    isPrimLiteral :: HsLit GhcPs -> Bool
    isPrimLiteral :: HsLit GhcPs -> Bool
    isPrimLiteral = \case
      HsCharPrim{} -> Bool
    True
      HsStringPrim{} -> Bool
    True
      HsIntPrim{} -> Bool
    True
      HsWordPrim{} -> Bool
    True
      HsInt64Prim{} -> Bool
    True
      HsWord64Prim{} -> Bool
    True
      HsFloatPrim{} -> Bool
    True
      HsDoublePrim{} -> Bool
    True
      HsLit GhcPs
    _ -> Bool
    False

    -- Since ghc-9.6.1, `HsTypedSplice` and `HsUntypedSplice` have been
    -- top-level constuctors of `Language.Haskell.Syntax.Expr.HsExpr p`
    #if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= ghc-9.6.1
    isTypedSplice, isUntypedSplice :: HsExpr GhcPs -> Bool
    isTypedSplice :: HsExpr GhcPs -> Bool
    isTypedSplice = \case HsTypedSplice{} -> Bool
    True; HsExpr GhcPs
    _ -> Bool
    False
    isUntypedSplice :: HsExpr GhcPs -> Bool
    isUntypedSplice = \case HsUntypedSplice{} -> Bool
    True; HsExpr GhcPs
    _ -> Bool
    False
    #endif

    isSpliceDecl :: HsExpr GhcPs -> Bool
    #if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.6.1
    isSpliceDecl :: HsExpr GhcPs -> Bool
    isSpliceDecl = \case
      HsTypedSplice{} -> Bool
    True
      HsUntypedSplice{} -> Bool
    True
      HsExpr GhcPs
    _ -> Bool
    False
    #else
    isSpliceDecl = \case HsSpliceE{} -> True; _ -> False
    #endif

    isMultiIf :: HsExpr GhcPs -> Bool
    isMultiIf :: HsExpr GhcPs -> Bool
    isMultiIf = \case HsMultiIf{} -> Bool
    True; HsExpr GhcPs
    _ -> Bool
    False

    isProc :: HsExpr GhcPs -> Bool
    isProc :: HsExpr GhcPs -> Bool
    isProc = \case HsProc{} -> Bool
    True; HsExpr GhcPs
    _ -> Bool
    False

    isTransStmt :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool
    isTransStmt :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool
    isTransStmt = \case TransStmt{} -> Bool
    True; StmtLR GhcPs GhcPs (LHsExpr GhcPs)
    _ -> Bool
    False

    -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'.
    #if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.4.1
    isFieldWildcard :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool
    #else
    isFieldWildcard :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool
    #endif
    isFieldWildcard :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool
    isFieldWildcard = \case

    #if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= ghc-9.6.1
    -- Use `Language.Haskell.GhcLibParserEx.GHC.Types.Name.Reader`s `occNameStr` since `HsUnboundVar` now contains a `RdrName` not an `OccName`.
      (L SrcSpanAnnA
    _ HsFieldBind {hfbRHS :: forall lhs rhs. HsFieldBind lhs rhs -> rhs
    hfbRHS=(L SrcSpanAnnA
    _ (HsUnboundVar XUnboundVar GhcPs
    _ RdrName
    s))}) -> RdrName -> String
    occNameStr RdrName
    s String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == String
    "_"
    #elif defined (GHC_9_4)
      (L _ HsFieldBind {hfbRHS=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_"
    #elif defined (GHC_9_2) || defined (GHC_9_0)
      (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_"
    #elif defined (GHC_8_10)
      (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ _))}) -> True
    #else
      (L _ HsRecField {hsRecFieldArg=(L _ (EWildPat _))}) -> True
    #endif
    #if ! (defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.4.1
      (L SrcSpanAnnA
    _ HsFieldBind {hfbPun :: forall lhs rhs. HsFieldBind lhs rhs -> Bool
    hfbPun=Bool
    True}) -> Bool
    True
      (L SrcSpanAnnA
    _ HsFieldBind {}) -> Bool
    False
    #else
      (L _ HsRecField {hsRecPun=True}) -> True
      (L _ HsRecField {}) -> False
    #endif

    isUnboxed :: Boxity -> Bool
    isUnboxed :: Boxity -> Bool
    isUnboxed = \case Boxity
    Unboxed -> Bool
    True; Boxity
    _ -> Bool
    False

    isWholeFrac :: HsExpr GhcPs -> Bool

    #if ! ( defined(GHC_9_12) || defined (GHC_9_10) || defined (GHC_9_8) || defined(GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api > 9.12.1
    isWholeFrac (HsOverLit _ (OverLit _ (HsFractional fl@FL {}) )) = denominator (rationalFromFractionalLit fl) == 1
    #elif ! (defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.4.1
    isWholeFrac :: HsExpr GhcPs -> Bool
    isWholeFrac (HsLit XLitE GhcPs
    _ (HsRat XHsRat GhcPs
    _ fl :: FractionalLit
    fl@FL{} Type
    _)) = Ratio Integer -> Integer
    forall a. Ratio a -> a
    denominator (FractionalLit -> Ratio Integer
    rationalFromFractionalLit FractionalLit
    fl) Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    1
    isWholeFrac (HsOverLit XOverLitE GhcPs
    _ (OverLit XOverLit GhcPs
    _ (HsFractional fl :: FractionalLit
    fl@FL {}) )) = Ratio Integer -> Integer
    forall a. Ratio a -> a
    denominator (FractionalLit -> Ratio Integer
    rationalFromFractionalLit FractionalLit
    fl) Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    1
    #elif defined (GHC_9_2)
    isWholeFrac (HsLit _ (HsRat _ fl@FL{} _)) = denominator (rationalFromFractionalLit fl) == 1
    isWholeFrac (HsOverLit _ (OverLit _ (HsFractional fl@FL {}) _)) = denominator (rationalFromFractionalLit fl) == 1
    #else
    isWholeFrac (HsLit _ (HsRat _ (FL _ _ v) _)) = denominator v == 1
    isWholeFrac (HsOverLit _ (OverLit _ (HsFractional (FL _ _ v)) _)) = denominator v == 1
    #endif
    isWholeFrac HsExpr GhcPs
    _ = Bool
    False

    varToStr :: LHsExpr GhcPs -> String
    varToStr :: LHsExpr GhcPs -> String
    varToStr (L SrcSpanAnnA
    _ (HsVar XVar GhcPs
    _ (L SrcSpanAnnN
    _ RdrName
    n)))
      | RdrName
    n RdrName -> RdrName -> Bool
    forall a. Eq a => a -> a -> Bool
    == RdrName
    consDataCon_RDR = String
    ":"
      | RdrName
    n RdrName -> RdrName -> Bool
    forall a. Eq a => a -> a -> Bool
    == Name -> RdrName
    nameRdrName Name
    nilDataConName = String
    "[]"
      | RdrName
    n RdrName -> RdrName -> Bool
    forall a. Eq a => a -> a -> Bool
    == Name -> RdrName
    nameRdrName (DataCon -> Name
    forall a. NamedThing a => a -> Name
    getName (Boxity -> Arity -> DataCon
    tupleDataCon Boxity
    Boxed Arity
    0)) = String
    "()"
      | Bool
    otherwise = OccName -> String
    occNameString (RdrName -> OccName
    rdrNameOcc RdrName
    n)
    varToStr LHsExpr GhcPs
    _ = String
    ""

    strToVar :: String -> LHsExpr GhcPs
    #if ! ( defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
    -- ghc api >= 9.2.1
    strToVar :: String -> LHsExpr GhcPs
    strToVar String
    x = HsExpr GhcPs -> GenLocated SrcSpanAnnA (HsExpr GhcPs)
    forall e a. HasAnnotation e => a -> GenLocated e a
    noLocA (HsExpr GhcPs -> GenLocated SrcSpanAnnA (HsExpr GhcPs))
    -> HsExpr GhcPs -> GenLocated SrcSpanAnnA (HsExpr GhcPs)
    forall a b. (a -> b) -> a -> b
    $ XVar GhcPs -> LIdP GhcPs -> HsExpr GhcPs
    forall p. XVar p -> LIdP p -> HsExpr p
    HsVar XVar GhcPs
    NoExtField
    noExtField (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 (String -> OccName
    mkVarOcc String
    x))
    #elif defined (GHC_9_0) || defined (GHC_8_10)
    strToVar x = noLoc $ HsVar noExtField (noLoc $ mkRdrUnqual (mkVarOcc x))
    #else
    strToVar x = noLoc $ HsVar noExt (noLoc $ mkRdrUnqual (mkVarOcc x))
    #endif

    fromChar :: LHsExpr GhcPs -> Maybe Char
    fromChar :: LHsExpr GhcPs -> Maybe Char
    fromChar = \case (L SrcSpanAnnA
    _ (HsLit XLitE GhcPs
    _ (HsChar XHsChar GhcPs
    _ Char
    x))) -> Char -> Maybe Char
    forall a. a -> Maybe a
    Just Char
    x; LHsExpr GhcPs
    _ -> Maybe Char
    forall a. Maybe a
    Nothing