{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Ormolu.Printer.Meat.Declaration.Type
( p_synDecl,
)
where
import GHC.Hs.Extension
import GHC.Hs.Type
import GHC.Types.Basic
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 ::
Located RdrName ->
LexicalFixity ->
LHsQTyVars GhcPs ->
LHsType GhcPs ->
R ()
p_synDecl :: Located RdrName
-> LexicalFixity -> LHsQTyVars GhcPs -> LHsType GhcPs -> R ()
p_synDecl Located RdrName
name LexicalFixity
fixity HsQTvs {[LHsTyVarBndr () GhcPs]
XHsQTvs GhcPs
hsq_ext :: forall pass. LHsQTyVars pass -> XHsQTvs pass
hsq_explicit :: forall pass. LHsQTyVars pass -> [LHsTyVarBndr () pass]
hsq_explicit :: [LHsTyVarBndr () GhcPs]
hsq_ext :: XHsQTvs GhcPs
..} LHsType GhcPs
t = do
Text -> R ()
txt Text
"type"
R ()
space
[SrcSpan] -> R () -> R ()
switchLayout (Located RdrName -> SrcSpan
forall l e. GenLocated l e -> l
getLoc Located RdrName
name SrcSpan -> [SrcSpan] -> [SrcSpan]
forall a. a -> [a] -> [a]
: (LHsTyVarBndr () GhcPs -> SrcSpan)
-> [LHsTyVarBndr () GhcPs] -> [SrcSpan]
forall a b. (a -> b) -> [a] -> [b]
map LHsTyVarBndr () GhcPs -> SrcSpan
forall l e. GenLocated l e -> l
getLoc [LHsTyVarBndr () 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
(Located RdrName -> R ()
p_rdrName Located RdrName
name)
((LHsTyVarBndr () GhcPs -> R ())
-> [LHsTyVarBndr () GhcPs] -> [R ()]
forall a b. (a -> b) -> [a] -> [b]
map ((HsTyVarBndr () GhcPs -> R ()) -> LHsTyVarBndr () GhcPs -> R ()
forall a. (a -> R ()) -> Located a -> R ()
located' HsTyVarBndr () GhcPs -> R ()
forall flag.
IsInferredTyVarBndr flag =>
HsTyVarBndr flag GhcPs -> R ()
p_hsTyVarBndr) [LHsTyVarBndr () GhcPs]
hsq_explicit)
R ()
space
R ()
equals
if HsType GhcPs -> Bool
hasDocStrings (LHsType GhcPs -> HsType GhcPs
forall l e. GenLocated l e -> e
unLoc LHsType GhcPs
t)
then R ()
newline
else R ()
breakpoint
R () -> R ()
inci (LHsType GhcPs -> (HsType GhcPs -> R ()) -> R ()
forall a. Located a -> (a -> R ()) -> R ()
located LHsType GhcPs
t HsType GhcPs -> R ()
p_hsType)