    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE RecordWildCards #-}

    -- | Rendering of type synonym declarations.
    module Ormolu.Printer.Meat.Declaration.Type
      ( p_synDecl,
      )
    where

    import GHC.Hs.Extension
    import GHC.Hs.Type
    import GHC.Parser.Annotation
    import GHC.Types.Fixity
    import GHC.Types.Name.Reader
    import GHC.Types.SrcLoc
    import Ormolu.Printer.Combinators
    import Ormolu.Printer.Meat.Common
    import Ormolu.Printer.Meat.Type

    p_synDecl ::
      -- | Type constructor
      LocatedN RdrName ->
      -- | Fixity
      LexicalFixity ->
      -- | Type variables
      LHsQTyVars GhcPs ->
      -- | RHS of type declaration
      LHsType GhcPs ->
      R ()
    p_synDecl :: LocatedN RdrName
    -> LexicalFixity -> LHsQTyVars GhcPs -> LHsType GhcPs -> R ()
    p_synDecl LocatedN RdrName
    name LexicalFixity
    fixity HsQTvs {[LHsTyVarBndr (HsBndrVis GhcPs) GhcPs]
    XHsQTvs GhcPs
    hsq_ext :: XHsQTvs GhcPs
    hsq_explicit :: [LHsTyVarBndr (HsBndrVis GhcPs) GhcPs]
    hsq_explicit :: forall pass.
    LHsQTyVars pass -> [LHsTyVarBndr (HsBndrVis pass) pass]
    hsq_ext :: forall pass. LHsQTyVars pass -> XHsQTvs pass
    ..} LHsType GhcPs
    t = do
      Text -> R ()
    txt Text
    "type"
      R ()
    space
      [SrcSpan] -> R () -> R ()
    switchLayout (LocatedN RdrName -> SrcSpan
    forall a e. HasLoc a => GenLocated a e -> SrcSpan
    getLocA LocatedN RdrName
    name SrcSpan -> [SrcSpan] -> [SrcSpan]
    forall a. a -> [a] -> [a]
    : (GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcPs) GhcPs)
     -> SrcSpan)
    -> [GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcPs) GhcPs)]
    -> [SrcSpan]
    forall a b. (a -> b) -> [a] -> [b]
    map GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcPs) GhcPs)
    -> SrcSpan
    forall a e. HasLoc a => GenLocated a e -> SrcSpan
    getLocA [LHsTyVarBndr (HsBndrVis GhcPs) GhcPs]
    [GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcPs) GhcPs)]
    hsq_explicit) (R () -> R ()) -> R () -> R ()
    forall a b. (a -> b) -> a -> b
    $
        Bool -> Bool -> R () -> [R ()] -> R ()
    p_infixDefHelper
          (case LexicalFixity
    fixity of LexicalFixity
    Infix -> Bool
    True; LexicalFixity
    _ -> Bool
    False)
          Bool
    True
          (LocatedN RdrName -> R ()
    p_rdrName LocatedN RdrName
    name)
          ((GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcPs) GhcPs)
     -> R ())
    -> [GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcPs) GhcPs)]
    -> [R ()]
    forall a b. (a -> b) -> [a] -> [b]
    map ((HsTyVarBndr (HsBndrVis GhcPs) GhcPs -> R ())
    -> GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcPs) GhcPs)
    -> R ()
    forall l a. HasLoc l => (a -> R ()) -> GenLocated l a -> R ()
    located' HsTyVarBndr (HsBndrVis GhcPs) GhcPs -> R ()
    forall flag. IsTyVarBndrFlag flag => HsTyVarBndr flag GhcPs -> R ()
    p_hsTyVarBndr) [LHsTyVarBndr (HsBndrVis GhcPs) GhcPs]
    [GenLocated SrcSpanAnnA (HsTyVarBndr (HsBndrVis GhcPs) GhcPs)]
    hsq_explicit)
      R () -> R ()
    inci (R () -> R ()) -> R () -> R ()
    forall a b. (a -> b) -> a -> b
    $ do
        R ()
    space
        R ()
    equals
        if HsType GhcPs -> Bool
    hasDocStrings (GenLocated SrcSpanAnnA (HsType GhcPs) -> HsType GhcPs
    forall l e. GenLocated l e -> e
    unLoc LHsType GhcPs
    GenLocated SrcSpanAnnA (HsType GhcPs)
    t)
          then R ()
    newline
          else R ()
    breakpoint
        GenLocated SrcSpanAnnA (HsType GhcPs)
    -> (HsType GhcPs -> R ()) -> R ()
    forall l a. HasLoc l => GenLocated l a -> (a -> R ()) -> R ()
    located LHsType GhcPs
    GenLocated SrcSpanAnnA (HsType GhcPs)
    t HsType GhcPs -> R ()
    p_hsType