{-# LANGUAGE DeriveDataTypeable   #-}
{-# LANGUAGE FlexibleContexts     #-}
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiWayIf           #-}
{-# LANGUAGE NamedFieldPuns       #-}
{-# LANGUAGE RankNTypes           #-}
{-# LANGUAGE ScopedTypeVariables  #-}
{-# LANGUAGE StandaloneDeriving   #-}
{-# LANGUAGE TupleSections        #-}
{-# LANGUAGE TypeApplications     #-}
{-# LANGUAGE TypeFamilies         #-}
{-# LANGUAGE TypeOperators        #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE ViewPatterns         #-}
{-# LANGUAGE BlockArguments       #-}
{-# LANGUAGE UndecidableInstances  #-} -- For the (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ExactPrint instance
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}

module Language.Haskell.GHC.ExactPrint.ExactPrint
  (
    ExactPrint(..)
  , exactPrint
  , exactPrintWithOptions
  , makeDeltaAst

  -- * Configuration
  , EPOptions(epRigidity, epAstPrint, epTokenPrint, epWhitespacePrint, epUpdateAnchors)
  , stringOptions
  , epOptions
  , deltaOptions

  -- Temporary to avoid import loop problems
  , showAst
  ) where

import GHC
import GHC.Core.Coercion.Axiom (Role(..))
import GHC.Data.Bag
import qualified GHC.Data.BooleanFormula as BF
import GHC.Data.FastString
import GHC.TypeLits
import GHC.Types.Basic hiding (EP)
import GHC.Types.Fixity
import GHC.Types.ForeignCall
import GHC.Types.Name.Reader
import GHC.Types.PkgQual
import GHC.Types.SourceText
import GHC.Types.Var
import GHC.Utils.Outputable hiding ( (<>) )
import GHC.Unit.Module.Warnings
import GHC.Utils.Misc
import GHC.Utils.Panic
import qualified GHC.Data.Strict as Strict
import GHC.Base (NonEmpty(..))

import Language.Haskell.Syntax.Basic (FieldLabelString(..))

import Control.Monad (forM, when, unless)
import Control.Monad.Identity (Identity(..))
import qualified Control.Monad.Reader as Reader
import Control.Monad.RWS (MonadReader, RWST, evalRWST, tell, modify, get, gets, ask)
import Control.Monad.Trans (lift)
import Data.Data ( Data )
import Data.Dynamic
import Data.Foldable
import Data.Functor.Const
import qualified Data.Set as Set
import Data.Typeable
import Data.List ( partition, sort, sortBy)
import Data.Maybe ( isJust, mapMaybe )
import Data.Void

import Language.Haskell.GHC.ExactPrint.Dump
import Language.Haskell.GHC.ExactPrint.Lookup
import Language.Haskell.GHC.ExactPrint.Utils
import Language.Haskell.GHC.ExactPrint.Types

-- import Debug.Trace

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

-- Note: moved from Language.Haskell.GHC.ExactPrint.Utils as a hack to
-- avoid import loop problems while we have to use the local version
-- of Dump
showAst :: (Data a) => a -> String
showAst :: forall a. Data a => a -> String
showAst a
ast
  = SDoc -> String
showSDocUnsafe
    (SDoc -> String) -> SDoc -> String
forall a b. (a -> b) -> a -> b
$ BlankSrcSpan -> BlankEpAnnotations -> a -> SDoc
forall a. Data a => BlankSrcSpan -> BlankEpAnnotations -> a -> SDoc
showAstData BlankSrcSpan
NoBlankSrcSpan BlankEpAnnotations
NoBlankEpAnnotations a
ast

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

exactPrint :: ExactPrint ast => ast -> String
exactPrint :: forall ast. ExactPrint ast => ast -> String
exactPrint ast
ast = (ast, String) -> String
forall a b. (a, b) -> b
snd ((ast, String) -> String) -> (ast, String) -> String
forall a b. (a -> b) -> a -> b
$ Identity (ast, String) -> (ast, String)
forall a. Identity a -> a
runIdentity (EPOptions Identity String
-> EP String Identity ast -> Identity (ast, String)
forall (m :: * -> *) w a.
Monad m =>
EPOptions m w -> EP w m a -> m (a, w)
runEP EPOptions Identity String
stringOptions (ast -> EP String Identity ast
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ast
ast))

-- | The additional option to specify the rigidity and printing
-- configuration.
exactPrintWithOptions :: (ExactPrint ast, Monoid b, Monad m)
                      => EPOptions m b
                      -> ast
                      -> m (ast, b)
exactPrintWithOptions :: forall ast b (m :: * -> *).
(ExactPrint ast, Monoid b, Monad m) =>
EPOptions m b -> ast -> m (ast, b)
exactPrintWithOptions EPOptions m b
r ast
ast =
    EPOptions m b -> EP b m ast -> m (ast, b)
forall (m :: * -> *) w a.
Monad m =>
EPOptions m w -> EP w m a -> m (a, w)
runEP EPOptions m b
r (ast -> EP b m ast
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ast
ast)

-- | Transform concrete annotations into relative annotations which
-- are more useful when transforming an AST. This corresponds to the
-- earlier 'relativiseApiAnns'.
makeDeltaAst :: ExactPrint ast => ast -> ast
makeDeltaAst :: forall ast. ExactPrint ast => ast -> ast
makeDeltaAst ast
ast = (ast, ()) -> ast
forall a b. (a, b) -> a
fst ((ast, ()) -> ast) -> (ast, ()) -> ast
forall a b. (a -> b) -> a -> b
$ Identity (ast, ()) -> (ast, ())
forall a. Identity a -> a
runIdentity (EPOptions Identity () -> EP () Identity ast -> Identity (ast, ())
forall (m :: * -> *) w a.
Monad m =>
EPOptions m w -> EP w m a -> m (a, w)
runEP EPOptions Identity ()
deltaOptions (ast -> EP () Identity ast
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ast
ast))

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

type EP w m a = RWST (EPOptions m w) (EPWriter w) EPState m a

runEP :: (Monad m)
      => EPOptions m w
      -> EP w m a -> m (a, w)
runEP :: forall (m :: * -> *) w a.
Monad m =>
EPOptions m w -> EP w m a -> m (a, w)
runEP EPOptions m w
epReader EP w m a
action = do
  (a
ast, EPWriter w
w) <- EP w m a -> EPOptions m w -> EPState -> m (a, EPWriter w)
forall (m :: * -> *) r w s a.
Monad m =>
RWST r w s m a -> r -> s -> m (a, w)
evalRWST EP w m a
action EPOptions m w
epReader EPState
defaultEPState
  (a, w) -> m (a, w)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a
ast, EPWriter w -> w
forall a. EPWriter a -> a
output EPWriter w
w)

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

defaultEPState :: EPState
defaultEPState :: EPState
defaultEPState = EPState
             { epPos :: Pos
epPos      = (Int
1,Int
1)
             , dLHS :: LayoutStartCol
dLHS       = LayoutStartCol
1
             , pMarkLayout :: Bool
pMarkLayout = Bool
False
             , pLHS :: LayoutStartCol
pLHS = LayoutStartCol
1
             , dMarkLayout :: Bool
dMarkLayout = Bool
False
             , dPriorEndPosition :: Pos
dPriorEndPosition = (Int
1,Int
1)
             , uAnchorSpan :: RealSrcSpan
uAnchorSpan = RealSrcSpan
badRealSrcSpan
             , uExtraDP :: Maybe Anchor
uExtraDP = Maybe Anchor
forall a. Maybe a
Nothing
             , epComments :: [Comment]
epComments = []
             , epCommentsApplied :: [[Comment]]
epCommentsApplied = []
             }


-- ---------------------------------------------------------------------
-- The EP monad and basic combinators

-- | The R part of RWS. The environment. Updated via 'local' as we
-- enter a new AST element, having a different anchor point.
data EPOptions m a = EPOptions
            {
              forall (m :: * -> *) a.
EPOptions m a -> forall ast. Data ast => Located ast -> a -> m a
epAstPrint :: forall ast . Data ast => GHC.Located ast -> a -> m a
            , forall (m :: * -> *) a. EPOptions m a -> String -> m a
epTokenPrint :: String -> m a
            , forall (m :: * -> *) a. EPOptions m a -> String -> m a
epWhitespacePrint :: String -> m a
            , forall (m :: * -> *) a. EPOptions m a -> Rigidity
epRigidity :: Rigidity
            , forall (m :: * -> *) a. EPOptions m a -> Bool
epUpdateAnchors :: Bool
            }

-- | Helper to create a 'EPOptions'
epOptions ::
      (forall ast . Data ast => GHC.Located ast -> a -> m a)
      -> (String -> m a)
      -> (String -> m a)
      -> Rigidity
      -> Bool
      -> EPOptions m a
epOptions :: forall a (m :: * -> *).
(forall ast. Data ast => Located ast -> a -> m a)
-> (String -> m a)
-> (String -> m a)
-> Rigidity
-> Bool
-> EPOptions m a
epOptions forall ast. Data ast => Located ast -> a -> m a
astPrint String -> m a
tokenPrint String -> m a
wsPrint Rigidity
rigidity Bool
delta = EPOptions
             {
               epAstPrint :: forall ast. Data ast => Located ast -> a -> m a
epAstPrint = Located ast -> a -> m a
forall ast. Data ast => Located ast -> a -> m a
astPrint
             , epWhitespacePrint :: String -> m a
epWhitespacePrint = String -> m a
wsPrint
             , epTokenPrint :: String -> m a
epTokenPrint = String -> m a
tokenPrint
             , epRigidity :: Rigidity
epRigidity = Rigidity
rigidity
             , epUpdateAnchors :: Bool
epUpdateAnchors = Bool
delta
             }

-- | Options which can be used to print as a normal String.
stringOptions :: EPOptions Identity String
stringOptions :: EPOptions Identity String
stringOptions = (forall ast. Data ast => Located ast -> String -> Identity String)
-> (String -> Identity String)
-> (String -> Identity String)
-> Rigidity
-> Bool
-> EPOptions Identity String
forall a (m :: * -> *).
(forall ast. Data ast => Located ast -> a -> m a)
-> (String -> m a)
-> (String -> m a)
-> Rigidity
-> Bool
-> EPOptions m a
epOptions (\Located ast
_ String
b -> String -> Identity String
forall a. a -> Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return String
b) String -> Identity String
forall a. a -> Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return String -> Identity String
forall a. a -> Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return Rigidity
NormalLayout Bool
False

-- | Options which can be used to simply update the AST to be in delta
-- form, without generating output
deltaOptions :: EPOptions Identity ()
deltaOptions :: EPOptions Identity ()
deltaOptions = (forall ast. Data ast => Located ast -> () -> Identity ())
-> (String -> Identity ())
-> (String -> Identity ())
-> Rigidity
-> Bool
-> EPOptions Identity ()
forall a (m :: * -> *).
(forall ast. Data ast => Located ast -> a -> m a)
-> (String -> m a)
-> (String -> m a)
-> Rigidity
-> Bool
-> EPOptions m a
epOptions (\Located ast
_ ()
_ -> () -> Identity ()
forall a. a -> Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ()) (\String
_ -> () -> Identity ()
forall a. a -> Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ()) (\String
_ -> () -> Identity ()
forall a. a -> Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ()) Rigidity
NormalLayout Bool
True

data EPWriter a = EPWriter
              { forall a. EPWriter a -> a
output :: !a }

instance Monoid w => Semigroup (EPWriter w) where
  (EPWriter w
a) <> :: EPWriter w -> EPWriter w -> EPWriter w
<> (EPWriter w
b) = w -> EPWriter w
forall a. a -> EPWriter a
EPWriter (w
a w -> w -> w
forall a. Semigroup a => a -> a -> a
<> w
b)

instance Monoid w => Monoid (EPWriter w) where
  mempty :: EPWriter w
mempty = w -> EPWriter w
forall a. a -> EPWriter a
EPWriter w
forall a. Monoid a => a
mempty

data EPState = EPState
             { EPState -> RealSrcSpan
uAnchorSpan :: !RealSrcSpan -- ^ in pre-changed AST
                                          -- reference frame, from
                                          -- Annotation
             , EPState -> Maybe Anchor
uExtraDP :: !(Maybe Anchor) -- ^ Used to anchor a
                                             -- list

             -- Print phase
             , EPState -> Pos
epPos        :: !Pos -- ^ Current output position
             , EPState -> Bool
pMarkLayout  :: !Bool
             , EPState -> LayoutStartCol
pLHS   :: !LayoutStartCol

             -- Delta phase
             , EPState -> Pos
dPriorEndPosition :: !Pos -- ^ End of Position reached
                                         -- when processing the
                                         -- preceding element
             , EPState -> Bool
dMarkLayout :: !Bool
             , EPState -> LayoutStartCol
dLHS        :: !LayoutStartCol

             -- Shared
             , EPState -> [Comment]
epComments :: ![Comment]
             , EPState -> [[Comment]]
epCommentsApplied :: ![[Comment]]
             }

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

-- AZ:TODO: this can just be a function :: (EpAnn a) -> Entry
class HasEntry ast where
  fromAnn :: ast -> Entry

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

-- | Key entry point.  Switches to an independent AST element with its
-- own annotation, calculating new offsets, etc
markAnnotated :: (Monad m, Monoid w, ExactPrint a) => a -> EP w m a
markAnnotated :: forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated a
a = Entry -> a -> EP w m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
Entry -> a -> EP w m a
enterAnn (a -> Entry
forall a. ExactPrint a => a -> Entry
getAnnotationEntry a
a) a
a

-- | For HsModule, because we do not have a proper SrcSpan, we must
-- indicate to flush trailing comments when done.
data FlushComments = FlushComments
                   | NoFlushComments
                   deriving (FlushComments -> FlushComments -> Bool
(FlushComments -> FlushComments -> Bool)
-> (FlushComments -> FlushComments -> Bool) -> Eq FlushComments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FlushComments -> FlushComments -> Bool
== :: FlushComments -> FlushComments -> Bool
$c/= :: FlushComments -> FlushComments -> Bool
/= :: FlushComments -> FlushComments -> Bool
Eq, Int -> FlushComments -> ShowS
[FlushComments] -> ShowS
FlushComments -> String
(Int -> FlushComments -> ShowS)
-> (FlushComments -> String)
-> ([FlushComments] -> ShowS)
-> Show FlushComments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FlushComments -> ShowS
showsPrec :: Int -> FlushComments -> ShowS
$cshow :: FlushComments -> String
show :: FlushComments -> String
$cshowList :: [FlushComments] -> ShowS
showList :: [FlushComments] -> ShowS
Show)

-- | For GenLocated SrcSpan, we construct an entry location but cannot update it.
data CanUpdateAnchor = CanUpdateAnchor
                     | CanUpdateAnchorOnly
                     | NoCanUpdateAnchor
                   deriving (CanUpdateAnchor -> CanUpdateAnchor -> Bool
(CanUpdateAnchor -> CanUpdateAnchor -> Bool)
-> (CanUpdateAnchor -> CanUpdateAnchor -> Bool)
-> Eq CanUpdateAnchor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CanUpdateAnchor -> CanUpdateAnchor -> Bool
== :: CanUpdateAnchor -> CanUpdateAnchor -> Bool
$c/= :: CanUpdateAnchor -> CanUpdateAnchor -> Bool
/= :: CanUpdateAnchor -> CanUpdateAnchor -> Bool
Eq, Int -> CanUpdateAnchor -> ShowS
[CanUpdateAnchor] -> ShowS
CanUpdateAnchor -> String
(Int -> CanUpdateAnchor -> ShowS)
-> (CanUpdateAnchor -> String)
-> ([CanUpdateAnchor] -> ShowS)
-> Show CanUpdateAnchor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CanUpdateAnchor -> ShowS
showsPrec :: Int -> CanUpdateAnchor -> ShowS
$cshow :: CanUpdateAnchor -> String
show :: CanUpdateAnchor -> String
$cshowList :: [CanUpdateAnchor] -> ShowS
showList :: [CanUpdateAnchor] -> ShowS
Show)

data Entry = Entry Anchor EpAnnComments FlushComments CanUpdateAnchor
           | NoEntryVal

-- | For flagging whether to capture comments in an EpaDelta or not
data CaptureComments = CaptureComments
                     | NoCaptureComments

mkEntry :: Anchor -> EpAnnComments -> Entry
mkEntry :: Anchor -> EpAnnComments -> Entry
mkEntry Anchor
anc EpAnnComments
cs = Anchor
-> EpAnnComments -> FlushComments -> CanUpdateAnchor -> Entry
Entry Anchor
anc EpAnnComments
cs FlushComments
NoFlushComments CanUpdateAnchor
CanUpdateAnchor

instance HasEntry (SrcSpanAnn' (EpAnn an)) where
  fromAnn :: SrcSpanAnn' (EpAnn an) -> Entry
fromAnn (SrcSpanAnn EpAnn an
EpAnnNotUsed SrcSpan
ss) = Anchor -> EpAnnComments -> Entry
mkEntry (SrcSpan -> Anchor
spanAsAnchor SrcSpan
ss) EpAnnComments
emptyComments
  fromAnn (SrcSpanAnn EpAnn an
an SrcSpan
_) = EpAnn an -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn an
an

instance HasEntry (EpAnn a) where
  fromAnn :: EpAnn a -> Entry
fromAnn (EpAnn Anchor
anchor a
_ EpAnnComments
cs) = Anchor -> EpAnnComments -> Entry
mkEntry Anchor
anchor EpAnnComments
cs
  fromAnn EpAnn a
EpAnnNotUsed = Entry
NoEntryVal

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

fromAnn' :: (HasEntry a) => a -> Entry
fromAnn' :: forall ast. HasEntry ast => ast -> Entry
fromAnn' a
an = case a -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn a
an of
  Entry
NoEntryVal -> Entry
NoEntryVal
  Entry Anchor
a EpAnnComments
c FlushComments
_ CanUpdateAnchor
u -> Anchor
-> EpAnnComments -> FlushComments -> CanUpdateAnchor -> Entry
Entry Anchor
a EpAnnComments
c' FlushComments
FlushComments CanUpdateAnchor
u
    where
      c' :: EpAnnComments
c' = case EpAnnComments
c of
        EpaComments [LEpaComment]
cs -> [LEpaComment] -> [LEpaComment] -> EpAnnComments
EpaCommentsBalanced (Bool -> [LEpaComment] -> [LEpaComment]
filterEofComment Bool
False [LEpaComment]
cs) (Bool -> [LEpaComment] -> [LEpaComment]
filterEofComment Bool
True [LEpaComment]
cs)
        EpaCommentsBalanced [LEpaComment]
cp [LEpaComment]
ct -> [LEpaComment] -> [LEpaComment] -> EpAnnComments
EpaCommentsBalanced [LEpaComment]
cp [LEpaComment]
ct

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

astId :: (Typeable a) => a -> String
astId :: forall a. Typeable a => a -> String
astId a
a = TypeRep -> String
forall a. Show a => a -> String
show (a -> TypeRep
forall a. Typeable a => a -> TypeRep
typeOf a
a)

cua :: (Monad m, Monoid w) => CanUpdateAnchor -> EP w m [a] -> EP w m [a]
cua :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
CanUpdateAnchor -> EP w m [a] -> EP w m [a]
cua CanUpdateAnchor
CanUpdateAnchor EP w m [a]
f = EP w m [a]
f
cua CanUpdateAnchor
CanUpdateAnchorOnly EP w m [a]
_ = [a] -> EP w m [a]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return []
cua CanUpdateAnchor
NoCanUpdateAnchor EP w m [a]
_ = [a] -> EP w m [a]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return []

-- | "Enter" an annotation, by using the associated 'anchor' field as
-- the new reference point for calculating all DeltaPos positions.
--
-- This is combination of the ghc=exactprint Delta.withAST and
-- Print.exactPC functions and effectively does the delta processing
-- immediately followed by the print processing.  JIT ghc-exactprint.
enterAnn :: (Monad m, Monoid w, ExactPrint a) => Entry -> a -> EP w m a
enterAnn :: forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
Entry -> a -> EP w m a
enterAnn Entry
NoEntryVal a
a = do
  Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn:starting:NO ANN:(p,a) =" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, String) -> String
forall a. Show a => a -> String
show (Pos
p, a -> String
forall a. Typeable a => a -> String
astId a
a)
  a
r <- a -> EP w m a
forall a (m :: * -> *) w.
(ExactPrint a, Monad m, Monoid w) =>
a -> EP w m a
forall (m :: * -> *) w. (Monad m, Monoid w) => a -> EP w m a
exact a
a
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn:done:NO ANN:p =" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, String) -> String
forall a. Show a => a -> String
show (Pos
p, a -> String
forall a. Typeable a => a -> String
astId a
a)
  a -> EP w m a
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
enterAnn (Entry Anchor
anchor' EpAnnComments
cs FlushComments
flush CanUpdateAnchor
canUpdateAnchor) a
a = do
  Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn:starting:(p,a) =" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, String) -> String
forall a. Show a => a -> String
show (Pos
p, a -> String
forall a. Typeable a => a -> String
astId a
a)
  -- debugM $ "enterAnn:(cs) =" ++ showGhc (cs)
  let curAnchor :: RealSrcSpan
curAnchor = Anchor -> RealSrcSpan
anchor Anchor
anchor' -- As a base for the current AST element
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn:(curAnchor):=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos) -> String
forall a. Show a => a -> String
show (RealSrcSpan -> (Pos, Pos)
rs2range RealSrcSpan
curAnchor)
  case CanUpdateAnchor
canUpdateAnchor of
    CanUpdateAnchor
CanUpdateAnchor -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m ()
pushAppliedComments
    CanUpdateAnchor
_ -> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  [LEpaComment] -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[LEpaComment] -> EP w m ()
addCommentsA (EpAnnComments -> [LEpaComment]
priorComments EpAnnComments
cs)
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn:Added comments"
  RealSrcSpan -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> EP w m ()
printComments RealSrcSpan
curAnchor
  [Comment]
priorCs <- CanUpdateAnchor -> EP w m [Comment] -> EP w m [Comment]
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
CanUpdateAnchor -> EP w m [a] -> EP w m [a]
cua CanUpdateAnchor
canUpdateAnchor EP w m [Comment]
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m [Comment]
takeAppliedComments -- no pop
  -- -------------------------
  case Anchor -> AnchorOperation
anchor_op Anchor
anchor' of
    MovedAnchor DeltaPos
dp -> do
      String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn: MovedAnchor:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ DeltaPos -> String
forall a. Show a => a -> String
show DeltaPos
dp
      -- Set the original anchor as prior end, so the rest of this AST
      -- fragment has a reference
      Pos -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPriorEndNoLayoutD (RealSrcSpan -> Pos
ss2pos RealSrcSpan
curAnchor)
    AnchorOperation
_ -> do
      () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  -- -------------------------
  if ((Pos -> Int
forall a b. (a, b) -> a
fst (Pos -> Int) -> Pos -> Int
forall a b. (a -> b) -> a -> b
$ (Pos, Pos) -> Pos
forall a b. (a, b) -> a
fst ((Pos, Pos) -> Pos) -> (Pos, Pos) -> Pos
forall a b. (a -> b) -> a -> b
$ RealSrcSpan -> (Pos, Pos)
rs2range RealSrcSpan
curAnchor) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0)
    then
      RealSrcSpan -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> EP w m ()
setAnchorU RealSrcSpan
curAnchor
    else
      String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn: not calling setAnchorU for : " String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos) -> String
forall a. Show a => a -> String
show (RealSrcSpan -> (Pos, Pos)
rs2range RealSrcSpan
curAnchor)
  -- -------------------------------------------------------------------
  -- Make sure the running dPriorEndPosition gets updated according to
  -- the change in the current anchor.

  -- Compute the distance from dPriorEndPosition to the start of the new span.

  -- While processing in the context of the prior anchor, we choose to
  -- enter a new Anchor, which has a defined position relative to the
  -- prior anchor, even if we do not actively output anything at that
  -- point.
  -- Is this edp?

  -- -------------------------------------------------------------------
  -- The first part corresponds to the delta phase, so should only use
  -- delta phase variables -----------------------------------
  -- Calculate offset required to get to the start of the SrcSPan
  LayoutStartCol
off <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetD
  let spanStart :: Pos
spanStart = RealSrcSpan -> Pos
ss2pos RealSrcSpan
curAnchor
  Pos
priorEndAfterComments <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
  let edp' :: DeltaPos
edp' = LayoutStartCol -> DeltaPos -> DeltaPos
adjustDeltaForOffset
               -- Use the propagated offset if one is set
               -- Note that we need to use the new offset if it has
               -- changed.
               LayoutStartCol
off (Pos -> RealSrcSpan -> DeltaPos
ss2delta Pos
priorEndAfterComments RealSrcSpan
curAnchor)
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn: (edp',off,priorEndAfterComments,curAnchor):" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (DeltaPos, LayoutStartCol, Pos, (Pos, Pos)) -> String
forall a. Show a => a -> String
show (DeltaPos
edp',LayoutStartCol
off,Pos
priorEndAfterComments,RealSrcSpan -> (Pos, Pos)
rs2range RealSrcSpan
curAnchor)
  let edp'' :: DeltaPos
edp'' = case Anchor -> AnchorOperation
anchor_op Anchor
anchor' of
        MovedAnchor DeltaPos
dp -> DeltaPos
dp
        AnchorOperation
_ -> DeltaPos
edp'
  -- ---------------------------------------------
  -- let edp = edp''
  Maybe Anchor
med <- EP w m (Maybe Anchor)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m (Maybe Anchor)
getExtraDP
  Maybe Anchor -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe Anchor -> EP w m ()
setExtraDP Maybe Anchor
forall a. Maybe a
Nothing
  let edp :: DeltaPos
edp = case Maybe Anchor
med of
        Maybe Anchor
Nothing -> DeltaPos
edp''
        Just (Anchor RealSrcSpan
_ (MovedAnchor DeltaPos
dp)) -> DeltaPos
dp
                   -- Replace original with desired one. Allows all
                   -- list entry values to be DP (1,0)
        Just (Anchor RealSrcSpan
r AnchorOperation
_) -> DeltaPos
dp
          where
            dp :: DeltaPos
dp = LayoutStartCol -> DeltaPos -> DeltaPos
adjustDeltaForOffset
                   LayoutStartCol
off (Pos -> RealSrcSpan -> DeltaPos
ss2delta Pos
priorEndAfterComments RealSrcSpan
r)
  Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Maybe Anchor -> Bool
forall a. Maybe a -> Bool
isJust Maybe Anchor
med) (RWST (EPOptions m w) (EPWriter w) EPState m ()
 -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn:(med,edp)=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Maybe Anchor, DeltaPos) -> String
forall a. Show a => a -> String
show (Maybe Anchor
med,DeltaPos
edp)
  -- ---------------------------------------------
  -- Preparation complete, perform the action
  Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Pos
priorEndAfterComments Pos -> Pos -> Bool
forall a. Ord a => a -> a -> Bool
< Pos
spanStart) (do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn.dPriorEndPosition:spanStart=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Pos -> String
forall a. Show a => a -> String
show Pos
spanStart
    (EPState -> EPState)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { dPriorEndPosition    = spanStart } ))

  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn: (anchor_op, curAnchor):" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (AnchorOperation, (Pos, Pos)) -> String
forall a. Show a => a -> String
show (Anchor -> AnchorOperation
anchor_op Anchor
anchor', RealSrcSpan -> (Pos, Pos)
rs2range RealSrcSpan
curAnchor)
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn: (dLHS,spanStart,pec,edp)=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (LayoutStartCol, Pos, Pos, DeltaPos) -> String
forall a. Show a => a -> String
show (LayoutStartCol
off,Pos
spanStart,Pos
priorEndAfterComments,DeltaPos
edp)
  Pos
p0 <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  Pos
d <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn: (posp, posd)=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos) -> String
forall a. Show a => a -> String
show (Pos
p0,Pos
d)

  -- end of delta phase processing
  -- -------------------------------------------------------------------
  -- start of print phase processing

  let mflush :: RWST (EPOptions m w) (EPWriter w) EPState m ()
mflush = Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (FlushComments
flush FlushComments -> FlushComments -> Bool
forall a. Eq a => a -> a -> Bool
== FlushComments
FlushComments) (RWST (EPOptions m w) (EPWriter w) EPState m ()
 -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ do
        String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"flushing comments in enterAnn:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpAnnComments -> String
forall a. Data a => a -> String
showAst EpAnnComments
cs
        [LEpaComment] -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[LEpaComment] -> EP w m ()
flushComments (EpAnnComments -> [LEpaComment]
getFollowingComments EpAnnComments
cs [LEpaComment] -> [LEpaComment] -> [LEpaComment]
forall a. [a] -> [a] -> [a]
++ Bool -> [LEpaComment] -> [LEpaComment]
filterEofComment Bool
True (EpAnnComments -> [LEpaComment]
priorComments EpAnnComments
cs))

  DeltaPos -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> EP w m ()
advance DeltaPos
edp
  a
a' <- a -> EP w m a
forall a (m :: * -> *) w.
(ExactPrint a, Monad m, Monoid w) =>
a -> EP w m a
forall (m :: * -> *) w. (Monad m, Monoid w) => a -> EP w m a
exact a
a
  RWST (EPOptions m w) (EPWriter w) EPState m ()
mflush

  -- end of sub-Anchor processing, start of tail end processing
  [Comment]
postCs <- CanUpdateAnchor -> EP w m [Comment] -> EP w m [Comment]
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
CanUpdateAnchor -> EP w m [a] -> EP w m [a]
cua CanUpdateAnchor
canUpdateAnchor EP w m [Comment]
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m [Comment]
takeAppliedCommentsPop
  Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (FlushComments
flush FlushComments -> FlushComments -> Bool
forall a. Eq a => a -> a -> Bool
== FlushComments
NoFlushComments) (RWST (EPOptions m w) (EPWriter w) EPState m ()
 -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ do
    Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ((EpAnnComments -> [LEpaComment]
getFollowingComments EpAnnComments
cs) [LEpaComment] -> [LEpaComment] -> Bool
forall a. Eq a => a -> a -> Bool
/= []) (RWST (EPOptions m w) (EPWriter w) EPState m ()
 -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ do
      String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"starting trailing comments:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [LEpaComment] -> String
forall a. Data a => a -> String
showAst (EpAnnComments -> [LEpaComment]
getFollowingComments EpAnnComments
cs)
      (Comment -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> [Comment] -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Comment -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Comment -> EP w m ()
printOneComment ((LEpaComment -> [Comment]) -> [LEpaComment] -> [Comment]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap LEpaComment -> [Comment]
tokComment ([LEpaComment] -> [Comment]) -> [LEpaComment] -> [Comment]
forall a b. (a -> b) -> a -> b
$ EpAnnComments -> [LEpaComment]
getFollowingComments EpAnnComments
cs)
      String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"ending trailing comments"

  let newAchor :: Anchor
newAchor = Anchor
anchor' { anchor_op = MovedAnchor edp }
  let r :: a
r = case CanUpdateAnchor
canUpdateAnchor of
            CanUpdateAnchor
CanUpdateAnchor -> a -> Anchor -> EpAnnComments -> a
forall a. ExactPrint a => a -> Anchor -> EpAnnComments -> a
setAnnotationAnchor a
a' Anchor
newAchor ([Comment] -> [Comment] -> EpAnnComments
mkEpaComments ([Comment]
priorCs[Comment] -> [Comment] -> [Comment]
forall a. [a] -> [a] -> [a]
++ [Comment]
postCs) [])
            CanUpdateAnchor
CanUpdateAnchorOnly -> a -> Anchor -> EpAnnComments -> a
forall a. ExactPrint a => a -> Anchor -> EpAnnComments -> a
setAnnotationAnchor a
a' Anchor
newAchor EpAnnComments
emptyComments
            CanUpdateAnchor
NoCanUpdateAnchor -> a
a'
  -- debugM $ "calling setAnnotationAnchor:(curAnchor, newAchor,priorCs,postCs)=" ++ showAst (show (rs2range curAnchor), newAchor, priorCs, postCs)
  -- debugM $ "calling setAnnotationAnchor:(newAchor,postCs)=" ++ showAst (newAchor, postCs)
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"enterAnn:done:(p,a) =" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, String) -> String
forall a. Show a => a -> String
show (Pos
p0, a -> String
forall a. Typeable a => a -> String
astId a
a')
  a -> EP w m a
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
r

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

addCommentsA :: (Monad m, Monoid w) => [LEpaComment] -> EP w m ()
addCommentsA :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[LEpaComment] -> EP w m ()
addCommentsA [LEpaComment]
csNew = [Comment] -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[Comment] -> EP w m ()
addComments ((LEpaComment -> [Comment]) -> [LEpaComment] -> [Comment]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap LEpaComment -> [Comment]
tokComment [LEpaComment]
csNew)

{-
TODO: When we addComments, some may have an anchor that is no longer
valid, as it has been moved and has an anchor_op.

Does an Anchor even make sense for a comment, perhaps it should be an
EpaLocation?

How do we sort them? do we assign a location based on when we add them
to the list, based on the current output pos?  Except the offset is a
delta compared to a reference location.  Need to nail the concept of
the reference location.

By definition it is the current anchor, so work against that. And that
also means that the first entry comment that has moved should not have
a line offset.
-}
addComments :: (Monad m, Monoid w) => [Comment] -> EP w m ()
addComments :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[Comment] -> EP w m ()
addComments [Comment]
csNew = do
  -- debugM $ "addComments:" ++ show csNew
  [Comment]
cs <- EP w m [Comment]
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m [Comment]
getUnallocatedComments

  [Comment] -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[Comment] -> EP w m ()
putUnallocatedComments ([Comment] -> [Comment]
forall a. Ord a => [a] -> [a]
sort ([Comment]
cs [Comment] -> [Comment] -> [Comment]
forall a. [a] -> [a] -> [a]
++ [Comment]
csNew))

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

-- | Just before we print out the EOF comments, flush the remaining
-- ones in the state.
flushComments :: (Monad m, Monoid w) => [LEpaComment] -> EP w m ()
flushComments :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[LEpaComment] -> EP w m ()
flushComments [LEpaComment]
trailing = do
  [LEpaComment] -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[LEpaComment] -> EP w m ()
addCommentsA (Bool -> [LEpaComment] -> [LEpaComment]
filterEofComment Bool
False [LEpaComment]
trailing)
  [Comment]
cs <- EP w m [Comment]
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m [Comment]
getUnallocatedComments
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"flushing comments starting"
  (Comment -> EP w m ()) -> [Comment] -> EP w m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Comment -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Comment -> EP w m ()
printOneComment ([Comment] -> [Comment]
sortComments [Comment]
cs)
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"flushing comments:EOF:trailing:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [LEpaComment] -> String
forall a. Data a => a -> String
showAst ([LEpaComment]
trailing)
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"flushing comments:EOF:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [LEpaComment] -> String
forall a. Data a => a -> String
showAst (Bool -> [LEpaComment] -> [LEpaComment]
filterEofComment Bool
True [LEpaComment]
trailing)
  (Comment -> EP w m ()) -> [Comment] -> EP w m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Comment -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Comment -> EP w m ()
printOneComment ((LEpaComment -> [Comment]) -> [LEpaComment] -> [Comment]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap LEpaComment -> [Comment]
tokComment (Bool -> [LEpaComment] -> [LEpaComment]
filterEofComment Bool
True [LEpaComment]
trailing))
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"flushing comments done"

filterEofComment :: Bool -> [LEpaComment] -> [LEpaComment]
filterEofComment :: Bool -> [LEpaComment] -> [LEpaComment]
filterEofComment Bool
keep [LEpaComment]
cs = [LEpaComment] -> [LEpaComment]
fixCs [LEpaComment]
cs
  where
      notEof :: LEpaComment -> Bool
notEof LEpaComment
com = case LEpaComment
com of
       L Anchor
_ (GHC.EpaComment (EpaCommentTok
EpaEofComment) RealSrcSpan
_) -> Bool
keep
       LEpaComment
_ -> Bool -> Bool
not Bool
keep
      fixCs :: [LEpaComment] -> [LEpaComment]
fixCs [LEpaComment]
c = (LEpaComment -> Bool) -> [LEpaComment] -> [LEpaComment]
forall a. (a -> Bool) -> [a] -> [a]
filter LEpaComment -> Bool
notEof [LEpaComment]
c

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

-- |In order to interleave annotations into the stream, we turn them into
-- comments. They are removed from the annotation to avoid duplication.
annotationsToComments :: (Monad m, Monoid w)
  => EpAnn a -> Lens a [AddEpAnn] -> [AnnKeywordId] -> EP w m (EpAnn a)
annotationsToComments :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> [AnnKeywordId] -> EP w m (EpAnn a)
annotationsToComments EpAnn a
EpAnnNotUsed Lens a [AddEpAnn]
_ [AnnKeywordId]
_kws = EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
annotationsToComments (EpAnn Anchor
anc a
a EpAnnComments
cs) Lens a [AddEpAnn]
l [AnnKeywordId]
kws = do
  let ([Comment]
newComments, [AddEpAnn]
newAnns) = ([Comment], [AddEpAnn]) -> [AddEpAnn] -> ([Comment], [AddEpAnn])
go ([],[]) (Getting a [AddEpAnn] -> a -> [AddEpAnn]
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a [AddEpAnn]
Lens a [AddEpAnn]
l a
a)
  [Comment] -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[Comment] -> EP w m ()
addComments [Comment]
newComments
  EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a [AddEpAnn] -> [AddEpAnn] -> a -> a
forall a b. Lens a b -> b -> a -> a
set ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l ([AddEpAnn] -> [AddEpAnn]
forall a. [a] -> [a]
reverse [AddEpAnn]
newAnns) a
a) EpAnnComments
cs)
  where
    keywords :: Set AnnKeywordId
keywords = [AnnKeywordId] -> Set AnnKeywordId
forall a. Ord a => [a] -> Set a
Set.fromList [AnnKeywordId]
kws

    go :: ([Comment], [AddEpAnn]) -> [AddEpAnn] -> ([Comment], [AddEpAnn])
    go :: ([Comment], [AddEpAnn]) -> [AddEpAnn] -> ([Comment], [AddEpAnn])
go ([Comment], [AddEpAnn])
acc [] = ([Comment], [AddEpAnn])
acc
    go ([Comment]
cs',[AddEpAnn]
ans) ((AddEpAnn AnnKeywordId
k EpaLocation
ss) : [AddEpAnn]
ls)
      | AnnKeywordId -> Set AnnKeywordId -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member AnnKeywordId
k Set AnnKeywordId
keywords = ([Comment], [AddEpAnn]) -> [AddEpAnn] -> ([Comment], [AddEpAnn])
go ((AnnKeywordId -> EpaLocation -> Comment
mkKWComment AnnKeywordId
k EpaLocation
ss)Comment -> [Comment] -> [Comment]
forall a. a -> [a] -> [a]
:[Comment]
cs', [AddEpAnn]
ans) [AddEpAnn]
ls
      | Bool
otherwise             = ([Comment], [AddEpAnn]) -> [AddEpAnn] -> ([Comment], [AddEpAnn])
go ([Comment]
cs', (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
k EpaLocation
ss)AddEpAnn -> [AddEpAnn] -> [AddEpAnn]
forall a. a -> [a] -> [a]
:[AddEpAnn]
ans)    [AddEpAnn]
ls

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

-- Temporary function to simply reproduce the "normal" pretty printer output
withPpr :: (Monad m, Monoid w, Outputable a) => a -> EP w m a
withPpr :: forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr a
a = do
  RealSrcSpan
ss <- EP w m RealSrcSpan
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m RealSrcSpan
getAnchorU
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"withPpr: ss=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ RealSrcSpan -> String
forall a. Show a => a -> String
show RealSrcSpan
ss
  RealSrcSpan
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> String -> EP w m ()
printStringAtRs' RealSrcSpan
ss (a -> String
forall a. Outputable a => a -> String
showPprUnsafe a
a)
  a -> EP w m a
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

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

-- | An AST fragment with an annotation must be able to return the
-- requirements for nesting another one, captured in an 'Entry', and
-- to be able to use the rest of the exactprint machinery to print the
-- element.  In the analogy to Outputable, 'exact' plays the role of
-- 'ppr'.
class (Typeable a) => ExactPrint a where
  getAnnotationEntry :: a -> Entry
  setAnnotationAnchor :: a -> Anchor -> EpAnnComments -> a
  exact :: (Monad m, Monoid w) => a -> EP w m a

-- ---------------------------------------------------------------------
-- Start of utility functions
-- ---------------------------------------------------------------------

printSourceText :: (Monad m, Monoid w) => SourceText -> String -> EP w m ()
printSourceText :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SourceText -> String -> EP w m ()
printSourceText (SourceText
NoSourceText) String
txt   =  String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance String
txt EP w m () -> EP w m () -> EP w m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> EP w m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
printSourceText (SourceText   String
txt) String
_ =  String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance String
txt EP w m () -> EP w m () -> EP w m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> EP w m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

printStringAtSs :: (Monad m, Monoid w) => SrcSpan -> String -> EP w m ()
printStringAtSs :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SrcSpan -> String -> EP w m ()
printStringAtSs SrcSpan
ss String
str = RealSrcSpan -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRs (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
ss) String
str EP w m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

printStringAtRs :: (Monad m, Monoid w) => RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRs :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRs RealSrcSpan
pa String
str = CaptureComments -> RealSrcSpan -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRsC CaptureComments
CaptureComments RealSrcSpan
pa String
str

printStringAtRsC :: (Monad m, Monoid w)
  => CaptureComments -> RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRsC :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRsC CaptureComments
capture RealSrcSpan
pa String
str = do
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"printStringAtRsC: pa=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ RealSrcSpan -> String
forall a. Data a => a -> String
showAst RealSrcSpan
pa
  RealSrcSpan -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> EP w m ()
printComments RealSrcSpan
pa
  Pos
pe <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"printStringAtRsC:pe=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Pos -> String
forall a. Show a => a -> String
show Pos
pe
  let p :: DeltaPos
p = Pos -> RealSrcSpan -> DeltaPos
ss2delta Pos
pe RealSrcSpan
pa
  DeltaPos
p' <- DeltaPos -> EP w m DeltaPos
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> EP w m DeltaPos
adjustDeltaForOffsetM DeltaPos
p
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"printStringAtRsC:(p,p')=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (DeltaPos, DeltaPos) -> String
forall a. Show a => a -> String
show (DeltaPos
p,DeltaPos
p')
  DeltaPos
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> String -> EP w m ()
printStringAtLsDelta DeltaPos
p' String
str
  Bool
-> RealSrcSpan -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> RealSrcSpan -> EP w m ()
setPriorEndASTD Bool
True RealSrcSpan
pa
  [Comment]
cs' <- case CaptureComments
capture of
    CaptureComments
CaptureComments -> RWST (EPOptions m w) (EPWriter w) EPState m [Comment]
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m [Comment]
takeAppliedComments
    CaptureComments
NoCaptureComments -> [Comment] -> RWST (EPOptions m w) (EPWriter w) EPState m [Comment]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return []
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"printStringAtRsC:cs'=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [Comment] -> String
forall a. Show a => a -> String
show [Comment]
cs'
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"printStringAtRsC:p'=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ DeltaPos -> String
forall a. Data a => a -> String
showAst DeltaPos
p'
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"printStringAtRsC: (EpaDelta p' [])=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpaLocation -> String
forall a. Data a => a -> String
showAst (DeltaPos -> [LEpaComment] -> EpaLocation
EpaDelta DeltaPos
p' [])
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"printStringAtRsC: (EpaDelta p' (map comment2LEpaComment cs'))=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpaLocation -> String
forall a. Data a => a -> String
showAst (DeltaPos -> [LEpaComment] -> EpaLocation
EpaDelta DeltaPos
p' ((Comment -> LEpaComment) -> [Comment] -> [LEpaComment]
forall a b. (a -> b) -> [a] -> [b]
map Comment -> LEpaComment
comment2LEpaComment [Comment]
cs'))
  EpaLocation -> EP w m EpaLocation
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (DeltaPos -> [LEpaComment] -> EpaLocation
EpaDelta DeltaPos
p' ((Comment -> LEpaComment) -> [Comment] -> [LEpaComment]
forall a b. (a -> b) -> [a] -> [b]
map Comment -> LEpaComment
comment2LEpaComment [Comment]
cs'))

printStringAtRs' :: (Monad m, Monoid w) => RealSrcSpan -> String -> EP w m ()
printStringAtRs' :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> String -> EP w m ()
printStringAtRs' RealSrcSpan
pa String
str = CaptureComments -> RealSrcSpan -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRsC CaptureComments
NoCaptureComments RealSrcSpan
pa String
str EP w m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

printStringAtMLoc' :: (Monad m, Monoid w)
  => Maybe EpaLocation -> String -> EP w m (Maybe EpaLocation)
printStringAtMLoc' :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe EpaLocation -> String -> EP w m (Maybe EpaLocation)
printStringAtMLoc' (Just EpaLocation
aa) String
s = EpaLocation -> Maybe EpaLocation
forall a. a -> Maybe a
Just (EpaLocation -> Maybe EpaLocation)
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe EpaLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> EpaLocation
-> String
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
aa String
s
printStringAtMLoc' Maybe EpaLocation
Nothing String
s = do
  DeltaPos -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> String -> EP w m ()
printStringAtLsDelta (Int -> DeltaPos
SameLine Int
1) String
s
  Maybe EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe EpaLocation)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpaLocation -> Maybe EpaLocation
forall a. a -> Maybe a
Just (DeltaPos -> [LEpaComment] -> EpaLocation
EpaDelta (Int -> DeltaPos
SameLine Int
1) []))

printStringAtMLocL :: (Monad m, Monoid w)
  => EpAnn a -> Lens a (Maybe EpaLocation) -> String -> EP w m (EpAnn a)
printStringAtMLocL :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe EpaLocation) -> String -> EP w m (EpAnn a)
printStringAtMLocL EpAnn a
EpAnnNotUsed Lens a (Maybe EpaLocation)
_ String
_ = EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
printStringAtMLocL (EpAnn Anchor
anc a
an EpAnnComments
cs) Lens a (Maybe EpaLocation)
l String
s = do
  Maybe EpaLocation
r <- Maybe EpaLocation
-> String
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe EpaLocation)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe EpaLocation -> String -> EP w m (Maybe EpaLocation)
go (Getting a (Maybe EpaLocation) -> a -> Maybe EpaLocation
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a (Maybe EpaLocation)
Lens a (Maybe EpaLocation)
l a
an) String
s
  EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a (Maybe EpaLocation) -> Maybe EpaLocation -> a -> a
forall a b. Lens a b -> b -> a -> a
set (Maybe EpaLocation -> f (Maybe EpaLocation)) -> a -> f a
Lens a (Maybe EpaLocation)
l Maybe EpaLocation
r a
an) EpAnnComments
cs)
  where
    go :: Maybe EpaLocation
-> String
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe EpaLocation)
go (Just EpaLocation
aa) String
str = EpaLocation -> Maybe EpaLocation
forall a. a -> Maybe a
Just (EpaLocation -> Maybe EpaLocation)
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe EpaLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> EpaLocation
-> String
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
aa String
str
    go Maybe EpaLocation
Nothing String
str = do
      DeltaPos -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> String -> EP w m ()
printStringAtLsDelta (Int -> DeltaPos
SameLine Int
1) String
str
      Maybe EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe EpaLocation)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpaLocation -> Maybe EpaLocation
forall a. a -> Maybe a
Just (DeltaPos -> [LEpaComment] -> EpaLocation
EpaDelta (Int -> DeltaPos
SameLine Int
1) []))

printStringAtAA :: (Monad m, Monoid w) => EpaLocation -> String -> EP w m EpaLocation
printStringAtAA :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
el String
str = CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
printStringAtAAC CaptureComments
CaptureComments EpaLocation
el String
str

printStringAtAAL :: (Monad m, Monoid w)
  => EpAnn a -> Lens a EpaLocation -> String -> EP w m (EpAnn a)
printStringAtAAL :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> String -> EP w m (EpAnn a)
printStringAtAAL EpAnn a
EpAnnNotUsed Lens a EpaLocation
_ String
_ = EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
printStringAtAAL (EpAnn Anchor
anc a
an EpAnnComments
cs) Lens a EpaLocation
l String
str = do
  EpaLocation
r <- CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
printStringAtAAC CaptureComments
CaptureComments (Getting a EpaLocation -> a -> EpaLocation
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a EpaLocation
Lens a EpaLocation
l a
an) String
str
  EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a EpaLocation -> EpaLocation -> a -> a
forall a b. Lens a b -> b -> a -> a
set (EpaLocation -> f EpaLocation) -> a -> f a
Lens a EpaLocation
l EpaLocation
r a
an) EpAnnComments
cs)

printStringAtAAC :: (Monad m, Monoid w)
  => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
printStringAtAAC :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
printStringAtAAC CaptureComments
capture (EpaSpan RealSrcSpan
r Maybe BufSpan
_) String
s = CaptureComments -> RealSrcSpan -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRsC CaptureComments
capture RealSrcSpan
r String
s
printStringAtAAC CaptureComments
capture (EpaDelta DeltaPos
d [LEpaComment]
cs) String
s = do
  (Comment -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> [Comment] -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_  Comment -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Comment -> EP w m ()
printOneComment ([Comment] -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> [Comment] -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ (LEpaComment -> [Comment]) -> [LEpaComment] -> [Comment]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap LEpaComment -> [Comment]
tokComment [LEpaComment]
cs
  Pos
pe1 <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
  Pos
p1 <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  DeltaPos
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> String -> EP w m ()
printStringAtLsDelta DeltaPos
d String
s
  Pos
p2 <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  Pos
pe2 <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"printStringAtAA:(pe1,pe2,p1,p2)=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos, Pos, Pos) -> String
forall a. Show a => a -> String
show (Pos
pe1,Pos
pe2,Pos
p1,Pos
p2)
  Bool
-> (Pos, Pos) -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> (Pos, Pos) -> EP w m ()
setPriorEndASTPD Bool
True (Pos
pe1,Pos
pe2)
  [Comment]
cs' <- case CaptureComments
capture of
    CaptureComments
CaptureComments -> RWST (EPOptions m w) (EPWriter w) EPState m [Comment]
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m [Comment]
takeAppliedComments
    CaptureComments
NoCaptureComments -> [Comment] -> RWST (EPOptions m w) (EPWriter w) EPState m [Comment]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return []
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"printStringAtAA:(pe1,pe2,p1,p2,cs')=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos, Pos, Pos, [Comment]) -> String
forall a. Show a => a -> String
show (Pos
pe1,Pos
pe2,Pos
p1,Pos
p2,[Comment]
cs')
  EpaLocation -> EP w m EpaLocation
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (DeltaPos -> [LEpaComment] -> EpaLocation
EpaDelta DeltaPos
d ((Comment -> LEpaComment) -> [Comment] -> [LEpaComment]
forall a b. (a -> b) -> [a] -> [b]
map Comment -> LEpaComment
comment2LEpaComment [Comment]
cs'))

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

markExternalSourceText :: (Monad m, Monoid w) => SrcSpan -> SourceText -> String -> EP w m ()
markExternalSourceText :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SrcSpan -> SourceText -> String -> EP w m ()
markExternalSourceText SrcSpan
l SourceText
NoSourceText String
txt   = RealSrcSpan -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRs (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
l) String
txt EP w m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
markExternalSourceText SrcSpan
l (SourceText String
txt) String
_ = RealSrcSpan -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRs (SrcSpan -> RealSrcSpan
realSrcSpan SrcSpan
l) String
txt EP w m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

markLensMAA :: (Monad m, Monoid w) => EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn a
EpAnnNotUsed  Lens a (Maybe AddEpAnn)
_  = EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
markLensMAA (EpAnn Anchor
anc a
a EpAnnComments
cs) Lens a (Maybe AddEpAnn)
l =
  case Getting a (Maybe AddEpAnn) -> a -> Maybe AddEpAnn
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a (Maybe AddEpAnn)
Lens a (Maybe AddEpAnn)
l a
a of
    Maybe AddEpAnn
Nothing -> EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc a
a EpAnnComments
cs)
    Just AddEpAnn
aa -> do
      AddEpAnn
aa' <- AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
markAddEpAnn AddEpAnn
aa
      EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a (Maybe AddEpAnn) -> Maybe AddEpAnn -> a -> a
forall a b. Lens a b -> b -> a -> a
set (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> a -> f a
Lens a (Maybe AddEpAnn)
l (AddEpAnn -> Maybe AddEpAnn
forall a. a -> Maybe a
Just AddEpAnn
aa') a
a) EpAnnComments
cs)

markLensAA :: (Monad m, Monoid w) => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA EpAnn a
EpAnnNotUsed  Lens a AddEpAnn
_  = EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
markLensAA (EpAnn Anchor
anc a
a EpAnnComments
cs) Lens a AddEpAnn
l = do
  AddEpAnn
a' <- AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
markKw (Getting a AddEpAnn -> a -> AddEpAnn
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a AddEpAnn
Lens a AddEpAnn
l a
a)
  EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a AddEpAnn -> AddEpAnn -> a -> a
forall a b. Lens a b -> b -> a -> a
set (AddEpAnn -> f AddEpAnn) -> a -> f a
Lens a AddEpAnn
l AddEpAnn
a' a
a) EpAnnComments
cs)


markEpAnnLMS :: (Monad m, Monoid w)
  => EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a)
markEpAnnLMS :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn a
an Lens a [AddEpAnn]
l AnnKeywordId
kw Maybe String
Nothing = EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn a)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn a
an ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
kw
markEpAnnLMS EpAnn a
EpAnnNotUsed  Lens a [AddEpAnn]
_ AnnKeywordId
_ Maybe String
_ = EpAnn a -> EP w m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
markEpAnnLMS (EpAnn Anchor
anc a
a EpAnnComments
cs) Lens a [AddEpAnn]
l AnnKeywordId
kw (Just String
str) = do
  [AddEpAnn]
anns <- (AddEpAnn -> RWST (EPOptions m w) (EPWriter w) EPState m AddEpAnn)
-> [AddEpAnn]
-> RWST (EPOptions m w) (EPWriter w) EPState m [AddEpAnn]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM AddEpAnn -> RWST (EPOptions m w) (EPWriter w) EPState m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
go (Getting a [AddEpAnn] -> a -> [AddEpAnn]
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a [AddEpAnn]
Lens a [AddEpAnn]
l a
a)
  EpAnn a -> EP w m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a [AddEpAnn] -> [AddEpAnn] -> a -> a
forall a b. Lens a b -> b -> a -> a
set ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l [AddEpAnn]
anns a
a) EpAnnComments
cs)
  where
    go :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn
    go :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
go (AddEpAnn AnnKeywordId
kw' EpaLocation
r)
      | AnnKeywordId
kw' AnnKeywordId -> AnnKeywordId -> Bool
forall a. Eq a => a -> a -> Bool
== AnnKeywordId
kw = do
          EpaLocation
r' <- EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
r String
str
          AddEpAnn -> EP w m AddEpAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kw' EpaLocation
r')
      | Bool
otherwise = AddEpAnn -> EP w m AddEpAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kw' EpaLocation
r)

markEpAnnLMS' :: (Monad m, Monoid w)
                => EpAnn a -> Lens a AddEpAnn -> AnnKeywordId -> Maybe String -> EP w m (EpAnn a)
markEpAnnLMS' :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a AddEpAnn
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS' EpAnn a
an Lens a AddEpAnn
l AnnKeywordId
_kw Maybe String
Nothing = EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensKwA EpAnn a
an (AddEpAnn -> f AddEpAnn) -> a -> f a
Lens a AddEpAnn
l
markEpAnnLMS' EpAnn a
EpAnnNotUsed  Lens a AddEpAnn
_ AnnKeywordId
_ Maybe String
_ = EpAnn a -> EP w m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
markEpAnnLMS' (EpAnn Anchor
anc a
a EpAnnComments
cs) Lens a AddEpAnn
l AnnKeywordId
kw (Just String
str) = do
  AddEpAnn
anns <- AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
go (Getting a AddEpAnn -> a -> AddEpAnn
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a AddEpAnn
Lens a AddEpAnn
l a
a)
  EpAnn a -> EP w m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a AddEpAnn -> AddEpAnn -> a -> a
forall a b. Lens a b -> b -> a -> a
set (AddEpAnn -> f AddEpAnn) -> a -> f a
Lens a AddEpAnn
l AddEpAnn
anns a
a) EpAnnComments
cs)
  where
    go :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn
    go :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
go (AddEpAnn AnnKeywordId
kw' EpaLocation
r)
      | AnnKeywordId
kw' AnnKeywordId -> AnnKeywordId -> Bool
forall a. Eq a => a -> a -> Bool
== AnnKeywordId
kw = do
          EpaLocation
r' <- EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
r String
str
          AddEpAnn -> EP w m AddEpAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kw' EpaLocation
r')
      | Bool
otherwise = AddEpAnn -> EP w m AddEpAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kw' EpaLocation
r)

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

markToken :: forall m w tok . (Monad m, Monoid w, KnownSymbol tok)
  => LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken :: forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken (L TokenLocation
NoTokenLoc HsToken tok
t) = GenLocated TokenLocation (HsToken tok)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated TokenLocation (HsToken tok))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (TokenLocation
-> HsToken tok -> GenLocated TokenLocation (HsToken tok)
forall l e. l -> e -> GenLocated l e
L TokenLocation
NoTokenLoc HsToken tok
t)
markToken (L (TokenLoc EpaLocation
aa) HsToken tok
t) = do
  EpaLocation
aa' <- EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
aa (Proxy tok -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (forall {k} (t :: k). Proxy t
forall (t :: Symbol). Proxy t
Proxy @tok))
  GenLocated TokenLocation (HsToken tok)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated TokenLocation (HsToken tok))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (TokenLocation
-> HsToken tok -> GenLocated TokenLocation (HsToken tok)
forall l e. l -> e -> GenLocated l e
L (EpaLocation -> TokenLocation
TokenLoc EpaLocation
aa') HsToken tok
t)

markUniToken :: forall m w tok utok. (Monad m, Monoid w, KnownSymbol tok, KnownSymbol utok)
  => LHsUniToken tok utok GhcPs -> EP w m (LHsUniToken tok utok GhcPs)
markUniToken :: forall (m :: * -> *) w (tok :: Symbol) (utok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok, KnownSymbol utok) =>
LHsUniToken tok utok GhcPs -> EP w m (LHsUniToken tok utok GhcPs)
markUniToken (L TokenLocation
l HsUniToken tok utok
HsNormalTok)  = do
  (L TokenLocation
l' HsToken tok
_) <- LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken (TokenLocation
-> HsToken tok -> GenLocated TokenLocation (HsToken tok)
forall l e. l -> e -> GenLocated l e
L TokenLocation
l (forall (tok :: Symbol). HsToken tok
HsTok @tok))
  GenLocated TokenLocation (HsUniToken tok utok)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated TokenLocation (HsUniToken tok utok))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (TokenLocation
-> HsUniToken tok utok
-> GenLocated TokenLocation (HsUniToken tok utok)
forall l e. l -> e -> GenLocated l e
L TokenLocation
l' HsUniToken tok utok
forall (tok :: Symbol) (utok :: Symbol). HsUniToken tok utok
HsNormalTok)
markUniToken (L TokenLocation
l HsUniToken tok utok
HsUnicodeTok) = do
  (L TokenLocation
l' HsToken utok
_) <- LHsToken utok GhcPs -> EP w m (LHsToken utok GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken (TokenLocation
-> HsToken utok -> GenLocated TokenLocation (HsToken utok)
forall l e. l -> e -> GenLocated l e
L TokenLocation
l (forall (tok :: Symbol). HsToken tok
HsTok @utok))
  GenLocated TokenLocation (HsUniToken tok utok)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated TokenLocation (HsUniToken tok utok))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (TokenLocation
-> HsUniToken tok utok
-> GenLocated TokenLocation (HsUniToken tok utok)
forall l e. l -> e -> GenLocated l e
L TokenLocation
l' HsUniToken tok utok
forall (tok :: Symbol) (utok :: Symbol). HsUniToken tok utok
HsUnicodeTok)

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

markArrow :: (Monad m, Monoid w) => HsArrow GhcPs -> EP w m (HsArrow GhcPs)
markArrow :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsArrow GhcPs -> EP w m (HsArrow GhcPs)
markArrow (HsUnrestrictedArrow LHsUniToken "->" "\8594" GhcPs
arr) = do
  GenLocated TokenLocation (HsUniToken "->" "\8594")
arr' <- LHsUniToken "->" "\8594" GhcPs
-> EP w m (LHsUniToken "->" "\8594" GhcPs)
forall (m :: * -> *) w (tok :: Symbol) (utok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok, KnownSymbol utok) =>
LHsUniToken tok utok GhcPs -> EP w m (LHsUniToken tok utok GhcPs)
markUniToken LHsUniToken "->" "\8594" GhcPs
arr
  HsArrow GhcPs -> EP w m (HsArrow GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsUniToken "->" "\8594" GhcPs -> HsArrow GhcPs
forall pass. LHsUniToken "->" "\8594" pass -> HsArrow pass
HsUnrestrictedArrow LHsUniToken "->" "\8594" GhcPs
GenLocated TokenLocation (HsUniToken "->" "\8594")
arr')
markArrow (HsLinearArrow (HsPct1 LHsToken "%1" GhcPs
pct1 LHsUniToken "->" "\8594" GhcPs
arr)) = do
  GenLocated TokenLocation (HsToken "%1")
pct1' <- LHsToken "%1" GhcPs -> EP w m (LHsToken "%1" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "%1" GhcPs
pct1
  GenLocated TokenLocation (HsUniToken "->" "\8594")
arr' <- LHsUniToken "->" "\8594" GhcPs
-> EP w m (LHsUniToken "->" "\8594" GhcPs)
forall (m :: * -> *) w (tok :: Symbol) (utok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok, KnownSymbol utok) =>
LHsUniToken tok utok GhcPs -> EP w m (LHsUniToken tok utok GhcPs)
markUniToken LHsUniToken "->" "\8594" GhcPs
arr
  HsArrow GhcPs -> EP w m (HsArrow GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsLinearArrowTokens GhcPs -> HsArrow GhcPs
forall pass. HsLinearArrowTokens pass -> HsArrow pass
HsLinearArrow (LHsToken "%1" GhcPs
-> LHsUniToken "->" "\8594" GhcPs -> HsLinearArrowTokens GhcPs
forall pass.
LHsToken "%1" pass
-> LHsUniToken "->" "\8594" pass -> HsLinearArrowTokens pass
HsPct1 LHsToken "%1" GhcPs
GenLocated TokenLocation (HsToken "%1")
pct1' LHsUniToken "->" "\8594" GhcPs
GenLocated TokenLocation (HsUniToken "->" "\8594")
arr'))
markArrow (HsLinearArrow (HsLolly LHsToken "\8888" GhcPs
arr)) = do
  GenLocated TokenLocation (HsToken "\8888")
arr' <- LHsToken "\8888" GhcPs -> EP w m (LHsToken "\8888" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "\8888" GhcPs
arr
  HsArrow GhcPs -> EP w m (HsArrow GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsLinearArrowTokens GhcPs -> HsArrow GhcPs
forall pass. HsLinearArrowTokens pass -> HsArrow pass
HsLinearArrow (LHsToken "\8888" GhcPs -> HsLinearArrowTokens GhcPs
forall pass. LHsToken "\8888" pass -> HsLinearArrowTokens pass
HsLolly LHsToken "\8888" GhcPs
GenLocated TokenLocation (HsToken "\8888")
arr'))
markArrow (HsExplicitMult LHsToken "%" GhcPs
pct LHsType GhcPs
t LHsUniToken "->" "\8594" GhcPs
arr) = do
  GenLocated TokenLocation (HsToken "%")
pct' <- LHsToken "%" GhcPs -> EP w m (LHsToken "%" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "%" GhcPs
pct
  GenLocated SrcSpanAnnA (HsType GhcPs)
t' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t
  GenLocated TokenLocation (HsUniToken "->" "\8594")
arr' <- LHsUniToken "->" "\8594" GhcPs
-> EP w m (LHsUniToken "->" "\8594" GhcPs)
forall (m :: * -> *) w (tok :: Symbol) (utok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok, KnownSymbol utok) =>
LHsUniToken tok utok GhcPs -> EP w m (LHsUniToken tok utok GhcPs)
markUniToken LHsUniToken "->" "\8594" GhcPs
arr
  HsArrow GhcPs -> EP w m (HsArrow GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsToken "%" GhcPs
-> LHsType GhcPs -> LHsUniToken "->" "\8594" GhcPs -> HsArrow GhcPs
forall pass.
LHsToken "%" pass
-> LHsType pass -> LHsUniToken "->" "\8594" pass -> HsArrow pass
HsExplicitMult LHsToken "%" GhcPs
GenLocated TokenLocation (HsToken "%")
pct' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t' LHsUniToken "->" "\8594" GhcPs
GenLocated TokenLocation (HsUniToken "->" "\8594")
arr')

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

markAnnCloseP :: (Monad m, Monoid w) => EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an = EpAnn AnnPragma
-> Lens AnnPragma AddEpAnn
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a AddEpAnn
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS' EpAnn AnnPragma
an (AddEpAnn -> f AddEpAnn) -> AnnPragma -> f AnnPragma
Lens AnnPragma AddEpAnn
lapr_close AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"#-}")

markAnnOpenP :: (Monad m, Monoid w) => EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
NoSourceText String
txt   = EpAnn AnnPragma
-> Lens AnnPragma AddEpAnn
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a AddEpAnn
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS' EpAnn AnnPragma
an (AddEpAnn -> f AddEpAnn) -> AnnPragma -> f AnnPragma
Lens AnnPragma AddEpAnn
lapr_open AnnKeywordId
AnnOpen (String -> Maybe String
forall a. a -> Maybe a
Just String
txt)
markAnnOpenP EpAnn AnnPragma
an (SourceText String
txt) String
_ = EpAnn AnnPragma
-> Lens AnnPragma AddEpAnn
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a AddEpAnn
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS' EpAnn AnnPragma
an (AddEpAnn -> f AddEpAnn) -> AnnPragma -> f AnnPragma
Lens AnnPragma AddEpAnn
lapr_open AnnKeywordId
AnnOpen (String -> Maybe String
forall a. a -> Maybe a
Just String
txt)

markAnnOpen :: (Monad m, Monoid w) => EpAnn [AddEpAnn] -> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
markAnnOpen :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
markAnnOpen EpAnn [AddEpAnn]
an SourceText
NoSourceText String
txt   = EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpen (String -> Maybe String
forall a. a -> Maybe a
Just String
txt)
markAnnOpen EpAnn [AddEpAnn]
an (SourceText String
txt) String
_ = EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpen (String -> Maybe String
forall a. a -> Maybe a
Just String
txt)

markAnnOpen' :: (Monad m, Monoid w)
  => Maybe EpaLocation -> SourceText -> String -> EP w m (Maybe EpaLocation)
markAnnOpen' :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe EpaLocation
-> SourceText -> String -> EP w m (Maybe EpaLocation)
markAnnOpen' Maybe EpaLocation
ms SourceText
NoSourceText String
txt   = Maybe EpaLocation -> String -> EP w m (Maybe EpaLocation)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe EpaLocation -> String -> EP w m (Maybe EpaLocation)
printStringAtMLoc' Maybe EpaLocation
ms String
txt
markAnnOpen' Maybe EpaLocation
ms (SourceText String
txt) String
_ = Maybe EpaLocation -> String -> EP w m (Maybe EpaLocation)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe EpaLocation -> String -> EP w m (Maybe EpaLocation)
printStringAtMLoc' Maybe EpaLocation
ms String
txt

markAnnOpen'' :: (Monad m, Monoid w)
  => EpaLocation -> SourceText -> String -> EP w m EpaLocation
markAnnOpen'' :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> SourceText -> String -> EP w m EpaLocation
markAnnOpen'' EpaLocation
el SourceText
NoSourceText String
txt   = EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
el String
txt
markAnnOpen'' EpaLocation
el (SourceText String
txt) String
_ = EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
el String
txt

-- ---------------------------------------------------------------------
{-
data AnnParen
  = AnnParen {
      ap_adornment :: ParenType,
      ap_open      :: EpaLocation,
      ap_close     :: EpaLocation
      } deriving (Data)
-}
markOpeningParen, markClosingParen :: (Monad m, Monoid w) => EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markOpeningParen :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markOpeningParen EpAnn AnnParen
an = EpAnn AnnParen
-> (forall a (f :: * -> *).
    Functor f =>
    (a -> f a) -> (a, a) -> f (a, a))
-> EP w m (EpAnn AnnParen)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen
-> (forall a (f :: * -> *).
    Functor f =>
    (a -> f a) -> (a, a) -> f (a, a))
-> EP w m (EpAnn AnnParen)
markParen EpAnn AnnParen
an (a -> f a) -> (a, a) -> f (a, a)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
lfst
markClosingParen :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markClosingParen EpAnn AnnParen
an = EpAnn AnnParen
-> (forall a (f :: * -> *).
    Functor f =>
    (a -> f a) -> (a, a) -> f (a, a))
-> EP w m (EpAnn AnnParen)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen
-> (forall a (f :: * -> *).
    Functor f =>
    (a -> f a) -> (a, a) -> f (a, a))
-> EP w m (EpAnn AnnParen)
markParen EpAnn AnnParen
an (a -> f a) -> (a, a) -> f (a, a)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
lsnd

markParen :: (Monad m, Monoid w) => EpAnn AnnParen -> (forall a. Lens (a,a) a) -> EP w m (EpAnn AnnParen)
markParen :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen
-> (forall a (f :: * -> *).
    Functor f =>
    (a -> f a) -> (a, a) -> f (a, a))
-> EP w m (EpAnn AnnParen)
markParen EpAnn AnnParen
EpAnnNotUsed forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
_ = EpAnn AnnParen
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn AnnParen)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnParen
forall ann. EpAnn ann
EpAnnNotUsed)
markParen (EpAnn Anchor
anc (AnnParen ParenType
pt EpaLocation
o EpaLocation
c) EpAnnComments
cs) forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
l = do
  EpaLocation
loc' <- AnnKeywordId -> EpaLocation -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA (Getting (AnnKeywordId, AnnKeywordId) AnnKeywordId
-> (AnnKeywordId, AnnKeywordId) -> AnnKeywordId
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting (AnnKeywordId, AnnKeywordId) AnnKeywordId
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
l ((AnnKeywordId, AnnKeywordId) -> AnnKeywordId)
-> (AnnKeywordId, AnnKeywordId) -> AnnKeywordId
forall a b. (a -> b) -> a -> b
$ ParenType -> (AnnKeywordId, AnnKeywordId)
kw ParenType
pt) (Getting (EpaLocation, EpaLocation) EpaLocation
-> (EpaLocation, EpaLocation) -> EpaLocation
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting (EpaLocation, EpaLocation) EpaLocation
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
l (EpaLocation
o, EpaLocation
c))
  let (EpaLocation
o',EpaLocation
c') = Lens (EpaLocation, EpaLocation) EpaLocation
-> EpaLocation
-> (EpaLocation, EpaLocation)
-> (EpaLocation, EpaLocation)
forall a b. Lens a b -> b -> a -> a
set (EpaLocation -> f EpaLocation)
-> (EpaLocation, EpaLocation) -> f (EpaLocation, EpaLocation)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
Lens (EpaLocation, EpaLocation) EpaLocation
l EpaLocation
loc' (EpaLocation
o,EpaLocation
c)
  EpAnn AnnParen
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn AnnParen)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> AnnParen -> EpAnnComments -> EpAnn AnnParen
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (ParenType -> EpaLocation -> EpaLocation -> AnnParen
AnnParen ParenType
pt EpaLocation
o' EpaLocation
c') EpAnnComments
cs)
  where
    kw :: ParenType -> (AnnKeywordId, AnnKeywordId)
kw ParenType
AnnParens       = (AnnKeywordId
AnnOpenP,  AnnKeywordId
AnnCloseP)
    kw ParenType
AnnParensHash   = (AnnKeywordId
AnnOpenPH, AnnKeywordId
AnnClosePH)
    kw ParenType
AnnParensSquare = (AnnKeywordId
AnnOpenS, AnnKeywordId
AnnCloseS)

-- ---------------------------------------------------------------------
-- Bare bones Optics
-- Base on From https://hackage.haskell.org/package/lens-tutorial-1.0.3/docs/Control-Lens-Tutorial.html

type Lens    a b = forall f . Functor f => (b -> f        b) -> (a -> f        a)
type Getting a b =                         (b -> Const  b b) -> (a -> Const b  a)
type ASetter a b =                         (b -> Identity b) -> (a -> Identity a)

view :: MonadReader s m => Getting s a -> m a
view :: forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting s a
l = (s -> a) -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
Reader.asks (Const a s -> a
forall {k} a (b :: k). Const a b -> a
getConst (Const a s -> a) -> (s -> Const a s) -> s -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting s a
l a -> Const a a
forall {k} a (b :: k). a -> Const a b
Const)
{-# INLINE view #-}

over :: ASetter a b -> (b -> b) -> (a -> a)
over :: forall a b. ASetter a b -> (b -> b) -> a -> a
over ASetter a b
l b -> b
f = Identity a -> a
forall a. Identity a -> a
runIdentity (Identity a -> a) -> (a -> Identity a) -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ASetter a b
l (b -> Identity b
forall a. a -> Identity a
Identity (b -> Identity b) -> (b -> b) -> b -> Identity b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> b
f)
{-# INLINE over #-}

set  :: Lens a b -> b -> a -> a
set :: forall a b. Lens a b -> b -> a -> a
set Lens a b
lens b
b = ASetter a b -> (b -> b) -> a -> a
forall a b. ASetter a b -> (b -> b) -> a -> a
over ASetter a b
Lens a b
lens (\b
_ -> b
b)
{-# INLINE set #-}

{-
Question: How do I combine lenses?

Answer: You compose them, using function composition (Yes, really!)

You can think of the function composition operator as having this type:

(.) :: Lens' a b -> Lens' b c -> Lens' a c
-}

-- ---------------------------------------------------------------------
-- Lenses

-- data AnnsModule
--   = AnnsModule {
--     am_main :: [AddEpAnn],
--     am_decls :: AnnList
--     } deriving (Data, Eq)

lam_main :: Lens AnnsModule [AddEpAnn]
lam_main :: Lens AnnsModule [AddEpAnn]
lam_main [AddEpAnn] -> f [AddEpAnn]
k AnnsModule
annsModule = ([AddEpAnn] -> AnnsModule) -> f [AddEpAnn] -> f AnnsModule
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[AddEpAnn]
newAnns -> AnnsModule
annsModule { am_main = newAnns })
                             ([AddEpAnn] -> f [AddEpAnn]
k (AnnsModule -> [AddEpAnn]
am_main AnnsModule
annsModule))

-- lam_decls :: Lens AnnsModule AnnList
-- lam_decls k annsModule = fmap (\newAnns -> annsModule { am_decls = newAnns })
--                               (k (am_decls annsModule))


-- data EpAnnImportDecl = EpAnnImportDecl
--   { importDeclAnnImport    :: EpaLocation
--   , importDeclAnnPragma    :: Maybe (EpaLocation, EpaLocation)
--   , importDeclAnnSafe      :: Maybe EpaLocation
--   , importDeclAnnQualified :: Maybe EpaLocation
--   , importDeclAnnPackage   :: Maybe EpaLocation
--   , importDeclAnnAs        :: Maybe EpaLocation
--   } deriving (Data)

limportDeclAnnImport :: Lens EpAnnImportDecl EpaLocation
limportDeclAnnImport :: Lens EpAnnImportDecl EpaLocation
limportDeclAnnImport EpaLocation -> f EpaLocation
k EpAnnImportDecl
annImp = (EpaLocation -> EpAnnImportDecl)
-> f EpaLocation -> f EpAnnImportDecl
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\EpaLocation
new -> EpAnnImportDecl
annImp { importDeclAnnImport = new })
                                     (EpaLocation -> f EpaLocation
k (EpAnnImportDecl -> EpaLocation
importDeclAnnImport EpAnnImportDecl
annImp))

-- limportDeclAnnPragma :: Lens EpAnnImportDecl (Maybe (EpaLocation, EpaLocation))
-- limportDeclAnnPragma k annImp = fmap (\new -> annImp { importDeclAnnPragma = new })
--                                      (k (importDeclAnnPragma annImp))

limportDeclAnnSafe :: Lens EpAnnImportDecl (Maybe EpaLocation)
limportDeclAnnSafe :: Lens EpAnnImportDecl (Maybe EpaLocation)
limportDeclAnnSafe Maybe EpaLocation -> f (Maybe EpaLocation)
k EpAnnImportDecl
annImp = (Maybe EpaLocation -> EpAnnImportDecl)
-> f (Maybe EpaLocation) -> f EpAnnImportDecl
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe EpaLocation
new -> EpAnnImportDecl
annImp { importDeclAnnSafe = new })
                                     (Maybe EpaLocation -> f (Maybe EpaLocation)
k (EpAnnImportDecl -> Maybe EpaLocation
importDeclAnnSafe EpAnnImportDecl
annImp))

limportDeclAnnQualified :: Lens EpAnnImportDecl (Maybe EpaLocation)
limportDeclAnnQualified :: Lens EpAnnImportDecl (Maybe EpaLocation)
limportDeclAnnQualified Maybe EpaLocation -> f (Maybe EpaLocation)
k EpAnnImportDecl
annImp = (Maybe EpaLocation -> EpAnnImportDecl)
-> f (Maybe EpaLocation) -> f EpAnnImportDecl
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe EpaLocation
new -> EpAnnImportDecl
annImp { importDeclAnnQualified = new })
                                     (Maybe EpaLocation -> f (Maybe EpaLocation)
k (EpAnnImportDecl -> Maybe EpaLocation
importDeclAnnQualified EpAnnImportDecl
annImp))

limportDeclAnnPackage :: Lens EpAnnImportDecl (Maybe EpaLocation)
limportDeclAnnPackage :: Lens EpAnnImportDecl (Maybe EpaLocation)
limportDeclAnnPackage Maybe EpaLocation -> f (Maybe EpaLocation)
k EpAnnImportDecl
annImp = (Maybe EpaLocation -> EpAnnImportDecl)
-> f (Maybe EpaLocation) -> f EpAnnImportDecl
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe EpaLocation
new -> EpAnnImportDecl
annImp { importDeclAnnPackage = new })
                                     (Maybe EpaLocation -> f (Maybe EpaLocation)
k (EpAnnImportDecl -> Maybe EpaLocation
importDeclAnnPackage EpAnnImportDecl
annImp))

-- limportDeclAnnAs :: Lens EpAnnImportDecl (Maybe EpaLocation)
-- limportDeclAnnAs k annImp = fmap (\new -> annImp { importDeclAnnAs = new })
--                                      (k (importDeclAnnAs annImp))

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

-- data AnnList
--   = AnnList {
--       al_anchor    :: Maybe Anchor, -- ^ start point of a list having layout
--       al_open      :: Maybe AddEpAnn,
--       al_close     :: Maybe AddEpAnn,
--       al_rest      :: [AddEpAnn], -- ^ context, such as 'where' keyword
--       al_trailing  :: [TrailingAnn] -- ^ items appearing after the
--                                     -- list, such as '=>' for a
--                                     -- context
--       } deriving (Data,Eq)

lal_open :: Lens AnnList (Maybe AddEpAnn)
lal_open :: Lens AnnList (Maybe AddEpAnn)
lal_open Maybe AddEpAnn -> f (Maybe AddEpAnn)
k AnnList
parent = (Maybe AddEpAnn -> AnnList) -> f (Maybe AddEpAnn) -> f AnnList
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe AddEpAnn
new -> AnnList
parent { al_open = new })
                           (Maybe AddEpAnn -> f (Maybe AddEpAnn)
k (AnnList -> Maybe AddEpAnn
al_open AnnList
parent))

lal_close :: Lens AnnList (Maybe AddEpAnn)
lal_close :: Lens AnnList (Maybe AddEpAnn)
lal_close Maybe AddEpAnn -> f (Maybe AddEpAnn)
k AnnList
parent = (Maybe AddEpAnn -> AnnList) -> f (Maybe AddEpAnn) -> f AnnList
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe AddEpAnn
new -> AnnList
parent { al_close = new })
                           (Maybe AddEpAnn -> f (Maybe AddEpAnn)
k (AnnList -> Maybe AddEpAnn
al_close AnnList
parent))

lal_rest :: Lens AnnList [AddEpAnn]
lal_rest :: Lens AnnList [AddEpAnn]
lal_rest [AddEpAnn] -> f [AddEpAnn]
k AnnList
parent = ([AddEpAnn] -> AnnList) -> f [AddEpAnn] -> f AnnList
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[AddEpAnn]
new -> AnnList
parent { al_rest = new })
                           ([AddEpAnn] -> f [AddEpAnn]
k (AnnList -> [AddEpAnn]
al_rest AnnList
parent))

lal_trailing :: Lens AnnList [TrailingAnn]
lal_trailing :: Lens AnnList [TrailingAnn]
lal_trailing [TrailingAnn] -> f [TrailingAnn]
k AnnList
parent = ([TrailingAnn] -> AnnList) -> f [TrailingAnn] -> f AnnList
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[TrailingAnn]
new -> AnnList
parent { al_trailing = new })
                           ([TrailingAnn] -> f [TrailingAnn]
k (AnnList -> [TrailingAnn]
al_trailing AnnList
parent))

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

lapr_rest :: Lens AnnPragma [AddEpAnn]
lapr_rest :: Lens AnnPragma [AddEpAnn]
lapr_rest [AddEpAnn] -> f [AddEpAnn]
k AnnPragma
parent = ([AddEpAnn] -> AnnPragma) -> f [AddEpAnn] -> f AnnPragma
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[AddEpAnn]
newAnns -> AnnPragma
parent { apr_rest = newAnns })
                          ([AddEpAnn] -> f [AddEpAnn]
k (AnnPragma -> [AddEpAnn]
apr_rest AnnPragma
parent))

lapr_open :: Lens AnnPragma AddEpAnn
lapr_open :: Lens AnnPragma AddEpAnn
lapr_open AddEpAnn -> f AddEpAnn
k AnnPragma
parent = (AddEpAnn -> AnnPragma) -> f AddEpAnn -> f AnnPragma
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\AddEpAnn
new -> AnnPragma
parent { apr_open = new })
                          (AddEpAnn -> f AddEpAnn
k (AnnPragma -> AddEpAnn
apr_open AnnPragma
parent))

lapr_close :: Lens AnnPragma AddEpAnn
lapr_close :: Lens AnnPragma AddEpAnn
lapr_close AddEpAnn -> f AddEpAnn
k AnnPragma
parent = (AddEpAnn -> AnnPragma) -> f AddEpAnn -> f AnnPragma
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\AddEpAnn
new -> AnnPragma
parent { apr_close = new })
                          (AddEpAnn -> f AddEpAnn
k (AnnPragma -> AddEpAnn
apr_close AnnPragma
parent))

lidl :: Lens [AddEpAnn] [AddEpAnn]
lidl :: Lens [AddEpAnn] [AddEpAnn]
lidl [AddEpAnn] -> f [AddEpAnn]
k [AddEpAnn]
parent = ([AddEpAnn] -> [AddEpAnn]) -> f [AddEpAnn] -> f [AddEpAnn]
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[AddEpAnn]
new -> [AddEpAnn]
new)
                     ([AddEpAnn] -> f [AddEpAnn]
k [AddEpAnn]
parent)

lid :: Lens a a
lid :: forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
lid a -> f a
k a
parent = (a -> a) -> f a -> f a
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\a
new -> a
new)
                    (a -> f a
k a
parent)

lfst :: Lens (a,a) a
lfst :: forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
lfst a -> f a
k (a, a)
parent = (a -> (a, a)) -> f a -> f (a, a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\a
new -> (a
new, (a, a) -> a
forall a b. (a, b) -> b
snd (a, a)
parent))
                     (a -> f a
k ((a, a) -> a
forall a b. (a, b) -> a
fst (a, a)
parent))

lsnd :: Lens (a,a) a
lsnd :: forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
lsnd a -> f a
k (a, a)
parent = (a -> (a, a)) -> f a -> f (a, a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\a
new -> ((a, a) -> a
forall a b. (a, b) -> a
fst (a, a)
parent, a
new))
                     (a -> f a
k ((a, a) -> a
forall a b. (a, b) -> b
snd (a, a)
parent))

-- -------------------------------------
-- data AnnExplicitSum
--   = AnnExplicitSum {
--       aesOpen       :: EpaLocation,
--       aesBarsBefore :: [EpaLocation],
--       aesBarsAfter  :: [EpaLocation],
--       aesClose      :: EpaLocation
--       } deriving Data

laesOpen :: Lens AnnExplicitSum EpaLocation
laesOpen :: Lens AnnExplicitSum EpaLocation
laesOpen EpaLocation -> f EpaLocation
k AnnExplicitSum
parent = (EpaLocation -> AnnExplicitSum)
-> f EpaLocation -> f AnnExplicitSum
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\EpaLocation
new -> AnnExplicitSum
parent { aesOpen = new })
                         (EpaLocation -> f EpaLocation
k (AnnExplicitSum -> EpaLocation
aesOpen AnnExplicitSum
parent))

laesBarsBefore :: Lens AnnExplicitSum [EpaLocation]
laesBarsBefore :: Lens AnnExplicitSum [EpaLocation]
laesBarsBefore [EpaLocation] -> f [EpaLocation]
k AnnExplicitSum
parent = ([EpaLocation] -> AnnExplicitSum)
-> f [EpaLocation] -> f AnnExplicitSum
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[EpaLocation]
new -> AnnExplicitSum
parent { aesBarsBefore = new })
                               ([EpaLocation] -> f [EpaLocation]
k (AnnExplicitSum -> [EpaLocation]
aesBarsBefore AnnExplicitSum
parent))

laesBarsAfter :: Lens AnnExplicitSum [EpaLocation]
laesBarsAfter :: Lens AnnExplicitSum [EpaLocation]
laesBarsAfter [EpaLocation] -> f [EpaLocation]
k AnnExplicitSum
parent = ([EpaLocation] -> AnnExplicitSum)
-> f [EpaLocation] -> f AnnExplicitSum
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[EpaLocation]
new -> AnnExplicitSum
parent { aesBarsAfter = new })
                               ([EpaLocation] -> f [EpaLocation]
k (AnnExplicitSum -> [EpaLocation]
aesBarsAfter AnnExplicitSum
parent))

laesClose :: Lens AnnExplicitSum EpaLocation
laesClose :: Lens AnnExplicitSum EpaLocation
laesClose EpaLocation -> f EpaLocation
k AnnExplicitSum
parent = (EpaLocation -> AnnExplicitSum)
-> f EpaLocation -> f AnnExplicitSum
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\EpaLocation
new -> AnnExplicitSum
parent { aesClose = new })
                               (EpaLocation -> f EpaLocation
k (AnnExplicitSum -> EpaLocation
aesClose AnnExplicitSum
parent))

-- -------------------------------------
-- data AnnFieldLabel
--   = AnnFieldLabel {
--       afDot :: Maybe EpaLocation
--       } deriving Data

lafDot :: Lens AnnFieldLabel (Maybe EpaLocation)
lafDot :: Lens AnnFieldLabel (Maybe EpaLocation)
lafDot Maybe EpaLocation -> f (Maybe EpaLocation)
k AnnFieldLabel
parent = (Maybe EpaLocation -> AnnFieldLabel)
-> f (Maybe EpaLocation) -> f AnnFieldLabel
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe EpaLocation
new -> AnnFieldLabel
parent { afDot = new })
                         (Maybe EpaLocation -> f (Maybe EpaLocation)
k (AnnFieldLabel -> Maybe EpaLocation
afDot AnnFieldLabel
parent))

-- -------------------------------------
-- data AnnProjection
--   = AnnProjection {
--       apOpen  :: EpaLocation, -- ^ '('
--       apClose :: EpaLocation  -- ^ ')'
--       } deriving Data

lapOpen :: Lens AnnProjection EpaLocation
lapOpen :: Lens AnnProjection EpaLocation
lapOpen EpaLocation -> f EpaLocation
k AnnProjection
parent = (EpaLocation -> AnnProjection) -> f EpaLocation -> f AnnProjection
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\EpaLocation
new -> AnnProjection
parent { apOpen = new })
                         (EpaLocation -> f EpaLocation
k (AnnProjection -> EpaLocation
apOpen AnnProjection
parent))

lapClose :: Lens AnnProjection EpaLocation
lapClose :: Lens AnnProjection EpaLocation
lapClose EpaLocation -> f EpaLocation
k AnnProjection
parent = (EpaLocation -> AnnProjection) -> f EpaLocation -> f AnnProjection
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\EpaLocation
new -> AnnProjection
parent { apClose = new })
                         (EpaLocation -> f EpaLocation
k (AnnProjection -> EpaLocation
apClose AnnProjection
parent))

-- -------------------------------------
-- data AnnsIf
--   = AnnsIf {
--       aiIf       :: EpaLocation,
--       aiThen     :: EpaLocation,
--       aiElse     :: EpaLocation,
--       aiThenSemi :: Maybe EpaLocation,
--       aiElseSemi :: Maybe EpaLocation
--       } deriving Data

laiIf :: Lens AnnsIf EpaLocation
laiIf :: Lens AnnsIf EpaLocation
laiIf EpaLocation -> f EpaLocation
k AnnsIf
parent = (EpaLocation -> AnnsIf) -> f EpaLocation -> f AnnsIf
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\EpaLocation
new -> AnnsIf
parent { aiIf = new })
                      (EpaLocation -> f EpaLocation
k (AnnsIf -> EpaLocation
aiIf AnnsIf
parent))

laiThen :: Lens AnnsIf EpaLocation
laiThen :: Lens AnnsIf EpaLocation
laiThen EpaLocation -> f EpaLocation
k AnnsIf
parent = (EpaLocation -> AnnsIf) -> f EpaLocation -> f AnnsIf
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\EpaLocation
new -> AnnsIf
parent { aiThen = new })
                        (EpaLocation -> f EpaLocation
k (AnnsIf -> EpaLocation
aiThen AnnsIf
parent))

laiElse :: Lens AnnsIf EpaLocation
laiElse :: Lens AnnsIf EpaLocation
laiElse EpaLocation -> f EpaLocation
k AnnsIf
parent = (EpaLocation -> AnnsIf) -> f EpaLocation -> f AnnsIf
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\EpaLocation
new -> AnnsIf
parent { aiElse = new })
                        (EpaLocation -> f EpaLocation
k (AnnsIf -> EpaLocation
aiElse AnnsIf
parent))

laiThenSemi :: Lens AnnsIf (Maybe EpaLocation)
laiThenSemi :: Lens AnnsIf (Maybe EpaLocation)
laiThenSemi Maybe EpaLocation -> f (Maybe EpaLocation)
k AnnsIf
parent = (Maybe EpaLocation -> AnnsIf) -> f (Maybe EpaLocation) -> f AnnsIf
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe EpaLocation
new -> AnnsIf
parent { aiThenSemi = new })
                            (Maybe EpaLocation -> f (Maybe EpaLocation)
k (AnnsIf -> Maybe EpaLocation
aiThenSemi AnnsIf
parent))

laiElseSemi :: Lens AnnsIf (Maybe EpaLocation)
laiElseSemi :: Lens AnnsIf (Maybe EpaLocation)
laiElseSemi Maybe EpaLocation -> f (Maybe EpaLocation)
k AnnsIf
parent = (Maybe EpaLocation -> AnnsIf) -> f (Maybe EpaLocation) -> f AnnsIf
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe EpaLocation
new -> AnnsIf
parent { aiElseSemi = new })
                            (Maybe EpaLocation -> f (Maybe EpaLocation)
k (AnnsIf -> Maybe EpaLocation
aiElseSemi AnnsIf
parent))

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

-- data AnnParen
--   = AnnParen {
--       ap_adornment :: ParenType,
--       ap_open      :: EpaLocation,
--       ap_close     :: EpaLocation
--       } deriving (Data)

-- lap_open :: Lens AnnParen EpaLocation
-- lap_open k parent = fmap (\new -> parent { ap_open = new })
--                          (k (ap_open parent))

-- lap_close :: Lens AnnParen EpaLocation
-- lap_close k parent = fmap (\new -> parent { ap_close = new })
--                           (k (ap_close parent))

-- -------------------------------------
-- data EpAnnHsCase = EpAnnHsCase
--       { hsCaseAnnCase :: EpaLocation
--       , hsCaseAnnOf   :: EpaLocation
--       , hsCaseAnnsRest :: [AddEpAnn]
--       } deriving Data

lhsCaseAnnCase :: Lens EpAnnHsCase EpaLocation
lhsCaseAnnCase :: Lens EpAnnHsCase EpaLocation
lhsCaseAnnCase EpaLocation -> f EpaLocation
k EpAnnHsCase
parent = (EpaLocation -> EpAnnHsCase) -> f EpaLocation -> f EpAnnHsCase
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\EpaLocation
new -> EpAnnHsCase
parent { hsCaseAnnCase = new })
                               (EpaLocation -> f EpaLocation
k (EpAnnHsCase -> EpaLocation
hsCaseAnnCase EpAnnHsCase
parent))

lhsCaseAnnOf :: Lens EpAnnHsCase EpaLocation
lhsCaseAnnOf :: Lens EpAnnHsCase EpaLocation
lhsCaseAnnOf EpaLocation -> f EpaLocation
k EpAnnHsCase
parent = (EpaLocation -> EpAnnHsCase) -> f EpaLocation -> f EpAnnHsCase
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\EpaLocation
new -> EpAnnHsCase
parent { hsCaseAnnOf = new })
                               (EpaLocation -> f EpaLocation
k (EpAnnHsCase -> EpaLocation
hsCaseAnnOf EpAnnHsCase
parent))

lhsCaseAnnsRest :: Lens EpAnnHsCase [AddEpAnn]
lhsCaseAnnsRest :: Lens EpAnnHsCase [AddEpAnn]
lhsCaseAnnsRest [AddEpAnn] -> f [AddEpAnn]
k EpAnnHsCase
parent = ([AddEpAnn] -> EpAnnHsCase) -> f [AddEpAnn] -> f EpAnnHsCase
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[AddEpAnn]
new -> EpAnnHsCase
parent { hsCaseAnnsRest = new })
                                ([AddEpAnn] -> f [AddEpAnn]
k (EpAnnHsCase -> [AddEpAnn]
hsCaseAnnsRest EpAnnHsCase
parent))

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

-- data HsRuleAnn
--   = HsRuleAnn
--        { ra_tyanns :: Maybe (AddEpAnn, AddEpAnn)
--                  -- ^ The locations of 'forall' and '.' for forall'd type vars
--                  -- Using AddEpAnn to capture possible unicode variants
--        , ra_tmanns :: Maybe (AddEpAnn, AddEpAnn)
--                  -- ^ The locations of 'forall' and '.' for forall'd term vars
--                  -- Using AddEpAnn to capture possible unicode variants
--        , ra_rest :: [AddEpAnn]
--        } deriving (Data, Eq)

lra_tyanns :: Lens HsRuleAnn (Maybe (AddEpAnn, AddEpAnn))
lra_tyanns :: Lens HsRuleAnn (Maybe (AddEpAnn, AddEpAnn))
lra_tyanns Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn))
k HsRuleAnn
parent = (Maybe (AddEpAnn, AddEpAnn) -> HsRuleAnn)
-> f (Maybe (AddEpAnn, AddEpAnn)) -> f HsRuleAnn
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe (AddEpAnn, AddEpAnn)
new -> HsRuleAnn
parent { ra_tyanns = new })
                               (Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn))
k (HsRuleAnn -> Maybe (AddEpAnn, AddEpAnn)
ra_tyanns HsRuleAnn
parent))

ff :: Maybe (a,b) -> (Maybe a,Maybe b)
ff :: forall a b. Maybe (a, b) -> (Maybe a, Maybe b)
ff Maybe (a, b)
Nothing = (Maybe a
forall a. Maybe a
Nothing, Maybe b
forall a. Maybe a
Nothing)
ff (Just (a
a,b
b)) = (a -> Maybe a
forall a. a -> Maybe a
Just a
a, b -> Maybe b
forall a. a -> Maybe a
Just b
b)


gg :: (Maybe a,Maybe b) -> Maybe (a,b)
gg :: forall a b. (Maybe a, Maybe b) -> Maybe (a, b)
gg (Maybe a
Nothing, Maybe b
Nothing) = Maybe (a, b)
forall a. Maybe a
Nothing
gg (Just a
a, Just b
b) = (a, b) -> Maybe (a, b)
forall a. a -> Maybe a
Just (a
a,b
b)
gg (Maybe a, Maybe b)
_ = String -> Maybe (a, b)
forall a. HasCallStack => String -> a
error String
"gg:expecting two Nothing or two Just"

lff :: Lens (Maybe (a,b)) (Maybe a,Maybe b)
lff :: forall a b (f :: * -> *).
Functor f =>
((Maybe a, Maybe b) -> f (Maybe a, Maybe b))
-> Maybe (a, b) -> f (Maybe (a, b))
lff (Maybe a, Maybe b) -> f (Maybe a, Maybe b)
k Maybe (a, b)
parent = ((Maybe a, Maybe b) -> Maybe (a, b))
-> f (Maybe a, Maybe b) -> f (Maybe (a, b))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Maybe a, Maybe b)
new -> (Maybe a, Maybe b) -> Maybe (a, b)
forall a b. (Maybe a, Maybe b) -> Maybe (a, b)
gg (Maybe a, Maybe b)
new)
                    ((Maybe a, Maybe b) -> f (Maybe a, Maybe b)
k (Maybe (a, b) -> (Maybe a, Maybe b)
forall a b. Maybe (a, b) -> (Maybe a, Maybe b)
ff Maybe (a, b)
parent))

-- (.) :: Lens' a b -> Lens' b c -> Lens' a c
lra_tyanns_fst :: Lens HsRuleAnn (Maybe AddEpAnn)
lra_tyanns_fst :: Lens HsRuleAnn (Maybe AddEpAnn)
lra_tyanns_fst = (Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> HsRuleAnn -> f HsRuleAnn
Lens HsRuleAnn (Maybe (AddEpAnn, AddEpAnn))
lra_tyanns ((Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
 -> HsRuleAnn -> f HsRuleAnn)
-> ((Maybe AddEpAnn -> f (Maybe AddEpAnn))
    -> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> HsRuleAnn
-> f HsRuleAnn
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Maybe AddEpAnn, Maybe AddEpAnn)
 -> f (Maybe AddEpAnn, Maybe AddEpAnn))
-> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn))
forall a b (f :: * -> *).
Functor f =>
((Maybe a, Maybe b) -> f (Maybe a, Maybe b))
-> Maybe (a, b) -> f (Maybe (a, b))
lff (((Maybe AddEpAnn, Maybe AddEpAnn)
  -> f (Maybe AddEpAnn, Maybe AddEpAnn))
 -> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> ((Maybe AddEpAnn -> f (Maybe AddEpAnn))
    -> (Maybe AddEpAnn, Maybe AddEpAnn)
    -> f (Maybe AddEpAnn, Maybe AddEpAnn))
-> (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> Maybe (AddEpAnn, AddEpAnn)
-> f (Maybe (AddEpAnn, AddEpAnn))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> (Maybe AddEpAnn, Maybe AddEpAnn)
-> f (Maybe AddEpAnn, Maybe AddEpAnn)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
lfst

lra_tyanns_snd :: Lens HsRuleAnn (Maybe AddEpAnn)
lra_tyanns_snd :: Lens HsRuleAnn (Maybe AddEpAnn)
lra_tyanns_snd = (Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> HsRuleAnn -> f HsRuleAnn
Lens HsRuleAnn (Maybe (AddEpAnn, AddEpAnn))
lra_tyanns ((Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
 -> HsRuleAnn -> f HsRuleAnn)
-> ((Maybe AddEpAnn -> f (Maybe AddEpAnn))
    -> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> HsRuleAnn
-> f HsRuleAnn
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Maybe AddEpAnn, Maybe AddEpAnn)
 -> f (Maybe AddEpAnn, Maybe AddEpAnn))
-> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn))
forall a b (f :: * -> *).
Functor f =>
((Maybe a, Maybe b) -> f (Maybe a, Maybe b))
-> Maybe (a, b) -> f (Maybe (a, b))
lff (((Maybe AddEpAnn, Maybe AddEpAnn)
  -> f (Maybe AddEpAnn, Maybe AddEpAnn))
 -> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> ((Maybe AddEpAnn -> f (Maybe AddEpAnn))
    -> (Maybe AddEpAnn, Maybe AddEpAnn)
    -> f (Maybe AddEpAnn, Maybe AddEpAnn))
-> (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> Maybe (AddEpAnn, AddEpAnn)
-> f (Maybe (AddEpAnn, AddEpAnn))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> (Maybe AddEpAnn, Maybe AddEpAnn)
-> f (Maybe AddEpAnn, Maybe AddEpAnn)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
lsnd

lra_tmanns :: Lens HsRuleAnn (Maybe (AddEpAnn, AddEpAnn))
lra_tmanns :: Lens HsRuleAnn (Maybe (AddEpAnn, AddEpAnn))
lra_tmanns Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn))
k HsRuleAnn
parent = (Maybe (AddEpAnn, AddEpAnn) -> HsRuleAnn)
-> f (Maybe (AddEpAnn, AddEpAnn)) -> f HsRuleAnn
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe (AddEpAnn, AddEpAnn)
new -> HsRuleAnn
parent { ra_tmanns = new })
                               (Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn))
k (HsRuleAnn -> Maybe (AddEpAnn, AddEpAnn)
ra_tmanns HsRuleAnn
parent))

lra_tmanns_fst :: Lens HsRuleAnn (Maybe AddEpAnn)
lra_tmanns_fst :: Lens HsRuleAnn (Maybe AddEpAnn)
lra_tmanns_fst = (Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> HsRuleAnn -> f HsRuleAnn
Lens HsRuleAnn (Maybe (AddEpAnn, AddEpAnn))
lra_tmanns ((Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
 -> HsRuleAnn -> f HsRuleAnn)
-> ((Maybe AddEpAnn -> f (Maybe AddEpAnn))
    -> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> HsRuleAnn
-> f HsRuleAnn
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Maybe AddEpAnn, Maybe AddEpAnn)
 -> f (Maybe AddEpAnn, Maybe AddEpAnn))
-> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn))
forall a b (f :: * -> *).
Functor f =>
((Maybe a, Maybe b) -> f (Maybe a, Maybe b))
-> Maybe (a, b) -> f (Maybe (a, b))
lff (((Maybe AddEpAnn, Maybe AddEpAnn)
  -> f (Maybe AddEpAnn, Maybe AddEpAnn))
 -> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> ((Maybe AddEpAnn -> f (Maybe AddEpAnn))
    -> (Maybe AddEpAnn, Maybe AddEpAnn)
    -> f (Maybe AddEpAnn, Maybe AddEpAnn))
-> (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> Maybe (AddEpAnn, AddEpAnn)
-> f (Maybe (AddEpAnn, AddEpAnn))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> (Maybe AddEpAnn, Maybe AddEpAnn)
-> f (Maybe AddEpAnn, Maybe AddEpAnn)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
lfst

lra_tmanns_snd :: Lens HsRuleAnn (Maybe AddEpAnn)
lra_tmanns_snd :: Lens HsRuleAnn (Maybe AddEpAnn)
lra_tmanns_snd = (Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> HsRuleAnn -> f HsRuleAnn
Lens HsRuleAnn (Maybe (AddEpAnn, AddEpAnn))
lra_tmanns ((Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
 -> HsRuleAnn -> f HsRuleAnn)
-> ((Maybe AddEpAnn -> f (Maybe AddEpAnn))
    -> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> HsRuleAnn
-> f HsRuleAnn
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Maybe AddEpAnn, Maybe AddEpAnn)
 -> f (Maybe AddEpAnn, Maybe AddEpAnn))
-> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn))
forall a b (f :: * -> *).
Functor f =>
((Maybe a, Maybe b) -> f (Maybe a, Maybe b))
-> Maybe (a, b) -> f (Maybe (a, b))
lff (((Maybe AddEpAnn, Maybe AddEpAnn)
  -> f (Maybe AddEpAnn, Maybe AddEpAnn))
 -> Maybe (AddEpAnn, AddEpAnn) -> f (Maybe (AddEpAnn, AddEpAnn)))
-> ((Maybe AddEpAnn -> f (Maybe AddEpAnn))
    -> (Maybe AddEpAnn, Maybe AddEpAnn)
    -> f (Maybe AddEpAnn, Maybe AddEpAnn))
-> (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> Maybe (AddEpAnn, AddEpAnn)
-> f (Maybe (AddEpAnn, AddEpAnn))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe AddEpAnn -> f (Maybe AddEpAnn))
-> (Maybe AddEpAnn, Maybe AddEpAnn)
-> f (Maybe AddEpAnn, Maybe AddEpAnn)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
lsnd

lra_rest :: Lens HsRuleAnn [AddEpAnn]
lra_rest :: Lens HsRuleAnn [AddEpAnn]
lra_rest [AddEpAnn] -> f [AddEpAnn]
k HsRuleAnn
parent = ([AddEpAnn] -> HsRuleAnn) -> f [AddEpAnn] -> f HsRuleAnn
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[AddEpAnn]
new -> HsRuleAnn
parent { ra_rest = new })
                                ([AddEpAnn] -> f [AddEpAnn]
k (HsRuleAnn -> [AddEpAnn]
ra_rest HsRuleAnn
parent))


-- ---------------------------------------------------------------------
-- data GrhsAnn
--   = GrhsAnn {
--       ga_vbar :: Maybe EpaLocation, -- TODO:AZ do we need this?
--       ga_sep  :: AddEpAnn -- ^ Match separator location
--       } deriving (Data)

lga_vbar :: Lens GrhsAnn (Maybe EpaLocation)
lga_vbar :: Lens GrhsAnn (Maybe EpaLocation)
lga_vbar Maybe EpaLocation -> f (Maybe EpaLocation)
k GrhsAnn
parent = (Maybe EpaLocation -> GrhsAnn)
-> f (Maybe EpaLocation) -> f GrhsAnn
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Maybe EpaLocation
new -> GrhsAnn
parent { ga_vbar = new })
                                (Maybe EpaLocation -> f (Maybe EpaLocation)
k (GrhsAnn -> Maybe EpaLocation
ga_vbar GrhsAnn
parent))

lga_sep :: Lens GrhsAnn AddEpAnn
lga_sep :: Lens GrhsAnn AddEpAnn
lga_sep AddEpAnn -> f AddEpAnn
k GrhsAnn
parent = (AddEpAnn -> GrhsAnn) -> f AddEpAnn -> f GrhsAnn
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\AddEpAnn
new -> GrhsAnn
parent { ga_sep = new })
                                (AddEpAnn -> f AddEpAnn
k (GrhsAnn -> AddEpAnn
ga_sep GrhsAnn
parent))

-- ---------------------------------------------------------------------
-- data AnnSig
--   = AnnSig {
--       asDcolon :: AddEpAnn, -- Not an EpaAnchor to capture unicode option
--       asRest   :: [AddEpAnn]
--       } deriving Data

lasDcolon :: Lens AnnSig AddEpAnn
lasDcolon :: Lens AnnSig AddEpAnn
lasDcolon AddEpAnn -> f AddEpAnn
k AnnSig
parent = (AddEpAnn -> AnnSig) -> f AddEpAnn -> f AnnSig
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\AddEpAnn
new -> AnnSig
parent { asDcolon = new })
                                (AddEpAnn -> f AddEpAnn
k (AnnSig -> AddEpAnn
asDcolon AnnSig
parent))

lasRest :: Lens AnnSig [AddEpAnn]
lasRest :: Lens AnnSig [AddEpAnn]
lasRest [AddEpAnn] -> f [AddEpAnn]
k AnnSig
parent = ([AddEpAnn] -> AnnSig) -> f [AddEpAnn] -> f AnnSig
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[AddEpAnn]
new -> AnnSig
parent { asRest = new })
                                ([AddEpAnn] -> f [AddEpAnn]
k (AnnSig -> [AddEpAnn]
asRest AnnSig
parent))

-- ---------------------------------------------------------------------
-- data EpAnnSumPat = EpAnnSumPat
--       { sumPatParens      :: [AddEpAnn]
--       , sumPatVbarsBefore :: [EpaLocation]
--       , sumPatVbarsAfter  :: [EpaLocation]
--       } deriving Data

lsumPatParens :: Lens EpAnnSumPat [AddEpAnn]
lsumPatParens :: Lens EpAnnSumPat [AddEpAnn]
lsumPatParens [AddEpAnn] -> f [AddEpAnn]
k EpAnnSumPat
parent = ([AddEpAnn] -> EpAnnSumPat) -> f [AddEpAnn] -> f EpAnnSumPat
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[AddEpAnn]
new -> EpAnnSumPat
parent { sumPatParens = new })
                              ([AddEpAnn] -> f [AddEpAnn]
k (EpAnnSumPat -> [AddEpAnn]
sumPatParens EpAnnSumPat
parent))

lsumPatVbarsBefore :: Lens EpAnnSumPat [EpaLocation]
lsumPatVbarsBefore :: Lens EpAnnSumPat [EpaLocation]
lsumPatVbarsBefore [EpaLocation] -> f [EpaLocation]
k EpAnnSumPat
parent = ([EpaLocation] -> EpAnnSumPat) -> f [EpaLocation] -> f EpAnnSumPat
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[EpaLocation]
new -> EpAnnSumPat
parent { sumPatVbarsBefore = new })
                              ([EpaLocation] -> f [EpaLocation]
k (EpAnnSumPat -> [EpaLocation]
sumPatVbarsBefore EpAnnSumPat
parent))

lsumPatVbarsAfter :: Lens EpAnnSumPat [EpaLocation]
lsumPatVbarsAfter :: Lens EpAnnSumPat [EpaLocation]
lsumPatVbarsAfter [EpaLocation] -> f [EpaLocation]
k EpAnnSumPat
parent = ([EpaLocation] -> EpAnnSumPat) -> f [EpaLocation] -> f EpAnnSumPat
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[EpaLocation]
new -> EpAnnSumPat
parent { sumPatVbarsAfter = new })
                              ([EpaLocation] -> f [EpaLocation]
k (EpAnnSumPat -> [EpaLocation]
sumPatVbarsAfter EpAnnSumPat
parent))

-- End of lenses
-- ---------------------------------------------------------------------

markLensKwA :: (Monad m, Monoid w)
  => EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensKwA :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensKwA EpAnn a
EpAnnNotUsed  Lens a AddEpAnn
_    = EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
markLensKwA (EpAnn Anchor
anc a
a EpAnnComments
cs) Lens a AddEpAnn
l = do
  AddEpAnn
loc <- AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
markKw (Getting a AddEpAnn -> a -> AddEpAnn
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a AddEpAnn
Lens a AddEpAnn
l a
a)
  EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a AddEpAnn -> AddEpAnn -> a -> a
forall a b. Lens a b -> b -> a -> a
set (AddEpAnn -> f AddEpAnn) -> a -> f a
Lens a AddEpAnn
l AddEpAnn
loc a
a) EpAnnComments
cs)

markLensKw :: (Monad m, Monoid w)
  => EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw EpAnn a
EpAnnNotUsed  Lens a EpaLocation
_ AnnKeywordId
_  = EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
markLensKw (EpAnn Anchor
anc a
a EpAnnComments
cs) Lens a EpaLocation
l AnnKeywordId
kw = do
  EpaLocation
loc <- AnnKeywordId -> EpaLocation -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
kw (Getting a EpaLocation -> a -> EpaLocation
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a EpaLocation
Lens a EpaLocation
l a
a)
  EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a EpaLocation -> EpaLocation -> a -> a
forall a b. Lens a b -> b -> a -> a
set (EpaLocation -> f EpaLocation) -> a -> f a
Lens a EpaLocation
l EpaLocation
loc a
a) EpAnnComments
cs)

markAnnKwL :: (Monad m, Monoid w)
  => EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwL :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwL = EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw

markAnnKwAllL :: (Monad m, Monoid w)
  => EpAnn a -> Lens a [EpaLocation] -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwAllL :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [EpaLocation] -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwAllL EpAnn a
EpAnnNotUsed  Lens a [EpaLocation]
_ AnnKeywordId
_  = EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
markAnnKwAllL (EpAnn Anchor
anc a
a EpAnnComments
cs) Lens a [EpaLocation]
l AnnKeywordId
kw = do
  [EpaLocation]
anns <- (EpaLocation
 -> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation)
-> [EpaLocation]
-> RWST (EPOptions m w) (EPWriter w) EPState m [EpaLocation]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (AnnKeywordId
-> EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
kw) (Getting a [EpaLocation] -> a -> [EpaLocation]
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a [EpaLocation]
Lens a [EpaLocation]
l a
a)
  EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a [EpaLocation] -> [EpaLocation] -> a -> a
forall a b. Lens a b -> b -> a -> a
set ([EpaLocation] -> f [EpaLocation]) -> a -> f a
Lens a [EpaLocation]
l [EpaLocation]
anns a
a) EpAnnComments
cs)

markLensKwM :: (Monad m, Monoid w)
  => EpAnn a -> Lens a (Maybe EpaLocation) -> AnnKeywordId -> EP w m (EpAnn a)
markLensKwM :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a (Maybe EpaLocation) -> AnnKeywordId -> EP w m (EpAnn a)
markLensKwM EpAnn a
EpAnnNotUsed  Lens a (Maybe EpaLocation)
_ AnnKeywordId
_ = EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
markLensKwM (EpAnn Anchor
anc a
a EpAnnComments
cs) Lens a (Maybe EpaLocation)
l AnnKeywordId
kw = do
  Maybe EpaLocation
new <- Maybe EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe EpaLocation)
go (Getting a (Maybe EpaLocation) -> a -> Maybe EpaLocation
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a (Maybe EpaLocation)
Lens a (Maybe EpaLocation)
l a
a)
  EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a (Maybe EpaLocation) -> Maybe EpaLocation -> a -> a
forall a b. Lens a b -> b -> a -> a
set (Maybe EpaLocation -> f (Maybe EpaLocation)) -> a -> f a
Lens a (Maybe EpaLocation)
l Maybe EpaLocation
new a
a) EpAnnComments
cs)
  where
    go :: Maybe EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe EpaLocation)
go Maybe EpaLocation
Nothing = Maybe EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe EpaLocation)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe EpaLocation
forall a. Maybe a
Nothing
    go (Just EpaLocation
s) = EpaLocation -> Maybe EpaLocation
forall a. a -> Maybe a
Just (EpaLocation -> Maybe EpaLocation)
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe EpaLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnnKeywordId
-> EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
kw EpaLocation
s

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

markALocatedA :: (Monad m, Monoid w) => EpAnn AnnListItem -> EP w m (EpAnn AnnListItem)
markALocatedA :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnListItem -> EP w m (EpAnn AnnListItem)
markALocatedA EpAnn AnnListItem
EpAnnNotUsed  = EpAnn AnnListItem
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn AnnListItem)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn AnnListItem
forall ann. EpAnn ann
EpAnnNotUsed
markALocatedA (EpAnn Anchor
anc AnnListItem
a EpAnnComments
cs) = do
  [TrailingAnn]
t <- [TrailingAnn] -> EP w m [TrailingAnn]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[TrailingAnn] -> EP w m [TrailingAnn]
markTrailing (AnnListItem -> [TrailingAnn]
lann_trailing AnnListItem
a)
  EpAnn AnnListItem
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn AnnListItem)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> AnnListItem -> EpAnnComments -> EpAnn AnnListItem
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (AnnListItem
a { lann_trailing = t }) EpAnnComments
cs)

markEpAnnL :: (Monad m, Monoid w)
  => EpAnn ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL :: forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn ann
EpAnnNotUsed Lens ann [AddEpAnn]
_ AnnKeywordId
_ = EpAnn ann
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn ann)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn ann
forall ann. EpAnn ann
EpAnnNotUsed
markEpAnnL (EpAnn Anchor
anc ann
a EpAnnComments
cs) Lens ann [AddEpAnn]
l AnnKeywordId
kw = do
  [AddEpAnn]
anns <- [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn]
mark' (Getting ann [AddEpAnn] -> ann -> [AddEpAnn]
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting ann [AddEpAnn]
Lens ann [AddEpAnn]
l ann
a) AnnKeywordId
kw
  EpAnn ann
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn ann)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> ann -> EpAnnComments -> EpAnn ann
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens ann [AddEpAnn] -> [AddEpAnn] -> ann -> ann
forall a b. Lens a b -> b -> a -> a
set ([AddEpAnn] -> f [AddEpAnn]) -> ann -> f ann
Lens ann [AddEpAnn]
l [AddEpAnn]
anns ann
a) EpAnnComments
cs)

markEpAnnAllL :: (Monad m, Monoid w)
  => EpAnn ann -> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL :: forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn ann
EpAnnNotUsed Lens ann [AddEpAnn]
_ AnnKeywordId
_ = EpAnn ann
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn ann)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn ann
forall ann. EpAnn ann
EpAnnNotUsed
markEpAnnAllL (EpAnn Anchor
anc ann
a EpAnnComments
cs) Lens ann [AddEpAnn]
l AnnKeywordId
kw = do
  [AddEpAnn]
anns <- (AddEpAnn -> RWST (EPOptions m w) (EPWriter w) EPState m AddEpAnn)
-> [AddEpAnn]
-> RWST (EPOptions m w) (EPWriter w) EPState m [AddEpAnn]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM AddEpAnn -> RWST (EPOptions m w) (EPWriter w) EPState m AddEpAnn
doit (Getting ann [AddEpAnn] -> ann -> [AddEpAnn]
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting ann [AddEpAnn]
Lens ann [AddEpAnn]
l ann
a)
  EpAnn ann
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn ann)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> ann -> EpAnnComments -> EpAnn ann
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens ann [AddEpAnn] -> [AddEpAnn] -> ann -> ann
forall a b. Lens a b -> b -> a -> a
set ([AddEpAnn] -> f [AddEpAnn]) -> ann -> f ann
Lens ann [AddEpAnn]
l [AddEpAnn]
anns ann
a) EpAnnComments
cs)
  where
    doit :: AddEpAnn -> RWST (EPOptions m w) (EPWriter w) EPState m AddEpAnn
doit an :: AddEpAnn
an@(AddEpAnn AnnKeywordId
ka EpaLocation
_)
      = if AnnKeywordId
ka AnnKeywordId -> AnnKeywordId -> Bool
forall a. Eq a => a -> a -> Bool
== AnnKeywordId
kw
          then AddEpAnn -> RWST (EPOptions m w) (EPWriter w) EPState m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
markKw AddEpAnn
an
          else AddEpAnn -> RWST (EPOptions m w) (EPWriter w) EPState m AddEpAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return AddEpAnn
an

markAddEpAnn :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn
markAddEpAnn :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
markAddEpAnn a :: AddEpAnn
a@(AddEpAnn AnnKeywordId
kw EpaLocation
_) = do
  [AddEpAnn]
r <- [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn]
mark' [AddEpAnn
a] AnnKeywordId
kw
  case [AddEpAnn]
r of
    [AddEpAnn
a'] -> AddEpAnn -> EP w m AddEpAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return AddEpAnn
a'
    [AddEpAnn]
_ -> String -> EP w m AddEpAnn
forall a. HasCallStack => String -> a
error String
"Should not happen: markAddEpAnn"

mark' :: (Monad m, Monoid w) => [AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn]
mark' :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[AddEpAnn] -> AnnKeywordId -> EP w m [AddEpAnn]
mark' [AddEpAnn]
anns AnnKeywordId
kw = do
  case AnnKeywordId
-> [AddEpAnn] -> ([AddEpAnn], Maybe AddEpAnn, [AddEpAnn])
find' AnnKeywordId
kw [AddEpAnn]
anns of
    ([AddEpAnn]
lead, Just AddEpAnn
aa, [AddEpAnn]
end) -> do
      AddEpAnn
aa' <- AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
markKw AddEpAnn
aa
      [AddEpAnn] -> EP w m [AddEpAnn]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([AddEpAnn]
lead [AddEpAnn] -> [AddEpAnn] -> [AddEpAnn]
forall a. [a] -> [a] -> [a]
++ [AddEpAnn
aa'] [AddEpAnn] -> [AddEpAnn] -> [AddEpAnn]
forall a. [a] -> [a] -> [a]
++ [AddEpAnn]
end)
    ([AddEpAnn]
_lead, Maybe AddEpAnn
Nothing, [AddEpAnn]
_end) -> case AnnKeywordId
-> [AddEpAnn] -> ([AddEpAnn], Maybe AddEpAnn, [AddEpAnn])
find' (AnnKeywordId -> AnnKeywordId
unicodeAnn AnnKeywordId
kw) [AddEpAnn]
anns of
      ([AddEpAnn]
leadu, Just AddEpAnn
aau, [AddEpAnn]
endu) -> do
        AddEpAnn
aau' <- AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
markKw AddEpAnn
aau
        [AddEpAnn] -> EP w m [AddEpAnn]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([AddEpAnn]
leadu [AddEpAnn] -> [AddEpAnn] -> [AddEpAnn]
forall a. [a] -> [a] -> [a]
++ [AddEpAnn
aau'] [AddEpAnn] -> [AddEpAnn] -> [AddEpAnn]
forall a. [a] -> [a] -> [a]
++ [AddEpAnn]
endu)
      ([AddEpAnn]
_,Maybe AddEpAnn
Nothing,[AddEpAnn]
_) -> [AddEpAnn] -> EP w m [AddEpAnn]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return [AddEpAnn]
anns

-- | Find for update, returning lead section of the list, item if
-- found, and tail of the list
find' :: AnnKeywordId -> [AddEpAnn] -> ([AddEpAnn], Maybe AddEpAnn, [AddEpAnn])
find' :: AnnKeywordId
-> [AddEpAnn] -> ([AddEpAnn], Maybe AddEpAnn, [AddEpAnn])
find' AnnKeywordId
kw [AddEpAnn]
anns = ([AddEpAnn]
lead, Maybe AddEpAnn
middle, [AddEpAnn]
end)
  where
    ([AddEpAnn]
lead, [AddEpAnn]
rest) = (AddEpAnn -> Bool) -> [AddEpAnn] -> ([AddEpAnn], [AddEpAnn])
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (\(AddEpAnn AnnKeywordId
k EpaLocation
_) -> AnnKeywordId
k AnnKeywordId -> AnnKeywordId -> Bool
forall a. Eq a => a -> a -> Bool
== AnnKeywordId
kw) [AddEpAnn]
anns
    (Maybe AddEpAnn
middle,[AddEpAnn]
end) = case [AddEpAnn]
rest of
      [] -> (Maybe AddEpAnn
forall a. Maybe a
Nothing, [])
      (AddEpAnn
x:[AddEpAnn]
xs) -> (AddEpAnn -> Maybe AddEpAnn
forall a. a -> Maybe a
Just AddEpAnn
x, [AddEpAnn]
xs)

markKw :: (Monad m, Monoid w) => AddEpAnn -> EP w m AddEpAnn
markKw :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
markKw AddEpAnn
an = CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
CaptureComments AddEpAnn
an

markKwC :: (Monad m, Monoid w) => CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
capture (AddEpAnn AnnKeywordId
kw EpaLocation
ss) = do
  EpaLocation
ss' <- CaptureComments
-> AnnKeywordId -> EpaLocation -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments
-> AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwAC CaptureComments
capture AnnKeywordId
kw EpaLocation
ss
  AddEpAnn -> EP w m AddEpAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kw EpaLocation
ss')

-- | This should be the main driver of the process, managing printing keywords.
-- It returns the 'EpaDelta' variant of the passed in 'EpaLocation'
markKwA :: (Monad m, Monoid w) => AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
kw EpaLocation
aa = CaptureComments
-> AnnKeywordId -> EpaLocation -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments
-> AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwAC CaptureComments
CaptureComments AnnKeywordId
kw EpaLocation
aa

markKwAC :: (Monad m, Monoid w)
  => CaptureComments -> AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwAC :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments
-> AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwAC CaptureComments
capture AnnKeywordId
kw EpaLocation
aa = CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
printStringAtAAC CaptureComments
capture EpaLocation
aa (AnnKeywordId -> String
keywordToString AnnKeywordId
kw)

-- | Print a keyword encoded in a 'TrailingAnn'
markKwT :: (Monad m, Monoid w) => TrailingAnn -> EP w m TrailingAnn
markKwT :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
TrailingAnn -> EP w m TrailingAnn
markKwT (AddSemiAnn EpaLocation
ss)    = EpaLocation -> TrailingAnn
AddSemiAnn    (EpaLocation -> TrailingAnn)
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m TrailingAnn
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnnKeywordId
-> EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
AnnSemi EpaLocation
ss
markKwT (AddCommaAnn EpaLocation
ss)   = EpaLocation -> TrailingAnn
AddCommaAnn   (EpaLocation -> TrailingAnn)
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m TrailingAnn
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnnKeywordId
-> EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
AnnComma EpaLocation
ss
markKwT (AddVbarAnn EpaLocation
ss)    = EpaLocation -> TrailingAnn
AddVbarAnn    (EpaLocation -> TrailingAnn)
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m TrailingAnn
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnnKeywordId
-> EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
AnnVbar EpaLocation
ss

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

markAnnList :: (Monad m, Monoid w)
  => Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList Bool
reallyTrail EpAnn AnnList
ann EP w m a
action = do
  Bool
-> EpAnn AnnList
-> (EpAnn AnnList -> EP w m (EpAnn AnnList, a))
-> EP w m (EpAnn AnnList, a)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool
-> EpAnn AnnList
-> (EpAnn AnnList -> EP w m (EpAnn AnnList, a))
-> EP w m (EpAnn AnnList, a)
markAnnListA Bool
reallyTrail EpAnn AnnList
ann ((EpAnn AnnList -> EP w m (EpAnn AnnList, a))
 -> EP w m (EpAnn AnnList, a))
-> (EpAnn AnnList -> EP w m (EpAnn AnnList, a))
-> EP w m (EpAnn AnnList, a)
forall a b. (a -> b) -> a -> b
$ \EpAnn AnnList
a -> do
    a
r <- EP w m a
action
    (EpAnn AnnList, a) -> EP w m (EpAnn AnnList, a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnList
a,a
r)

markAnnListA :: (Monad m, Monoid w)
  => Bool -> EpAnn AnnList
  -> (EpAnn AnnList -> EP w m (EpAnn AnnList, a))
  -> EP w m (EpAnn AnnList, a)
markAnnListA :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool
-> EpAnn AnnList
-> (EpAnn AnnList -> EP w m (EpAnn AnnList, a))
-> EP w m (EpAnn AnnList, a)
markAnnListA Bool
_ EpAnn AnnList
EpAnnNotUsed EpAnn AnnList -> EP w m (EpAnn AnnList, a)
action = do
  EpAnn AnnList -> EP w m (EpAnn AnnList, a)
action EpAnn AnnList
forall ann. EpAnn ann
EpAnnNotUsed
markAnnListA Bool
reallyTrail EpAnn AnnList
an EpAnn AnnList -> EP w m (EpAnn AnnList, a)
action = do
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"markAnnListA: an=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpAnn AnnList -> String
forall a. Data a => a -> String
showAst EpAnn AnnList
an
  EpAnn AnnList
an0 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn AnnList
an (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_open
  EpAnn AnnList
an1 <- if (Bool -> Bool
not Bool
reallyTrail)
           then EpAnn AnnList
-> Lens AnnList [TrailingAnn] -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [TrailingAnn] -> EP w m (EpAnn a)
markTrailingL EpAnn AnnList
an0 ([TrailingAnn] -> f [TrailingAnn]) -> AnnList -> f AnnList
Lens AnnList [TrailingAnn]
lal_trailing
           else EpAnn AnnList -> EP w m (EpAnn AnnList)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn AnnList
an0
  EpAnn AnnList
an2 <- EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn AnnList
an1 ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
AnnSemi
  (EpAnn AnnList
an3, a
r) <- EpAnn AnnList -> EP w m (EpAnn AnnList, a)
action EpAnn AnnList
an2
  EpAnn AnnList
an4 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn AnnList
an3 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_close
  EpAnn AnnList
an5 <- if Bool
reallyTrail
           then EpAnn AnnList
-> Lens AnnList [TrailingAnn] -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [TrailingAnn] -> EP w m (EpAnn a)
markTrailingL EpAnn AnnList
an4 ([TrailingAnn] -> f [TrailingAnn]) -> AnnList -> f AnnList
Lens AnnList [TrailingAnn]
lal_trailing
           else EpAnn AnnList -> EP w m (EpAnn AnnList)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn AnnList
an4
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"markAnnListA: an5=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpAnn AnnList -> String
forall a. Data a => a -> String
showAst EpAnn AnnList
an
  (EpAnn AnnList, a) -> EP w m (EpAnn AnnList, a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnList
an5, a
r)


markAnnList' :: (Monad m, Monoid w)
  => Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList' :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList' Bool
reallyTrail EpAnn AnnList
an EP w m a
action = do
  Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"markAnnList : " String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, EpAnn AnnList) -> String
forall a. Outputable a => a -> String
showPprUnsafe (Pos
p, EpAnn AnnList
an)
  EpAnn AnnList
an0 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn AnnList
an (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_open
  EpAnn AnnList
an1 <- if (Bool -> Bool
not Bool
reallyTrail)
           then EpAnn AnnList
-> Lens AnnList [TrailingAnn] -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [TrailingAnn] -> EP w m (EpAnn a)
markTrailingL EpAnn AnnList
an0 ([TrailingAnn] -> f [TrailingAnn]) -> AnnList -> f AnnList
Lens AnnList [TrailingAnn]
lal_trailing
           else EpAnn AnnList -> EP w m (EpAnn AnnList)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn AnnList
an0
  EpAnn AnnList
an2 <- EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn AnnList
an1 ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
AnnSemi
  a
r <- EP w m a
action
  EpAnn AnnList
an3 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn AnnList
an2 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_close
  EpAnn AnnList
an4 <- if Bool
reallyTrail
           then EpAnn AnnList
-> Lens AnnList [TrailingAnn] -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [TrailingAnn] -> EP w m (EpAnn a)
markTrailingL EpAnn AnnList
an3 ([TrailingAnn] -> f [TrailingAnn]) -> AnnList -> f AnnList
Lens AnnList [TrailingAnn]
lal_trailing
           else EpAnn AnnList -> EP w m (EpAnn AnnList)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn AnnList
an3
  (EpAnn AnnList, a) -> EP w m (EpAnn AnnList, a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnList
an4, a
r)

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

printComments :: (Monad m, Monoid w) => RealSrcSpan -> EP w m ()
printComments :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> EP w m ()
printComments RealSrcSpan
ss = do
  [Comment]
cs <- RealSrcSpan -> EP w m [Comment]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> EP w m [Comment]
commentAllocation RealSrcSpan
ss
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"printComments: (ss): " String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos) -> String
forall a. Outputable a => a -> String
showPprUnsafe (RealSrcSpan -> (Pos, Pos)
rs2range RealSrcSpan
ss)
  -- debugM $ "printComments: (ss,comment locations): " ++ showPprUnsafe (rs2range ss,map commentAnchor cs)
  (Comment -> EP w m ()) -> [Comment] -> EP w m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Comment -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Comment -> EP w m ()
printOneComment [Comment]
cs

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

printOneComment :: (Monad m, Monoid w) => Comment -> EP w m ()
printOneComment :: forall (m :: * -> *) w. (Monad m, Monoid w) => Comment -> EP w m ()
printOneComment c :: Comment
c@(Comment String
_str Anchor
loc RealSrcSpan
_r Maybe AnnKeywordId
_mo) = do
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"printOneComment:c=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Comment -> String
forall a. Outputable a => a -> String
showGhc Comment
c
  DeltaPos
dp <-case Anchor -> AnchorOperation
anchor_op Anchor
loc of
    MovedAnchor DeltaPos
dp -> DeltaPos -> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return DeltaPos
dp
    AnchorOperation
_ -> do
        Pos
pe <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
        let dp :: DeltaPos
dp = Pos -> RealSrcSpan -> DeltaPos
ss2delta Pos
pe (Anchor -> RealSrcSpan
anchor Anchor
loc)
        String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"printOneComment:(dp,pe,anchor loc)=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (DeltaPos, Pos, Pos) -> String
forall a. Outputable a => a -> String
showGhc (DeltaPos
dp,Pos
pe,RealSrcSpan -> Pos
ss2pos (RealSrcSpan -> Pos) -> RealSrcSpan -> Pos
forall a b. (a -> b) -> a -> b
$ Anchor -> RealSrcSpan
anchor Anchor
loc)
        DeltaPos -> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> EP w m DeltaPos
adjustDeltaForOffsetM DeltaPos
dp
  Maybe Anchor
mep <- EP w m (Maybe Anchor)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m (Maybe Anchor)
getExtraDP
  DeltaPos
dp' <- case Maybe Anchor
mep of
    Just (Anchor RealSrcSpan
_ (MovedAnchor DeltaPos
edp)) -> do
      String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"printOneComment:edp=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ DeltaPos -> String
forall a. Show a => a -> String
show DeltaPos
edp
      DeltaPos
ddd <- (DeltaPos -> DeltaPos)
-> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
-> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
forall a b.
(a -> b)
-> RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DeltaPos -> DeltaPos
unTweakDelta (RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
 -> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos)
-> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
-> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
forall a b. (a -> b) -> a -> b
$ DeltaPos -> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> EP w m DeltaPos
adjustDeltaForOffsetM DeltaPos
edp
      String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"printOneComment:ddd=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ DeltaPos -> String
forall a. Show a => a -> String
show DeltaPos
ddd
      (DeltaPos -> DeltaPos)
-> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
-> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
forall a b.
(a -> b)
-> RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DeltaPos -> DeltaPos
unTweakDelta (RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
 -> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos)
-> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
-> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
forall a b. (a -> b) -> a -> b
$ DeltaPos -> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> EP w m DeltaPos
adjustDeltaForOffsetM DeltaPos
edp
    Maybe Anchor
_ -> DeltaPos -> RWST (EPOptions m w) (EPWriter w) EPState m DeltaPos
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return DeltaPos
dp
  -- Start of debug printing
  -- LayoutStartCol dOff <- getLayoutOffsetD
  -- debugM $ "printOneComment:(dp,dp',dOff)=" ++ showGhc (dp,dp',dOff)
  -- End of debug printing
  -- setPriorEndD (ss2posEnd (anchor loc))
  Comment -> DeltaPos -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Comment -> DeltaPos -> EP w m ()
updateAndApplyComment Comment
c DeltaPos
dp'
  RealSrcSpan -> Comment -> DeltaPos -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> Comment -> DeltaPos -> EP w m ()
printQueuedComment (Anchor -> RealSrcSpan
anchor Anchor
loc) Comment
c DeltaPos
dp'

-- | For comment-related deltas starting on a new line we have an
-- off-by-one problem. Adjust
unTweakDelta :: DeltaPos  -> DeltaPos
unTweakDelta :: DeltaPos -> DeltaPos
unTweakDelta (SameLine Int
d) = Int -> DeltaPos
SameLine Int
d
unTweakDelta (DifferentLine Int
l Int
d) = Int -> Int -> DeltaPos
DifferentLine Int
l (Int
dInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)


updateAndApplyComment :: (Monad m, Monoid w) => Comment -> DeltaPos -> EP w m ()
updateAndApplyComment :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Comment -> DeltaPos -> EP w m ()
updateAndApplyComment (Comment String
str Anchor
anc RealSrcSpan
pp Maybe AnnKeywordId
mo) DeltaPos
dp = do
  -- debugM $ "updateAndApplyComment: (dp,anc',co)=" ++ showAst (dp,anc',co)
  Comment -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Comment -> EP w m ()
applyComment (String -> Anchor -> RealSrcSpan -> Maybe AnnKeywordId -> Comment
Comment String
str Anchor
anc' RealSrcSpan
pp Maybe AnnKeywordId
mo)
  where
    anc' :: Anchor
anc' = Anchor
anc { anchor_op = op}

    (Int
r,Int
c) = RealSrcSpan -> Pos
ss2posEnd RealSrcSpan
pp
    la :: RealSrcSpan
la = Anchor -> RealSrcSpan
anchor Anchor
anc
    dp'' :: DeltaPos
dp'' = if Int
r Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0
           then (Pos -> RealSrcSpan -> DeltaPos
ss2delta (Int
r,Int
cInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
0) RealSrcSpan
la)
           else (Pos -> RealSrcSpan -> DeltaPos
ss2delta (Int
r,Int
c)   RealSrcSpan
la)
    dp' :: DeltaPos
dp' = if RealSrcSpan
pp RealSrcSpan -> RealSrcSpan -> Bool
forall a. Eq a => a -> a -> Bool
== Anchor -> RealSrcSpan
anchor Anchor
anc
             then DeltaPos
dp
             else DeltaPos
dp''
    op' :: AnchorOperation
op' = case DeltaPos
dp' of
            SameLine Int
n -> if Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0
                            then DeltaPos -> AnchorOperation
MovedAnchor DeltaPos
dp'
                            else DeltaPos -> AnchorOperation
MovedAnchor DeltaPos
dp
            DeltaPos
_ -> DeltaPos -> AnchorOperation
MovedAnchor DeltaPos
dp'
    op :: AnchorOperation
op = if String
str String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"" Bool -> Bool -> Bool
&& AnchorOperation
op' AnchorOperation -> AnchorOperation -> Bool
forall a. Eq a => a -> a -> Bool
== DeltaPos -> AnchorOperation
MovedAnchor (Int -> DeltaPos
SameLine Int
0) -- EOF comment
           then DeltaPos -> AnchorOperation
MovedAnchor DeltaPos
dp
           -- else op'
           else DeltaPos -> AnchorOperation
MovedAnchor DeltaPos
dp

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

commentAllocation :: (Monad m, Monoid w) => RealSrcSpan -> EP w m [Comment]
commentAllocation :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> EP w m [Comment]
commentAllocation RealSrcSpan
ss = do
  [Comment]
cs <- EP w m [Comment]
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m [Comment]
getUnallocatedComments
  -- Note: The CPP comment injection may change the file name in the
  -- RealSrcSpan, which affects comparison, as the Ord instance for
  -- RealSrcSpan compares the file first. So we sort via ss2pos
  -- TODO: this is inefficient, use Pos all the way through
  let ([Comment]
earlier,[Comment]
later) = (Comment -> Bool) -> [Comment] -> ([Comment], [Comment])
forall a. (a -> Bool) -> [a] -> ([a], [a])
partition (\(Comment String
_str Anchor
loc RealSrcSpan
_r Maybe AnnKeywordId
_mo) -> (RealSrcSpan -> Pos
ss2pos (RealSrcSpan -> Pos) -> RealSrcSpan -> Pos
forall a b. (a -> b) -> a -> b
$ Anchor -> RealSrcSpan
anchor Anchor
loc) Pos -> Pos -> Bool
forall a. Ord a => a -> a -> Bool
<= (RealSrcSpan -> Pos
ss2pos RealSrcSpan
ss)) [Comment]
cs
  [Comment] -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[Comment] -> EP w m ()
putUnallocatedComments [Comment]
later
  -- debugM $ "commentAllocation:(ss,earlier,later)" ++ show (rs2range ss,earlier,later)
  [Comment] -> EP w m [Comment]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return [Comment]
earlier

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

markAnnotatedWithLayout :: (Monad m, Monoid w) => ExactPrint ast => ast -> EP w m ast
markAnnotatedWithLayout :: forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotatedWithLayout ast
a = EP w m ast -> EP w m ast
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutBoth (EP w m ast -> EP w m ast) -> EP w m ast -> EP w m ast
forall a b. (a -> b) -> a -> b
$ ast -> EP w m ast
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ast
a

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

markTopLevelList :: (Monad m, Monoid w) => ExactPrint ast => [ast] -> EP w m [ast]
markTopLevelList :: forall (m :: * -> *) w ast.
(Monad m, Monoid w, ExactPrint ast) =>
[ast] -> EP w m [ast]
markTopLevelList [ast]
ls = (ast -> RWST (EPOptions m w) (EPWriter w) EPState m ast)
-> [ast] -> RWST (EPOptions m w) (EPWriter w) EPState m [ast]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (\ast
a -> RWST (EPOptions m w) (EPWriter w) EPState m ast
-> RWST (EPOptions m w) (EPWriter w) EPState m ast
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutTopLevelP (RWST (EPOptions m w) (EPWriter w) EPState m ast
 -> RWST (EPOptions m w) (EPWriter w) EPState m ast)
-> RWST (EPOptions m w) (EPWriter w) EPState m ast
-> RWST (EPOptions m w) (EPWriter w) EPState m ast
forall a b. (a -> b) -> a -> b
$ ast -> RWST (EPOptions m w) (EPWriter w) EPState m ast
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ast
a) [ast]
ls

-- ---------------------------------------------------------------------
-- End of utility functions
-- ---------------------------------------------------------------------
-- Start of ExactPrint instances
-- ---------------------------------------------------------------------

-- | Bare Located elements are simply stripped off without further
-- processing.
instance (ExactPrint a) => ExactPrint (Located a) where
  getAnnotationEntry :: Located a -> Entry
getAnnotationEntry (L SrcSpan
l a
_) = case SrcSpan
l of
    UnhelpfulSpan UnhelpfulSpanReason
_ -> Entry
NoEntryVal
    SrcSpan
_ -> Anchor
-> EpAnnComments -> FlushComments -> CanUpdateAnchor -> Entry
Entry (SrcSpan -> Anchor
hackSrcSpanToAnchor SrcSpan
l) EpAnnComments
emptyComments FlushComments
NoFlushComments CanUpdateAnchor
CanUpdateAnchorOnly

  setAnnotationAnchor :: Located a -> Anchor -> EpAnnComments -> Located a
setAnnotationAnchor (L SrcSpan
_ a
a) Anchor
anc EpAnnComments
_cs = (SrcSpan -> a -> Located a
forall l e. l -> e -> GenLocated l e
L (Anchor -> SrcSpan
hackAnchorToSrcSpan Anchor
anc) a
a)
                 Located a -> String -> Located a
forall c. c -> String -> c
`debug` (String
"setAnnotationAnchor(Located):" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Anchor -> String
forall a. Data a => a -> String
showAst Anchor
anc)

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Located a -> EP w m (Located a)
exact (L SrcSpan
l a
a) = SrcSpan -> a -> Located a
forall l e. l -> e -> GenLocated l e
L SrcSpan
l (a -> Located a)
-> RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m (Located a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated a
a

instance (ExactPrint a) => ExactPrint (LocatedA a) where
  getAnnotationEntry :: LocatedA a -> Entry
getAnnotationEntry = LocatedA a -> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: LocatedA a -> Anchor -> EpAnnComments -> LocatedA a
setAnnotationAnchor LocatedA a
la Anchor
anc EpAnnComments
cs = LocatedA a -> Anchor -> EpAnnComments -> LocatedA a
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn LocatedA a
la Anchor
anc EpAnnComments
cs
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LocatedA a -> EP w m (LocatedA a)
exact (L SrcSpanAnnA
la a
a) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LocatedA a:la loc=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos) -> String
forall a. Show a => a -> String
show (SrcSpan -> (Pos, Pos)
ss2range (SrcSpan -> (Pos, Pos)) -> SrcSpan -> (Pos, Pos)
forall a b. (a -> b) -> a -> b
$ SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnA
la)
    a
a' <- a -> EP w m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated a
a
    EpAnn AnnListItem
ann' <- EpAnn AnnListItem -> EP w m (EpAnn AnnListItem)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnListItem -> EP w m (EpAnn AnnListItem)
markALocatedA (SrcSpanAnnA -> EpAnn AnnListItem
forall a. SrcSpanAnn' a -> a
ann SrcSpanAnnA
la)
    LocatedA a -> EP w m (LocatedA a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnA -> a -> LocatedA a
forall l e. l -> e -> GenLocated l e
L (SrcSpanAnnA
la { ann = ann'}) a
a')

instance (ExactPrint a) => ExactPrint (LocatedAn NoEpAnns a) where
  getAnnotationEntry :: LocatedAn NoEpAnns a -> Entry
getAnnotationEntry = LocatedAn NoEpAnns a -> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: LocatedAn NoEpAnns a
-> Anchor -> EpAnnComments -> LocatedAn NoEpAnns a
setAnnotationAnchor LocatedAn NoEpAnns a
la Anchor
anc EpAnnComments
cs = LocatedAn NoEpAnns a
-> Anchor -> EpAnnComments -> LocatedAn NoEpAnns a
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn LocatedAn NoEpAnns a
la Anchor
anc EpAnnComments
cs
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LocatedAn NoEpAnns a -> EP w m (LocatedAn NoEpAnns a)
exact (L SrcAnn NoEpAnns
la a
a) = do
    a
a' <- a -> EP w m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated a
a
    LocatedAn NoEpAnns a -> EP w m (LocatedAn NoEpAnns a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcAnn NoEpAnns -> a -> LocatedAn NoEpAnns a
forall l e. l -> e -> GenLocated l e
L SrcAnn NoEpAnns
la a
a')

instance (ExactPrint a) => ExactPrint [a] where
  getAnnotationEntry :: [a] -> Entry
getAnnotationEntry = Entry -> [a] -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: [a] -> Anchor -> EpAnnComments -> [a]
setAnnotationAnchor [a]
ls Anchor
_ EpAnnComments
_ = [a]
ls
  exact :: forall (m :: * -> *) w. (Monad m, Monoid w) => [a] -> EP w m [a]
exact [a]
ls = (a -> RWST (EPOptions m w) (EPWriter w) EPState m a)
-> [a] -> RWST (EPOptions m w) (EPWriter w) EPState m [a]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [a]
ls

instance (ExactPrint a) => ExactPrint (Maybe a) where
  getAnnotationEntry :: Maybe a -> Entry
getAnnotationEntry = Entry -> Maybe a -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: Maybe a -> Anchor -> EpAnnComments -> Maybe a
setAnnotationAnchor Maybe a
ma Anchor
_ EpAnnComments
_ = Maybe a
ma
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe a -> EP w m (Maybe a)
exact Maybe a
ma = (a -> RWST (EPOptions m w) (EPWriter w) EPState m a)
-> Maybe a -> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe a)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe a
ma

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

-- | 'Located (HsModule GhcPs)' corresponds to 'ParsedSource'
instance ExactPrint (HsModule GhcPs) where
  getAnnotationEntry :: HsModule GhcPs -> Entry
getAnnotationEntry HsModule GhcPs
hsmod = EpAnn AnnsModule -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn' (XModulePs -> EpAnn AnnsModule
hsmodAnn (XModulePs -> EpAnn AnnsModule) -> XModulePs -> EpAnn AnnsModule
forall a b. (a -> b) -> a -> b
$ HsModule GhcPs -> XCModule GhcPs
forall p. HsModule p -> XCModule p
hsmodExt HsModule GhcPs
hsmod)
  -- A bit pointless actually changing anything here
  setAnnotationAnchor :: HsModule GhcPs -> Anchor -> EpAnnComments -> HsModule GhcPs
setAnnotationAnchor HsModule GhcPs
hsmod Anchor
anc EpAnnComments
cs = HsModule GhcPs -> Anchor -> EpAnnComments -> HsModule GhcPs
setAnchorHsModule HsModule GhcPs
hsmod Anchor
anc EpAnnComments
cs
                   HsModule GhcPs -> String -> HsModule GhcPs
forall c. c -> String -> c
`debug` (String
"setAnnotationAnchor hsmod called" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Anchor, EpAnnComments) -> String
forall a. Data a => a -> String
showAst (Anchor
anc,EpAnnComments
cs))

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsModule GhcPs -> EP w m (HsModule GhcPs)
exact hsmod :: HsModule GhcPs
hsmod@(HsModule {hsmodExt :: forall p. HsModule p -> XCModule p
hsmodExt = XModulePs { hsmodAnn :: XModulePs -> EpAnn AnnsModule
hsmodAnn = EpAnn AnnsModule
EpAnnNotUsed }}) = HsModule GhcPs -> EP w m (HsModule GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr HsModule GhcPs
hsmod EP w m (HsModule GhcPs)
-> EP w m (HsModule GhcPs) -> EP w m (HsModule GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HsModule GhcPs -> EP w m (HsModule GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsModule GhcPs
hsmod
  exact (HsModule (XModulePs EpAnn AnnsModule
an LayoutInfo GhcPs
lo Maybe (LocatedP (WarningTxt GhcPs))
mdeprec Maybe (LHsDoc GhcPs)
mbDoc) Maybe (XRec GhcPs ModuleName)
mmn Maybe (XRec GhcPs [LIE GhcPs])
mexports [LImportDecl GhcPs]
imports [LHsDecl GhcPs]
decls) = do

    let mbDoc' :: Maybe (LHsDoc GhcPs)
mbDoc' = Maybe (LHsDoc GhcPs)
mbDoc
    -- mbDoc' <- markAnnotated mbDoc

    (EpAnn AnnsModule
an0, Maybe (GenLocated SrcSpanAnnA ModuleName)
mmn' , Maybe (LocatedP (WarningTxt GhcPs))
mdeprec', Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
mexports') <-
      case Maybe (XRec GhcPs ModuleName)
mmn of
        Maybe (XRec GhcPs ModuleName)
Nothing -> (EpAnn AnnsModule, Maybe (GenLocated SrcSpanAnnA ModuleName),
 Maybe (LocatedP (WarningTxt GhcPs)),
 Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnsModule, Maybe (GenLocated SrcSpanAnnA ModuleName),
      Maybe (LocatedP (WarningTxt GhcPs)),
      Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnsModule
an, Maybe (XRec GhcPs ModuleName)
Maybe (GenLocated SrcSpanAnnA ModuleName)
mmn, Maybe (LocatedP (WarningTxt GhcPs))
mdeprec, Maybe (XRec GhcPs [LIE GhcPs])
Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
mexports)
        Just XRec GhcPs ModuleName
m -> do
          EpAnn AnnsModule
an0 <- EpAnn AnnsModule
-> Lens AnnsModule [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnsModule)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn AnnsModule
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnsModule -> f AnnsModule
Lens AnnsModule [AddEpAnn]
lam_main AnnKeywordId
AnnModule
          GenLocated SrcSpanAnnA ModuleName
m' <- GenLocated SrcSpanAnnA ModuleName
-> EP w m (GenLocated SrcSpanAnnA ModuleName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs ModuleName
GenLocated SrcSpanAnnA ModuleName
m

          Maybe (LocatedP (WarningTxt GhcPs))
mdeprec' <- EP w m (Maybe (LocatedP (WarningTxt GhcPs)))
-> EP w m (Maybe (LocatedP (WarningTxt GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutTopLevelP (EP w m (Maybe (LocatedP (WarningTxt GhcPs)))
 -> EP w m (Maybe (LocatedP (WarningTxt GhcPs))))
-> EP w m (Maybe (LocatedP (WarningTxt GhcPs)))
-> EP w m (Maybe (LocatedP (WarningTxt GhcPs)))
forall a b. (a -> b) -> a -> b
$ Maybe (LocatedP (WarningTxt GhcPs))
-> EP w m (Maybe (LocatedP (WarningTxt GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (LocatedP (WarningTxt GhcPs))
mdeprec
          Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
mexports' <- EP
  w
  m
  (Maybe
     (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
-> EP
     w
     m
     (Maybe
        (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutTopLevelP (EP
   w
   m
   (Maybe
      (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
 -> EP
      w
      m
      (Maybe
         (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])))
-> EP
     w
     m
     (Maybe
        (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
-> EP
     w
     m
     (Maybe
        (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
forall a b. (a -> b) -> a -> b
$ Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
-> EP
     w
     m
     (Maybe
        (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (XRec GhcPs [LIE GhcPs])
Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
mexports
          EpAnn AnnsModule
an1 <- EP w m (EpAnn AnnsModule) -> EP w m (EpAnn AnnsModule)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutTopLevelP (EP w m (EpAnn AnnsModule) -> EP w m (EpAnn AnnsModule))
-> EP w m (EpAnn AnnsModule) -> EP w m (EpAnn AnnsModule)
forall a b. (a -> b) -> a -> b
$ EpAnn AnnsModule
-> Lens AnnsModule [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnsModule)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn AnnsModule
an0 ([AddEpAnn] -> f [AddEpAnn]) -> AnnsModule -> f AnnsModule
Lens AnnsModule [AddEpAnn]
lam_main AnnKeywordId
AnnWhere

          (EpAnn AnnsModule, Maybe (GenLocated SrcSpanAnnA ModuleName),
 Maybe (LocatedP (WarningTxt GhcPs)),
 Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnsModule, Maybe (GenLocated SrcSpanAnnA ModuleName),
      Maybe (LocatedP (WarningTxt GhcPs)),
      Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnsModule
an1, GenLocated SrcSpanAnnA ModuleName
-> Maybe (GenLocated SrcSpanAnnA ModuleName)
forall a. a -> Maybe a
Just GenLocated SrcSpanAnnA ModuleName
m', Maybe (LocatedP (WarningTxt GhcPs))
mdeprec', Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
mexports')

    let ann_decls :: EpAnn AnnList
ann_decls = Anchor -> AnnList -> EpAnnComments -> EpAnn AnnList
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn (EpAnn AnnsModule -> Anchor
forall ann. EpAnn ann -> Anchor
entry EpAnn AnnsModule
an) (AnnsModule -> AnnList
am_decls (AnnsModule -> AnnList) -> AnnsModule -> AnnList
forall a b. (a -> b) -> a -> b
$ EpAnn AnnsModule -> AnnsModule
forall ann. EpAnn ann -> ann
anns EpAnn AnnsModule
an0) EpAnnComments
emptyComments
    (EpAnn AnnList
ann_decls', ([GenLocated SrcSpanAnnA (HsDecl GhcPs)]
decls', [GenLocated SrcSpanAnnA (ImportDecl GhcPs)]
imports')) <- Bool
-> EpAnn AnnList
-> EP
     w
     m
     ([GenLocated SrcSpanAnnA (HsDecl GhcPs)],
      [GenLocated SrcSpanAnnA (ImportDecl GhcPs)])
-> EP
     w
     m
     (EpAnn AnnList,
      ([GenLocated SrcSpanAnnA (HsDecl GhcPs)],
       [GenLocated SrcSpanAnnA (ImportDecl GhcPs)]))
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList' Bool
False EpAnn AnnList
ann_decls (EP
   w
   m
   ([GenLocated SrcSpanAnnA (HsDecl GhcPs)],
    [GenLocated SrcSpanAnnA (ImportDecl GhcPs)])
 -> EP
      w
      m
      (EpAnn AnnList,
       ([GenLocated SrcSpanAnnA (HsDecl GhcPs)],
        [GenLocated SrcSpanAnnA (ImportDecl GhcPs)])))
-> EP
     w
     m
     ([GenLocated SrcSpanAnnA (HsDecl GhcPs)],
      [GenLocated SrcSpanAnnA (ImportDecl GhcPs)])
-> EP
     w
     m
     (EpAnn AnnList,
      ([GenLocated SrcSpanAnnA (HsDecl GhcPs)],
       [GenLocated SrcSpanAnnA (ImportDecl GhcPs)]))
forall a b. (a -> b) -> a -> b
$ do
      [GenLocated SrcSpanAnnA (ImportDecl GhcPs)]
imports' <- [GenLocated SrcSpanAnnA (ImportDecl GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (ImportDecl GhcPs)]
forall (m :: * -> *) w ast.
(Monad m, Monoid w, ExactPrint ast) =>
[ast] -> EP w m [ast]
markTopLevelList [LImportDecl GhcPs]
[GenLocated SrcSpanAnnA (ImportDecl GhcPs)]
imports
      [GenLocated SrcSpanAnnA (HsDecl GhcPs)]
decls' <- [GenLocated SrcSpanAnnA (HsDecl GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsDecl GhcPs)]
forall (m :: * -> *) w ast.
(Monad m, Monoid w, ExactPrint ast) =>
[ast] -> EP w m [ast]
markTopLevelList [LHsDecl GhcPs]
[GenLocated SrcSpanAnnA (HsDecl GhcPs)]
decls
      ([GenLocated SrcSpanAnnA (HsDecl GhcPs)],
 [GenLocated SrcSpanAnnA (ImportDecl GhcPs)])
-> EP
     w
     m
     ([GenLocated SrcSpanAnnA (HsDecl GhcPs)],
      [GenLocated SrcSpanAnnA (ImportDecl GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([GenLocated SrcSpanAnnA (HsDecl GhcPs)]
decls', [GenLocated SrcSpanAnnA (ImportDecl GhcPs)]
imports')
    let am_decls' :: AnnList
am_decls' = case EpAnn AnnList
ann_decls' of
          EpAnn AnnList
EpAnnNotUsed -> (AnnsModule -> AnnList
am_decls (AnnsModule -> AnnList) -> AnnsModule -> AnnList
forall a b. (a -> b) -> a -> b
$ EpAnn AnnsModule -> AnnsModule
forall ann. EpAnn ann -> ann
anns EpAnn AnnsModule
an0)
          EpAnn Anchor
_ AnnList
r EpAnnComments
_ -> AnnList
r

    let anf :: EpAnn AnnsModule
anf = EpAnn AnnsModule
an0 { anns = (anns an0) { am_decls = am_decls' }}
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsModule, anf=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpAnn AnnsModule -> String
forall a. Data a => a -> String
showAst EpAnn AnnsModule
anf

    HsModule GhcPs -> EP w m (HsModule GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCModule GhcPs
-> Maybe (XRec GhcPs ModuleName)
-> Maybe (XRec GhcPs [LIE GhcPs])
-> [LImportDecl GhcPs]
-> [LHsDecl GhcPs]
-> HsModule GhcPs
forall p.
XCModule p
-> Maybe (XRec p ModuleName)
-> Maybe (XRec p [LIE p])
-> [LImportDecl p]
-> [LHsDecl p]
-> HsModule p
HsModule (EpAnn AnnsModule
-> LayoutInfo GhcPs
-> Maybe (LocatedP (WarningTxt GhcPs))
-> Maybe (LHsDoc GhcPs)
-> XModulePs
XModulePs EpAnn AnnsModule
anf LayoutInfo GhcPs
lo Maybe (LocatedP (WarningTxt GhcPs))
mdeprec' Maybe (LHsDoc GhcPs)
mbDoc') Maybe (XRec GhcPs ModuleName)
Maybe (GenLocated SrcSpanAnnA ModuleName)
mmn' Maybe (XRec GhcPs [LIE GhcPs])
Maybe (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
mexports' [LImportDecl GhcPs]
[GenLocated SrcSpanAnnA (ImportDecl GhcPs)]
imports' [LHsDecl GhcPs]
[GenLocated SrcSpanAnnA (HsDecl GhcPs)]
decls')

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

instance ExactPrint ModuleName where
  getAnnotationEntry :: ModuleName -> Entry
getAnnotationEntry ModuleName
_ = Entry
NoEntryVal
  setAnnotationAnchor :: ModuleName -> Anchor -> EpAnnComments -> ModuleName
setAnnotationAnchor ModuleName
n Anchor
_anc EpAnnComments
cs = ModuleName
n
     ModuleName -> String -> ModuleName
forall c. c -> String -> c
`debug` (String
"ModuleName.setAnnotationAnchor:cs=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpAnnComments -> String
forall a. Data a => a -> String
showAst EpAnnComments
cs)
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
ModuleName -> EP w m ModuleName
exact ModuleName
n = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"ModuleName: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ModuleName -> String
forall a. Outputable a => a -> String
showPprUnsafe ModuleName
n
    ModuleName -> EP w m ModuleName
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr ModuleName
n

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

instance ExactPrint (LocatedP (WarningTxt GhcPs)) where
  getAnnotationEntry :: LocatedP (WarningTxt GhcPs) -> Entry
getAnnotationEntry = LocatedP (WarningTxt GhcPs) -> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: LocatedP (WarningTxt GhcPs)
-> Anchor -> EpAnnComments -> LocatedP (WarningTxt GhcPs)
setAnnotationAnchor = LocatedP (WarningTxt GhcPs)
-> Anchor -> EpAnnComments -> LocatedP (WarningTxt GhcPs)
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LocatedP (WarningTxt GhcPs) -> EP w m (LocatedP (WarningTxt GhcPs))
exact (L (SrcSpanAnn EpAnn AnnPragma
an SrcSpan
l) (WarningTxt (L SrcSpan
la SourceText
src) [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ws)) = do
    EpAnn AnnPragma
an0 <- EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
src String
"{-# WARNING"
    EpAnn AnnPragma
an1 <- EpAnn AnnPragma
-> Lens AnnPragma [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn AnnPragma
an0 ([AddEpAnn] -> f [AddEpAnn]) -> AnnPragma -> f AnnPragma
Lens AnnPragma [AddEpAnn]
lapr_rest AnnKeywordId
AnnOpenS
    [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ws' <- [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
-> EP w m [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ws
    EpAnn AnnPragma
an2 <- EpAnn AnnPragma
-> Lens AnnPragma [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn AnnPragma
an1 ([AddEpAnn] -> f [AddEpAnn]) -> AnnPragma -> f AnnPragma
Lens AnnPragma [AddEpAnn]
lapr_rest AnnKeywordId
AnnCloseS
    EpAnn AnnPragma
an3 <- EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an2
    LocatedP (WarningTxt GhcPs) -> EP w m (LocatedP (WarningTxt GhcPs))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnP -> WarningTxt GhcPs -> LocatedP (WarningTxt GhcPs)
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnPragma -> SrcSpan -> SrcSpanAnnP
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnPragma
an3 SrcSpan
l) (GenLocated SrcSpan SourceText
-> [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
-> WarningTxt GhcPs
forall pass.
GenLocated SrcSpan SourceText
-> [Located (WithHsDocIdentifiers StringLiteral pass)]
-> WarningTxt pass
WarningTxt (SrcSpan -> SourceText -> GenLocated SrcSpan SourceText
forall l e. l -> e -> GenLocated l e
L SrcSpan
la SourceText
src) [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ws'))

  exact (L (SrcSpanAnn EpAnn AnnPragma
an SrcSpan
l) (DeprecatedTxt (L SrcSpan
ls SourceText
src) [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ws)) = do
    EpAnn AnnPragma
an0 <- EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
src String
"{-# DEPRECATED"
    EpAnn AnnPragma
an1 <- EpAnn AnnPragma
-> Lens AnnPragma [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn AnnPragma
an0 ([AddEpAnn] -> f [AddEpAnn]) -> AnnPragma -> f AnnPragma
Lens AnnPragma [AddEpAnn]
lapr_rest AnnKeywordId
AnnOpenS
    [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ws' <- [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
-> EP w m [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ws
    EpAnn AnnPragma
an2 <- EpAnn AnnPragma
-> Lens AnnPragma [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn AnnPragma
an1 ([AddEpAnn] -> f [AddEpAnn]) -> AnnPragma -> f AnnPragma
Lens AnnPragma [AddEpAnn]
lapr_rest AnnKeywordId
AnnCloseS
    EpAnn AnnPragma
an3 <- EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an2
    LocatedP (WarningTxt GhcPs) -> EP w m (LocatedP (WarningTxt GhcPs))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnP -> WarningTxt GhcPs -> LocatedP (WarningTxt GhcPs)
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnPragma -> SrcSpan -> SrcSpanAnnP
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnPragma
an3 SrcSpan
l) (GenLocated SrcSpan SourceText
-> [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
-> WarningTxt GhcPs
forall pass.
GenLocated SrcSpan SourceText
-> [Located (WithHsDocIdentifiers StringLiteral pass)]
-> WarningTxt pass
DeprecatedTxt (SrcSpan -> SourceText -> GenLocated SrcSpan SourceText
forall l e. l -> e -> GenLocated l e
L SrcSpan
ls SourceText
src) [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ws'))

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

instance ExactPrint (ImportDecl GhcPs) where
  getAnnotationEntry :: ImportDecl GhcPs -> Entry
getAnnotationEntry ImportDecl GhcPs
idecl = EpAnn EpAnnImportDecl -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn (XImportDeclPass -> EpAnn EpAnnImportDecl
ideclAnn (XImportDeclPass -> EpAnn EpAnnImportDecl)
-> XImportDeclPass -> EpAnn EpAnnImportDecl
forall a b. (a -> b) -> a -> b
$ ImportDecl GhcPs -> XCImportDecl GhcPs
forall pass. ImportDecl pass -> XCImportDecl pass
ideclExt ImportDecl GhcPs
idecl)
  setAnnotationAnchor :: ImportDecl GhcPs -> Anchor -> EpAnnComments -> ImportDecl GhcPs
setAnnotationAnchor ImportDecl GhcPs
idecl Anchor
anc EpAnnComments
cs = ImportDecl GhcPs
idecl { ideclExt
                    = (ideclExt idecl) { ideclAnn = setAnchorEpa (ideclAnn $ ideclExt idecl) anc cs} }

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
ImportDecl GhcPs -> EP w m (ImportDecl GhcPs)
exact x :: ImportDecl GhcPs
x@(ImportDecl{ ideclExt :: forall pass. ImportDecl pass -> XCImportDecl pass
ideclExt = XImportDeclPass{ ideclAnn :: XImportDeclPass -> EpAnn EpAnnImportDecl
ideclAnn = EpAnn EpAnnImportDecl
EpAnnNotUsed } }) = ImportDecl GhcPs -> EP w m (ImportDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr ImportDecl GhcPs
x
  exact (ImportDecl (XImportDeclPass EpAnn EpAnnImportDecl
ann SourceText
msrc Bool
impl)
                     XRec GhcPs ModuleName
modname ImportDeclPkgQual GhcPs
mpkg IsBootInterface
src Bool
safeflag ImportDeclQualifiedStyle
qualFlag Maybe (XRec GhcPs ModuleName)
mAs Maybe (ImportListInterpretation, XRec GhcPs [LIE GhcPs])
hiding) = do

    EpAnn EpAnnImportDecl
ann0 <- EpAnn EpAnnImportDecl
-> Lens EpAnnImportDecl EpaLocation
-> AnnKeywordId
-> EP w m (EpAnn EpAnnImportDecl)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw EpAnn EpAnnImportDecl
ann (EpaLocation -> f EpaLocation)
-> EpAnnImportDecl -> f EpAnnImportDecl
Lens EpAnnImportDecl EpaLocation
limportDeclAnnImport AnnKeywordId
AnnImport
    let (EpAnn Anchor
_anc EpAnnImportDecl
an EpAnnComments
_cs) = EpAnn EpAnnImportDecl
ann0

    -- "{-# SOURCE" and "#-}"
    Maybe (EpaLocation, EpaLocation)
importDeclAnnPragma' <-
      case SourceText
msrc of
        SourceText String
_txt -> do
          String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"ImportDecl sourcetext"
          case EpAnnImportDecl -> Maybe (EpaLocation, EpaLocation)
importDeclAnnPragma EpAnnImportDecl
an of
            Just (EpaLocation
mo, EpaLocation
mc) -> do
              EpaLocation
mo' <- EpaLocation -> SourceText -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> SourceText -> String -> EP w m EpaLocation
markAnnOpen'' EpaLocation
mo SourceText
msrc String
"{-# SOURCE"
              EpaLocation
mc' <- EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
mc String
"#-}"
              Maybe (EpaLocation, EpaLocation)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (EpaLocation, EpaLocation))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (EpaLocation, EpaLocation)
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (Maybe (EpaLocation, EpaLocation)))
-> Maybe (EpaLocation, EpaLocation)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (EpaLocation, EpaLocation))
forall a b. (a -> b) -> a -> b
$ (EpaLocation, EpaLocation) -> Maybe (EpaLocation, EpaLocation)
forall a. a -> Maybe a
Just (EpaLocation
mo', EpaLocation
mc')
            Maybe (EpaLocation, EpaLocation)
Nothing ->  do
              Maybe EpaLocation
_ <- Maybe EpaLocation
-> SourceText -> String -> EP w m (Maybe EpaLocation)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe EpaLocation
-> SourceText -> String -> EP w m (Maybe EpaLocation)
markAnnOpen' Maybe EpaLocation
forall a. Maybe a
Nothing SourceText
msrc String
"{-# SOURCE"
              DeltaPos
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> String -> EP w m ()
printStringAtLsDelta (Int -> DeltaPos
SameLine Int
1) String
"#-}"
              Maybe (EpaLocation, EpaLocation)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (EpaLocation, EpaLocation))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (EpaLocation, EpaLocation)
forall a. Maybe a
Nothing
        SourceText
NoSourceText -> Maybe (EpaLocation, EpaLocation)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (EpaLocation, EpaLocation))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnnImportDecl -> Maybe (EpaLocation, EpaLocation)
importDeclAnnPragma EpAnnImportDecl
an)
    EpAnn EpAnnImportDecl
ann1 <- if Bool
safeflag
      then (EpAnn EpAnnImportDecl
-> Lens EpAnnImportDecl (Maybe EpaLocation)
-> AnnKeywordId
-> EP w m (EpAnn EpAnnImportDecl)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a (Maybe EpaLocation) -> AnnKeywordId -> EP w m (EpAnn a)
markLensKwM EpAnn EpAnnImportDecl
ann0 (Maybe EpaLocation -> f (Maybe EpaLocation))
-> EpAnnImportDecl -> f EpAnnImportDecl
Lens EpAnnImportDecl (Maybe EpaLocation)
limportDeclAnnSafe AnnKeywordId
AnnSafe)
      else EpAnn EpAnnImportDecl -> EP w m (EpAnn EpAnnImportDecl)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn EpAnnImportDecl
ann0
    EpAnn EpAnnImportDecl
ann2 <-
      case ImportDeclQualifiedStyle
qualFlag of
        ImportDeclQualifiedStyle
QualifiedPre  -- 'qualified' appears in prepositive position.
          -> EpAnn EpAnnImportDecl
-> Lens EpAnnImportDecl (Maybe EpaLocation)
-> String
-> EP w m (EpAnn EpAnnImportDecl)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe EpaLocation) -> String -> EP w m (EpAnn a)
printStringAtMLocL EpAnn EpAnnImportDecl
ann1 (Maybe EpaLocation -> f (Maybe EpaLocation))
-> EpAnnImportDecl -> f EpAnnImportDecl
Lens EpAnnImportDecl (Maybe EpaLocation)
limportDeclAnnQualified String
"qualified"
        ImportDeclQualifiedStyle
_ -> EpAnn EpAnnImportDecl -> EP w m (EpAnn EpAnnImportDecl)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn EpAnnImportDecl
ann1
    EpAnn EpAnnImportDecl
ann3 <-
      case ImportDeclPkgQual GhcPs
mpkg of
       RawPkgQual (StringLiteral SourceText
src' FastString
v Maybe RealSrcSpan
_) ->
         EpAnn EpAnnImportDecl
-> Lens EpAnnImportDecl (Maybe EpaLocation)
-> String
-> EP w m (EpAnn EpAnnImportDecl)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe EpaLocation) -> String -> EP w m (EpAnn a)
printStringAtMLocL EpAnn EpAnnImportDecl
ann2 (Maybe EpaLocation -> f (Maybe EpaLocation))
-> EpAnnImportDecl -> f EpAnnImportDecl
Lens EpAnnImportDecl (Maybe EpaLocation)
limportDeclAnnPackage (SourceText -> ShowS
sourceTextToString SourceText
src' (FastString -> String
forall a. Show a => a -> String
show FastString
v))
       ImportDeclPkgQual GhcPs
_ -> EpAnn EpAnnImportDecl -> EP w m (EpAnn EpAnnImportDecl)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn EpAnnImportDecl
ann2
    GenLocated SrcSpanAnnA ModuleName
modname' <- GenLocated SrcSpanAnnA ModuleName
-> EP w m (GenLocated SrcSpanAnnA ModuleName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs ModuleName
GenLocated SrcSpanAnnA ModuleName
modname

    EpAnn EpAnnImportDecl
ann4 <-
      case ImportDeclQualifiedStyle
qualFlag of
        ImportDeclQualifiedStyle
QualifiedPost  -- 'qualified' appears in postpositive position.
          -> EpAnn EpAnnImportDecl
-> Lens EpAnnImportDecl (Maybe EpaLocation)
-> String
-> EP w m (EpAnn EpAnnImportDecl)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe EpaLocation) -> String -> EP w m (EpAnn a)
printStringAtMLocL EpAnn EpAnnImportDecl
ann3 (Maybe EpaLocation -> f (Maybe EpaLocation))
-> EpAnnImportDecl -> f EpAnnImportDecl
Lens EpAnnImportDecl (Maybe EpaLocation)
limportDeclAnnQualified String
"qualified"
        ImportDeclQualifiedStyle
_ -> EpAnn EpAnnImportDecl -> EP w m (EpAnn EpAnnImportDecl)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn EpAnnImportDecl
ann3

    (Maybe EpaLocation
importDeclAnnAs', Maybe (GenLocated SrcSpanAnnA ModuleName)
mAs') <-
      case Maybe (XRec GhcPs ModuleName)
mAs of
        Maybe (XRec GhcPs ModuleName)
Nothing -> (Maybe EpaLocation, Maybe (GenLocated SrcSpanAnnA ModuleName))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe EpaLocation, Maybe (GenLocated SrcSpanAnnA ModuleName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnnImportDecl -> Maybe EpaLocation
importDeclAnnAs EpAnnImportDecl
an, Maybe (GenLocated SrcSpanAnnA ModuleName)
forall a. Maybe a
Nothing)
        Just XRec GhcPs ModuleName
m0 -> do
          Maybe EpaLocation
a <- Maybe EpaLocation -> String -> EP w m (Maybe EpaLocation)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe EpaLocation -> String -> EP w m (Maybe EpaLocation)
printStringAtMLoc' (EpAnnImportDecl -> Maybe EpaLocation
importDeclAnnAs EpAnnImportDecl
an) String
"as"
          GenLocated SrcSpanAnnA ModuleName
m'' <- GenLocated SrcSpanAnnA ModuleName
-> EP w m (GenLocated SrcSpanAnnA ModuleName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs ModuleName
GenLocated SrcSpanAnnA ModuleName
m0
          (Maybe EpaLocation, Maybe (GenLocated SrcSpanAnnA ModuleName))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe EpaLocation, Maybe (GenLocated SrcSpanAnnA ModuleName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe EpaLocation
a, GenLocated SrcSpanAnnA ModuleName
-> Maybe (GenLocated SrcSpanAnnA ModuleName)
forall a. a -> Maybe a
Just GenLocated SrcSpanAnnA ModuleName
m'')

    Maybe
  (ImportListInterpretation,
   GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
hiding' <-
      case Maybe (ImportListInterpretation, XRec GhcPs [LIE GhcPs])
hiding of
        Maybe (ImportListInterpretation, XRec GhcPs [LIE GhcPs])
Nothing -> Maybe
  (ImportListInterpretation,
   GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe
        (ImportListInterpretation,
         GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (ImportListInterpretation, XRec GhcPs [LIE GhcPs])
Maybe
  (ImportListInterpretation,
   GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
hiding
        Just (ImportListInterpretation
isHiding,XRec GhcPs [LIE GhcPs]
lie) -> do
          GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
lie' <- GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
-> EP
     w m (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs [LIE GhcPs]
GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
lie
          Maybe
  (ImportListInterpretation,
   GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe
        (ImportListInterpretation,
         GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ((ImportListInterpretation,
 GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
-> Maybe
     (ImportListInterpretation,
      GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
forall a. a -> Maybe a
Just (ImportListInterpretation
isHiding, GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
lie'))

    let (EpAnn Anchor
anc' EpAnnImportDecl
an' EpAnnComments
cs') = EpAnn EpAnnImportDecl
ann4
    let an2 :: EpAnnImportDecl
an2 = EpAnnImportDecl
an' { importDeclAnnAs = importDeclAnnAs'
                  , importDeclAnnPragma = importDeclAnnPragma'
                  }

    ImportDecl GhcPs -> EP w m (ImportDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCImportDecl GhcPs
-> XRec GhcPs ModuleName
-> ImportDeclPkgQual GhcPs
-> IsBootInterface
-> Bool
-> ImportDeclQualifiedStyle
-> Maybe (XRec GhcPs ModuleName)
-> Maybe (ImportListInterpretation, XRec GhcPs [LIE GhcPs])
-> ImportDecl GhcPs
forall pass.
XCImportDecl pass
-> XRec pass ModuleName
-> ImportDeclPkgQual pass
-> IsBootInterface
-> Bool
-> ImportDeclQualifiedStyle
-> Maybe (XRec pass ModuleName)
-> Maybe (ImportListInterpretation, XRec pass [LIE pass])
-> ImportDecl pass
ImportDecl (EpAnn EpAnnImportDecl -> SourceText -> Bool -> XImportDeclPass
XImportDeclPass (Anchor -> EpAnnImportDecl -> EpAnnComments -> EpAnn EpAnnImportDecl
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc' EpAnnImportDecl
an2 EpAnnComments
cs') SourceText
msrc Bool
impl)
                     XRec GhcPs ModuleName
GenLocated SrcSpanAnnA ModuleName
modname' ImportDeclPkgQual GhcPs
mpkg IsBootInterface
src Bool
safeflag ImportDeclQualifiedStyle
qualFlag Maybe (XRec GhcPs ModuleName)
Maybe (GenLocated SrcSpanAnnA ModuleName)
mAs' Maybe (ImportListInterpretation, XRec GhcPs [LIE GhcPs])
Maybe
  (ImportListInterpretation,
   GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
hiding')


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

instance ExactPrint HsDocString where
  getAnnotationEntry :: HsDocString -> Entry
getAnnotationEntry HsDocString
_ = Entry
NoEntryVal
  setAnnotationAnchor :: HsDocString -> Anchor -> EpAnnComments -> HsDocString
setAnnotationAnchor HsDocString
a Anchor
_ EpAnnComments
_ = HsDocString
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsDocString -> EP w m HsDocString
exact (MultiLineDocString HsDocStringDecorator
decorator (LHsDocStringChunk
x :| [LHsDocStringChunk]
xs)) = do
    String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance (String
"-- " String -> ShowS
forall a. [a] -> [a] -> [a]
++ HsDocStringDecorator -> String
printDecorator HsDocStringDecorator
decorator)
    Pos
pe <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
    String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"MultiLineDocString: (pe,x)=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, LHsDocStringChunk) -> String
forall a. Data a => a -> String
showAst (Pos
pe,LHsDocStringChunk
x)
    LHsDocStringChunk
x' <- LHsDocStringChunk -> EP w m LHsDocStringChunk
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsDocStringChunk
x
    [LHsDocStringChunk]
xs' <- [LHsDocStringChunk] -> EP w m [LHsDocStringChunk]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ((LHsDocStringChunk -> LHsDocStringChunk)
-> [LHsDocStringChunk] -> [LHsDocStringChunk]
forall a b. (a -> b) -> [a] -> [b]
map LHsDocStringChunk -> LHsDocStringChunk
dedentDocChunk [LHsDocStringChunk]
xs)
    HsDocString -> EP w m HsDocString
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsDocStringDecorator -> NonEmpty LHsDocStringChunk -> HsDocString
MultiLineDocString HsDocStringDecorator
decorator (LHsDocStringChunk
x' LHsDocStringChunk
-> [LHsDocStringChunk] -> NonEmpty LHsDocStringChunk
forall a. a -> [a] -> NonEmpty a
:| [LHsDocStringChunk]
xs'))
  exact HsDocString
x = do
    -- TODO: can this happen?
    String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"Not exact printing:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ HsDocString -> String
forall a. Data a => a -> String
showAst HsDocString
x
    HsDocString -> EP w m HsDocString
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsDocString
x


instance ExactPrint HsDocStringChunk where
  getAnnotationEntry :: HsDocStringChunk -> Entry
getAnnotationEntry HsDocStringChunk
_ = Entry
NoEntryVal
  setAnnotationAnchor :: HsDocStringChunk -> Anchor -> EpAnnComments -> HsDocStringChunk
setAnnotationAnchor HsDocStringChunk
a Anchor
_ EpAnnComments
_ = HsDocStringChunk
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsDocStringChunk -> EP w m HsDocStringChunk
exact HsDocStringChunk
chunk = do
    String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance (String
"--" String -> ShowS
forall a. [a] -> [a] -> [a]
++ HsDocStringChunk -> String
unpackHDSC HsDocStringChunk
chunk)
    HsDocStringChunk -> EP w m HsDocStringChunk
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsDocStringChunk
chunk


instance ExactPrint a => ExactPrint (WithHsDocIdentifiers a GhcPs) where
  getAnnotationEntry :: WithHsDocIdentifiers a GhcPs -> Entry
getAnnotationEntry WithHsDocIdentifiers a GhcPs
_ = Entry
NoEntryVal
  setAnnotationAnchor :: WithHsDocIdentifiers a GhcPs
-> Anchor -> EpAnnComments -> WithHsDocIdentifiers a GhcPs
setAnnotationAnchor WithHsDocIdentifiers a GhcPs
a Anchor
_ EpAnnComments
_ = WithHsDocIdentifiers a GhcPs
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
WithHsDocIdentifiers a GhcPs
-> EP w m (WithHsDocIdentifiers a GhcPs)
exact (WithHsDocIdentifiers a
ds [Located (IdP GhcPs)]
ids) = do
    a
ds' <- a -> EP w m a
forall a (m :: * -> *) w.
(ExactPrint a, Monad m, Monoid w) =>
a -> EP w m a
forall (m :: * -> *) w. (Monad m, Monoid w) => a -> EP w m a
exact a
ds
    WithHsDocIdentifiers a GhcPs
-> EP w m (WithHsDocIdentifiers a GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> [Located (IdP GhcPs)] -> WithHsDocIdentifiers a GhcPs
forall a pass.
a -> [Located (IdP pass)] -> WithHsDocIdentifiers a pass
WithHsDocIdentifiers a
ds' [Located (IdP GhcPs)]
ids)

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

instance ExactPrint (HsDecl GhcPs) where
  getAnnotationEntry :: HsDecl GhcPs -> Entry
getAnnotationEntry (TyClD      XTyClD GhcPs
_ TyClDecl GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (InstD      XInstD GhcPs
_ InstDecl GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (DerivD     XDerivD GhcPs
_ DerivDecl GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (ValD       XValD GhcPs
_ HsBind GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (SigD       XSigD GhcPs
_ Sig GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (KindSigD   XKindSigD GhcPs
_ StandaloneKindSig GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (DefD       XDefD GhcPs
_ DefaultDecl GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (ForD       XForD GhcPs
_ ForeignDecl GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (WarningD   XWarningD GhcPs
_ WarnDecls GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (AnnD       XAnnD GhcPs
_ AnnDecl GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (RuleD      XRuleD GhcPs
_ RuleDecls GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (SpliceD    XSpliceD GhcPs
_ SpliceDecl GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (DocD       XDocD GhcPs
_ DocDecl GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (RoleAnnotD XRoleAnnotD GhcPs
_ RoleAnnotDecl GhcPs
_) = Entry
NoEntryVal

  -- We do not recurse, the generic traversal using this feature
  -- should do that for us.
  setAnnotationAnchor :: HsDecl GhcPs -> Anchor -> EpAnnComments -> HsDecl GhcPs
setAnnotationAnchor HsDecl GhcPs
d Anchor
_ EpAnnComments
_ = HsDecl GhcPs
d

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsDecl GhcPs -> EP w m (HsDecl GhcPs)
exact (TyClD       XTyClD GhcPs
x TyClDecl GhcPs
d) = XTyClD GhcPs -> TyClDecl GhcPs -> HsDecl GhcPs
forall p. XTyClD p -> TyClDecl p -> HsDecl p
TyClD       XTyClD GhcPs
x (TyClDecl GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (TyClDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TyClDecl GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (TyClDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated TyClDecl GhcPs
d
  exact (InstD       XInstD GhcPs
x InstDecl GhcPs
d) = XInstD GhcPs -> InstDecl GhcPs -> HsDecl GhcPs
forall p. XInstD p -> InstDecl p -> HsDecl p
InstD       XInstD GhcPs
x (InstDecl GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (InstDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> InstDecl GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (InstDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated InstDecl GhcPs
d
  exact (DerivD      XDerivD GhcPs
x DerivDecl GhcPs
d) = XDerivD GhcPs -> DerivDecl GhcPs -> HsDecl GhcPs
forall p. XDerivD p -> DerivDecl p -> HsDecl p
DerivD      XDerivD GhcPs
x (DerivDecl GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (DerivDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DerivDecl GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (DerivDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated DerivDecl GhcPs
d
  exact (ValD        XValD GhcPs
x HsBind GhcPs
d) = XValD GhcPs -> HsBind GhcPs -> HsDecl GhcPs
forall p. XValD p -> HsBind p -> HsDecl p
ValD        XValD GhcPs
x (HsBind GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsBind GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HsBind GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsBind GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsBind GhcPs
d
  exact (SigD        XSigD GhcPs
x Sig GhcPs
d) = XSigD GhcPs -> Sig GhcPs -> HsDecl GhcPs
forall p. XSigD p -> Sig p -> HsDecl p
SigD        XSigD GhcPs
x (Sig GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (Sig GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (Sig GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Sig GhcPs
d
  exact (KindSigD    XKindSigD GhcPs
x StandaloneKindSig GhcPs
d) = XKindSigD GhcPs -> StandaloneKindSig GhcPs -> HsDecl GhcPs
forall p. XKindSigD p -> StandaloneKindSig p -> HsDecl p
KindSigD    XKindSigD GhcPs
x (StandaloneKindSig GhcPs -> HsDecl GhcPs)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (StandaloneKindSig GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StandaloneKindSig GhcPs
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (StandaloneKindSig GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated StandaloneKindSig GhcPs
d
  exact (DefD        XDefD GhcPs
x DefaultDecl GhcPs
d) = XDefD GhcPs -> DefaultDecl GhcPs -> HsDecl GhcPs
forall p. XDefD p -> DefaultDecl p -> HsDecl p
DefD        XDefD GhcPs
x (DefaultDecl GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (DefaultDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DefaultDecl GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (DefaultDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated DefaultDecl GhcPs
d
  exact (ForD        XForD GhcPs
x ForeignDecl GhcPs
d) = XForD GhcPs -> ForeignDecl GhcPs -> HsDecl GhcPs
forall p. XForD p -> ForeignDecl p -> HsDecl p
ForD        XForD GhcPs
x (ForeignDecl GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (ForeignDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ForeignDecl GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (ForeignDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ForeignDecl GhcPs
d
  exact (WarningD    XWarningD GhcPs
x WarnDecls GhcPs
d) = XWarningD GhcPs -> WarnDecls GhcPs -> HsDecl GhcPs
forall p. XWarningD p -> WarnDecls p -> HsDecl p
WarningD    XWarningD GhcPs
x (WarnDecls GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (WarnDecls GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WarnDecls GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (WarnDecls GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated WarnDecls GhcPs
d
  exact (AnnD        XAnnD GhcPs
x AnnDecl GhcPs
d) = XAnnD GhcPs -> AnnDecl GhcPs -> HsDecl GhcPs
forall p. XAnnD p -> AnnDecl p -> HsDecl p
AnnD        XAnnD GhcPs
x (AnnDecl GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (AnnDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnnDecl GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (AnnDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated AnnDecl GhcPs
d
  exact (RuleD       XRuleD GhcPs
x RuleDecls GhcPs
d) = XRuleD GhcPs -> RuleDecls GhcPs -> HsDecl GhcPs
forall p. XRuleD p -> RuleDecls p -> HsDecl p
RuleD       XRuleD GhcPs
x (RuleDecls GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (RuleDecls GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RuleDecls GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (RuleDecls GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated RuleDecls GhcPs
d
  exact (SpliceD     XSpliceD GhcPs
x SpliceDecl GhcPs
d) = XSpliceD GhcPs -> SpliceDecl GhcPs -> HsDecl GhcPs
forall p. XSpliceD p -> SpliceDecl p -> HsDecl p
SpliceD     XSpliceD GhcPs
x (SpliceDecl GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (SpliceDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SpliceDecl GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (SpliceDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated SpliceDecl GhcPs
d
  exact (DocD        XDocD GhcPs
x DocDecl GhcPs
d) = XDocD GhcPs -> DocDecl GhcPs -> HsDecl GhcPs
forall p. XDocD p -> DocDecl p -> HsDecl p
DocD        XDocD GhcPs
x (DocDecl GhcPs -> HsDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (DocDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DocDecl GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (DocDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated DocDecl GhcPs
d
  exact (RoleAnnotD  XRoleAnnotD GhcPs
x RoleAnnotDecl GhcPs
d) = XRoleAnnotD GhcPs -> RoleAnnotDecl GhcPs -> HsDecl GhcPs
forall p. XRoleAnnotD p -> RoleAnnotDecl p -> HsDecl p
RoleAnnotD  XRoleAnnotD GhcPs
x (RoleAnnotDecl GhcPs -> HsDecl GhcPs)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (RoleAnnotDecl GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsDecl GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RoleAnnotDecl GhcPs
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (RoleAnnotDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated RoleAnnotDecl GhcPs
d

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

instance ExactPrint (InstDecl GhcPs) where
  getAnnotationEntry :: InstDecl GhcPs -> Entry
getAnnotationEntry (ClsInstD     XClsInstD GhcPs
_ ClsInstDecl GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (DataFamInstD XDataFamInstD GhcPs
_ DataFamInstDecl GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (TyFamInstD   XTyFamInstD GhcPs
_ TyFamInstDecl GhcPs
_) = Entry
NoEntryVal

  setAnnotationAnchor :: InstDecl GhcPs -> Anchor -> EpAnnComments -> InstDecl GhcPs
setAnnotationAnchor InstDecl GhcPs
d Anchor
_ EpAnnComments
_ = InstDecl GhcPs
d


  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
InstDecl GhcPs -> EP w m (InstDecl GhcPs)
exact (ClsInstD     XClsInstD GhcPs
a  ClsInstDecl GhcPs
cid) = do
    ClsInstDecl GhcPs
cid' <- ClsInstDecl GhcPs -> EP w m (ClsInstDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ClsInstDecl GhcPs
cid
    InstDecl GhcPs -> EP w m (InstDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XClsInstD GhcPs -> ClsInstDecl GhcPs -> InstDecl GhcPs
forall pass. XClsInstD pass -> ClsInstDecl pass -> InstDecl pass
ClsInstD     XClsInstD GhcPs
a  ClsInstDecl GhcPs
cid')
  exact (DataFamInstD XDataFamInstD GhcPs
a DataFamInstDecl GhcPs
decl) = do
    DataFamInstDeclWithContext
d' <- DataFamInstDeclWithContext -> EP w m DataFamInstDeclWithContext
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated (EpAnn [AddEpAnn]
-> TopLevelFlag
-> DataFamInstDecl GhcPs
-> DataFamInstDeclWithContext
DataFamInstDeclWithContext EpAnn [AddEpAnn]
forall ann. EpAnn ann
noAnn TopLevelFlag
TopLevel DataFamInstDecl GhcPs
decl)
    InstDecl GhcPs -> EP w m (InstDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XDataFamInstD GhcPs -> DataFamInstDecl GhcPs -> InstDecl GhcPs
forall pass.
XDataFamInstD pass -> DataFamInstDecl pass -> InstDecl pass
DataFamInstD XDataFamInstD GhcPs
a (DataFamInstDeclWithContext -> DataFamInstDecl GhcPs
dc_d DataFamInstDeclWithContext
d'))
  exact (TyFamInstD XTyFamInstD GhcPs
a TyFamInstDecl GhcPs
eqn) = do
    TyFamInstDecl GhcPs
eqn' <- TyFamInstDecl GhcPs -> EP w m (TyFamInstDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated TyFamInstDecl GhcPs
eqn
    InstDecl GhcPs -> EP w m (InstDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XTyFamInstD GhcPs -> TyFamInstDecl GhcPs -> InstDecl GhcPs
forall pass.
XTyFamInstD pass -> TyFamInstDecl pass -> InstDecl pass
TyFamInstD XTyFamInstD GhcPs
a TyFamInstDecl GhcPs
eqn')

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

data DataFamInstDeclWithContext
  = DataFamInstDeclWithContext
    { DataFamInstDeclWithContext -> EpAnn [AddEpAnn]
_dc_a :: EpAnn [AddEpAnn]
    , DataFamInstDeclWithContext -> TopLevelFlag
_dc_f :: TopLevelFlag
    , DataFamInstDeclWithContext -> DataFamInstDecl GhcPs
dc_d :: DataFamInstDecl GhcPs
    }

instance ExactPrint DataFamInstDeclWithContext where
  getAnnotationEntry :: DataFamInstDeclWithContext -> Entry
getAnnotationEntry (DataFamInstDeclWithContext EpAnn [AddEpAnn]
_ TopLevelFlag
_ (DataFamInstDecl (FamEqn { feqn_ext :: forall pass rhs. FamEqn pass rhs -> XCFamEqn pass rhs
feqn_ext = XCFamEqn GhcPs (HsDataDefn GhcPs)
an})))
    = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCFamEqn GhcPs (HsDataDefn GhcPs)
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: DataFamInstDeclWithContext
-> Anchor -> EpAnnComments -> DataFamInstDeclWithContext
setAnnotationAnchor (DataFamInstDeclWithContext EpAnn [AddEpAnn]
a TopLevelFlag
c (DataFamInstDecl FamEqn GhcPs (HsDataDefn GhcPs)
fe)) Anchor
anc EpAnnComments
cs
    = (EpAnn [AddEpAnn]
-> TopLevelFlag
-> DataFamInstDecl GhcPs
-> DataFamInstDeclWithContext
DataFamInstDeclWithContext EpAnn [AddEpAnn]
a TopLevelFlag
c (FamEqn GhcPs (HsDataDefn GhcPs) -> DataFamInstDecl GhcPs
forall pass. FamEqn pass (HsDataDefn pass) -> DataFamInstDecl pass
DataFamInstDecl (FamEqn GhcPs (HsDataDefn GhcPs)
fe { feqn_ext = (setAnchorEpa (feqn_ext fe) anc cs)})))
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DataFamInstDeclWithContext -> EP w m DataFamInstDeclWithContext
exact (DataFamInstDeclWithContext EpAnn [AddEpAnn]
an TopLevelFlag
c DataFamInstDecl GhcPs
d) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"starting DataFamInstDeclWithContext:an=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpAnn [AddEpAnn] -> String
forall a. Data a => a -> String
showAst EpAnn [AddEpAnn]
an
    (EpAnn [AddEpAnn]
an', DataFamInstDecl GhcPs
d') <- EpAnn [AddEpAnn]
-> TopLevelFlag
-> DataFamInstDecl GhcPs
-> EP w m (EpAnn [AddEpAnn], DataFamInstDecl GhcPs)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> TopLevelFlag
-> DataFamInstDecl GhcPs
-> EP w m (EpAnn [AddEpAnn], DataFamInstDecl GhcPs)
exactDataFamInstDecl EpAnn [AddEpAnn]
an TopLevelFlag
c DataFamInstDecl GhcPs
d
    DataFamInstDeclWithContext -> EP w m DataFamInstDeclWithContext
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
-> TopLevelFlag
-> DataFamInstDecl GhcPs
-> DataFamInstDeclWithContext
DataFamInstDeclWithContext EpAnn [AddEpAnn]
an' TopLevelFlag
c DataFamInstDecl GhcPs
d')

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

exactDataFamInstDecl :: (Monad m, Monoid w)
                     => EpAnn [AddEpAnn] -> TopLevelFlag -> DataFamInstDecl GhcPs
                     -> EP w m (EpAnn [AddEpAnn], DataFamInstDecl GhcPs)
exactDataFamInstDecl :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> TopLevelFlag
-> DataFamInstDecl GhcPs
-> EP w m (EpAnn [AddEpAnn], DataFamInstDecl GhcPs)
exactDataFamInstDecl EpAnn [AddEpAnn]
an TopLevelFlag
top_lvl
  (DataFamInstDecl (FamEqn { feqn_ext :: forall pass rhs. FamEqn pass rhs -> XCFamEqn pass rhs
feqn_ext    = XCFamEqn GhcPs (HsDataDefn GhcPs)
an2
                           , feqn_tycon :: forall pass rhs. FamEqn pass rhs -> LIdP pass
feqn_tycon  = LIdP GhcPs
tycon
                           , feqn_bndrs :: forall pass rhs. FamEqn pass rhs -> HsOuterFamEqnTyVarBndrs pass
feqn_bndrs  = HsOuterFamEqnTyVarBndrs GhcPs
bndrs
                           , feqn_pats :: forall pass rhs. FamEqn pass rhs -> HsTyPats pass
feqn_pats   = HsTyPats GhcPs
pats
                           , feqn_fixity :: forall pass rhs. FamEqn pass rhs -> LexicalFixity
feqn_fixity = LexicalFixity
fixity
                           , feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
feqn_rhs    = HsDataDefn GhcPs
defn })) = do
    (EpAnn [AddEpAnn]
an', EpAnn [AddEpAnn]
an2', GenLocated SrcSpanAnnN RdrName
tycon', HsOuterFamEqnTyVarBndrs GhcPs
bndrs', [HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
_,  Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
_mc, HsDataDefn GhcPs
defn') <- EpAnn [AddEpAnn]
-> (Maybe (LHsContext GhcPs)
    -> EP
         w
         m
         (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
          HsOuterFamEqnTyVarBndrs GhcPs,
          [HsArg
             (GenLocated SrcSpanAnnA (HsType GhcPs))
             (GenLocated SrcSpanAnnA (HsType GhcPs))],
          Maybe (LHsContext GhcPs)))
-> HsDataDefn GhcPs
-> EP
     w
     m
     (EpAnn [AddEpAnn], EpAnn [AddEpAnn],
      GenLocated SrcSpanAnnN RdrName, HsOuterFamEqnTyVarBndrs GhcPs,
      [HsArg
         (GenLocated SrcSpanAnnA (HsType GhcPs))
         (GenLocated SrcSpanAnnA (HsType GhcPs))],
      Maybe (LHsContext GhcPs), HsDataDefn GhcPs)
forall (m :: * -> *) w a b.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> (Maybe (LHsContext GhcPs)
    -> EP
         w
         m
         (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName, a, b,
          Maybe (LHsContext GhcPs)))
-> HsDataDefn GhcPs
-> EP
     w
     m
     (EpAnn [AddEpAnn], EpAnn [AddEpAnn],
      GenLocated SrcSpanAnnN RdrName, a, b, Maybe (LHsContext GhcPs),
      HsDataDefn GhcPs)
exactDataDefn XCFamEqn GhcPs (HsDataDefn GhcPs)
EpAnn [AddEpAnn]
an2 Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsOuterFamEqnTyVarBndrs GhcPs, HsTyPats GhcPs,
      Maybe (LHsContext GhcPs))
Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsOuterFamEqnTyVarBndrs GhcPs,
      [HsArg
         (GenLocated SrcSpanAnnA (HsType GhcPs))
         (GenLocated SrcSpanAnnA (HsType GhcPs))],
      Maybe (LHsContext GhcPs))
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsOuterFamEqnTyVarBndrs GhcPs, HsTyPats GhcPs,
      Maybe (LHsContext GhcPs))
pp_hdr HsDataDefn GhcPs
defn
                                                 -- See Note [an and an2 in exactDataFamInstDecl]
    (EpAnn [AddEpAnn], DataFamInstDecl GhcPs)
-> EP w m (EpAnn [AddEpAnn], DataFamInstDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return
      (EpAnn [AddEpAnn]
an',
       FamEqn GhcPs (HsDataDefn GhcPs) -> DataFamInstDecl GhcPs
forall pass. FamEqn pass (HsDataDefn pass) -> DataFamInstDecl pass
DataFamInstDecl ( FamEqn { feqn_ext :: XCFamEqn GhcPs (HsDataDefn GhcPs)
feqn_ext    = XCFamEqn GhcPs (HsDataDefn GhcPs)
EpAnn [AddEpAnn]
an2'
                                , feqn_tycon :: LIdP GhcPs
feqn_tycon  = LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
tycon'
                                , feqn_bndrs :: HsOuterFamEqnTyVarBndrs GhcPs
feqn_bndrs  = HsOuterFamEqnTyVarBndrs GhcPs
bndrs'
                                , feqn_pats :: HsTyPats GhcPs
feqn_pats   = HsTyPats GhcPs
pats
                                , feqn_fixity :: LexicalFixity
feqn_fixity = LexicalFixity
fixity
                                , feqn_rhs :: HsDataDefn GhcPs
feqn_rhs    = HsDataDefn GhcPs
defn' }))
                    EP w m (EpAnn [AddEpAnn], DataFamInstDecl GhcPs)
-> String -> EP w m (EpAnn [AddEpAnn], DataFamInstDecl GhcPs)
forall c. c -> String -> c
`debug` (String
"exactDataFamInstDecl: defn' derivs:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcPs)] -> String
forall a. Data a => a -> String
showAst (HsDataDefn GhcPs -> HsDeriving GhcPs
forall pass. HsDataDefn pass -> HsDeriving pass
dd_derivs HsDataDefn GhcPs
defn'))
  where
    pp_hdr :: (Monad m, Monoid w)
           => Maybe (LHsContext GhcPs)
           -> EP w m ( EpAnn [AddEpAnn]
                     , LocatedN RdrName
                     , HsOuterTyVarBndrs () GhcPs
                     , HsTyPats GhcPs
                     , Maybe (LHsContext GhcPs))
    pp_hdr :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsOuterFamEqnTyVarBndrs GhcPs, HsTyPats GhcPs,
      Maybe (LHsContext GhcPs))
pp_hdr Maybe (LHsContext GhcPs)
mctxt = do
      EpAnn [AddEpAnn]
an0 <- case TopLevelFlag
top_lvl of
               TopLevelFlag
TopLevel -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnInstance -- TODO: maybe in toplevel
               TopLevelFlag
NotTopLevel -> EpAnn [AddEpAnn]
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn [AddEpAnn]
an
      EpAnn [AddEpAnn]
-> GenLocated SrcSpanAnnN RdrName
-> HsOuterFamEqnTyVarBndrs GhcPs
-> HsTyPats GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsOuterFamEqnTyVarBndrs GhcPs, HsTyPats GhcPs,
      Maybe (LHsContext GhcPs))
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> GenLocated SrcSpanAnnN RdrName
-> HsOuterFamEqnTyVarBndrs GhcPs
-> HsTyPats GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsOuterFamEqnTyVarBndrs GhcPs, HsTyPats GhcPs,
      Maybe (LHsContext GhcPs))
exactHsFamInstLHS EpAnn [AddEpAnn]
an0 LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
tycon HsOuterFamEqnTyVarBndrs GhcPs
bndrs HsTyPats GhcPs
pats LexicalFixity
fixity Maybe (LHsContext GhcPs)
mctxt

{-
Note [an and an2 in exactDataFamInstDecl]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The exactDataFamInstDecl function is called to render a
DataFamInstDecl within its surrounding context. This context is
rendered via the 'pp_hdr' function, which uses the exact print
annotations from that context, named 'an'.  The EPAs used for
rendering the DataDefn are contained in the FamEqn, and are called
'an2'.

-}

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

instance ExactPrint (DerivDecl GhcPs) where
  getAnnotationEntry :: DerivDecl GhcPs -> Entry
getAnnotationEntry (DerivDecl {deriv_ext :: forall pass. DerivDecl pass -> XCDerivDecl pass
deriv_ext = XCDerivDecl GhcPs
an} ) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCDerivDecl GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: DerivDecl GhcPs -> Anchor -> EpAnnComments -> DerivDecl GhcPs
setAnnotationAnchor DerivDecl GhcPs
dd Anchor
anc EpAnnComments
cs = DerivDecl GhcPs
dd { deriv_ext = setAnchorEpa (deriv_ext dd) anc cs }
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DerivDecl GhcPs -> EP w m (DerivDecl GhcPs)
exact (DerivDecl XCDerivDecl GhcPs
an LHsSigWcType GhcPs
typ Maybe (LDerivStrategy GhcPs)
ms Maybe (XRec GhcPs OverlapMode)
mov) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCDerivDecl GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDeriving
    Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs))
ms' <- (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs)
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs)))
-> Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs)))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (LDerivStrategy GhcPs)
Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs))
ms
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnInstance
    Maybe (GenLocated SrcSpanAnnP OverlapMode)
mov' <- (GenLocated SrcSpanAnnP OverlapMode
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnP OverlapMode))
-> Maybe (GenLocated SrcSpanAnnP OverlapMode)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (GenLocated SrcSpanAnnP OverlapMode))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM GenLocated SrcSpanAnnP OverlapMode
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnP OverlapMode)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (XRec GhcPs OverlapMode)
Maybe (GenLocated SrcSpanAnnP OverlapMode)
mov
    HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
typ' <- HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
-> EP
     w
     m
     (HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsSigWcType GhcPs
HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
typ
    DerivDecl GhcPs -> EP w m (DerivDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCDerivDecl GhcPs
-> LHsSigWcType GhcPs
-> Maybe (LDerivStrategy GhcPs)
-> Maybe (XRec GhcPs OverlapMode)
-> DerivDecl GhcPs
forall pass.
XCDerivDecl pass
-> LHsSigWcType pass
-> Maybe (LDerivStrategy pass)
-> Maybe (XRec pass OverlapMode)
-> DerivDecl pass
DerivDecl XCDerivDecl GhcPs
EpAnn [AddEpAnn]
an1 LHsSigWcType GhcPs
HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
typ' Maybe (LDerivStrategy GhcPs)
Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs))
ms' Maybe (XRec GhcPs OverlapMode)
Maybe (GenLocated SrcSpanAnnP OverlapMode)
mov')

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

instance ExactPrint (ForeignDecl GhcPs) where
  getAnnotationEntry :: ForeignDecl GhcPs -> Entry
getAnnotationEntry (ForeignImport XForeignImport GhcPs
an LIdP GhcPs
_ LHsSigType GhcPs
_  ForeignImport GhcPs
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XForeignImport GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (ForeignExport XForeignExport GhcPs
an LIdP GhcPs
_ LHsSigType GhcPs
_  ForeignExport GhcPs
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XForeignExport GhcPs
EpAnn [AddEpAnn]
an

  setAnnotationAnchor :: ForeignDecl GhcPs -> Anchor -> EpAnnComments -> ForeignDecl GhcPs
setAnnotationAnchor (ForeignImport XForeignImport GhcPs
an LIdP GhcPs
a LHsSigType GhcPs
b ForeignImport GhcPs
c) Anchor
anc EpAnnComments
cs = XForeignImport GhcPs
-> LIdP GhcPs
-> LHsSigType GhcPs
-> ForeignImport GhcPs
-> ForeignDecl GhcPs
forall pass.
XForeignImport pass
-> LIdP pass
-> LHsSigType pass
-> ForeignImport pass
-> ForeignDecl pass
ForeignImport (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XForeignImport GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LIdP GhcPs
a LHsSigType GhcPs
b ForeignImport GhcPs
c
  setAnnotationAnchor (ForeignExport XForeignExport GhcPs
an LIdP GhcPs
a LHsSigType GhcPs
b ForeignExport GhcPs
c) Anchor
anc EpAnnComments
cs = XForeignExport GhcPs
-> LIdP GhcPs
-> LHsSigType GhcPs
-> ForeignExport GhcPs
-> ForeignDecl GhcPs
forall pass.
XForeignExport pass
-> LIdP pass
-> LHsSigType pass
-> ForeignExport pass
-> ForeignDecl pass
ForeignExport (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XForeignExport GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LIdP GhcPs
a LHsSigType GhcPs
b ForeignExport GhcPs
c

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
ForeignDecl GhcPs -> EP w m (ForeignDecl GhcPs)
exact (ForeignImport XForeignImport GhcPs
an LIdP GhcPs
n LHsSigType GhcPs
ty ForeignImport GhcPs
fimport) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XForeignImport GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnForeign
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnImport

    ForeignImport GhcPs
fimport' <- ForeignImport GhcPs -> EP w m (ForeignImport GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ForeignImport GhcPs
fimport

    GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
    GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty
    ForeignDecl GhcPs -> EP w m (ForeignDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XForeignImport GhcPs
-> LIdP GhcPs
-> LHsSigType GhcPs
-> ForeignImport GhcPs
-> ForeignDecl GhcPs
forall pass.
XForeignImport pass
-> LIdP pass
-> LHsSigType pass
-> ForeignImport pass
-> ForeignDecl pass
ForeignImport XForeignImport GhcPs
EpAnn [AddEpAnn]
an2 LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n' LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty' ForeignImport GhcPs
fimport')

  exact (ForeignExport XForeignExport GhcPs
an LIdP GhcPs
n LHsSigType GhcPs
ty ForeignExport GhcPs
fexport) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XForeignExport GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnForeign
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnExport
    ForeignExport GhcPs
fexport' <- ForeignExport GhcPs -> EP w m (ForeignExport GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ForeignExport GhcPs
fexport
    GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
    GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty
    ForeignDecl GhcPs -> EP w m (ForeignDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XForeignExport GhcPs
-> LIdP GhcPs
-> LHsSigType GhcPs
-> ForeignExport GhcPs
-> ForeignDecl GhcPs
forall pass.
XForeignExport pass
-> LIdP pass
-> LHsSigType pass
-> ForeignExport pass
-> ForeignDecl pass
ForeignExport XForeignExport GhcPs
EpAnn [AddEpAnn]
an2 LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n' LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty' ForeignExport GhcPs
fexport')

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

instance ExactPrint (ForeignImport GhcPs) where
  getAnnotationEntry :: ForeignImport GhcPs -> Entry
getAnnotationEntry = Entry -> ForeignImport GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: ForeignImport GhcPs
-> Anchor -> EpAnnComments -> ForeignImport GhcPs
setAnnotationAnchor ForeignImport GhcPs
a Anchor
_ EpAnnComments
_ = ForeignImport GhcPs
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
ForeignImport GhcPs -> EP w m (ForeignImport GhcPs)
exact (CImport (L SrcSpan
ls SourceText
src) XRec GhcPs CCallConv
cconv safety :: XRec GhcPs Safety
safety@(L SrcSpan
ll Safety
_) Maybe Header
mh CImportSpec
imp) = do
    GenLocated SrcSpan CCallConv
cconv' <- GenLocated SrcSpan CCallConv
-> EP w m (GenLocated SrcSpan CCallConv)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs CCallConv
GenLocated SrcSpan CCallConv
cconv
    Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (SrcSpan
ll SrcSpan -> SrcSpan -> Bool
forall a. Eq a => a -> a -> Bool
== SrcSpan
noSrcSpan) (RWST (EPOptions m w) (EPWriter w) EPState m ()
 -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpan Safety -> EP w m (GenLocated SrcSpan Safety)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs Safety
GenLocated SrcSpan Safety
safety EP w m (GenLocated SrcSpan Safety)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
    Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (SrcSpan
ls SrcSpan -> SrcSpan -> Bool
forall a. Eq a => a -> a -> Bool
== SrcSpan
noSrcSpan) (RWST (EPOptions m w) (EPWriter w) EPState m ()
 -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ SrcSpan
-> SourceText
-> String
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SrcSpan -> SourceText -> String -> EP w m ()
markExternalSourceText SrcSpan
ls SourceText
src String
"" RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
    ForeignImport GhcPs -> EP w m (ForeignImport GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCImport GhcPs
-> XRec GhcPs CCallConv
-> XRec GhcPs Safety
-> Maybe Header
-> CImportSpec
-> ForeignImport GhcPs
forall pass.
XCImport pass
-> XRec pass CCallConv
-> XRec pass Safety
-> Maybe Header
-> CImportSpec
-> ForeignImport pass
CImport (SrcSpan -> SourceText -> GenLocated SrcSpan SourceText
forall l e. l -> e -> GenLocated l e
L SrcSpan
ls SourceText
src) XRec GhcPs CCallConv
GenLocated SrcSpan CCallConv
cconv' XRec GhcPs Safety
safety Maybe Header
mh CImportSpec
imp)

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

instance ExactPrint (ForeignExport GhcPs) where
  getAnnotationEntry :: ForeignExport GhcPs -> Entry
getAnnotationEntry = Entry -> ForeignExport GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: ForeignExport GhcPs
-> Anchor -> EpAnnComments -> ForeignExport GhcPs
setAnnotationAnchor ForeignExport GhcPs
a Anchor
_ EpAnnComments
_ = ForeignExport GhcPs
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
ForeignExport GhcPs -> EP w m (ForeignExport GhcPs)
exact (CExport (L SrcSpan
ls SourceText
src) XRec GhcPs CExportSpec
spec) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"CExport starting"
    GenLocated SrcSpan CExportSpec
spec' <- GenLocated SrcSpan CExportSpec
-> EP w m (GenLocated SrcSpan CExportSpec)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs CExportSpec
GenLocated SrcSpan CExportSpec
spec
    Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (SrcSpan
ls SrcSpan -> SrcSpan -> Bool
forall a. Eq a => a -> a -> Bool
== SrcSpan
noSrcSpan) (RWST (EPOptions m w) (EPWriter w) EPState m ()
 -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ SrcSpan
-> SourceText
-> String
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SrcSpan -> SourceText -> String -> EP w m ()
markExternalSourceText SrcSpan
ls SourceText
src String
""
    ForeignExport GhcPs -> EP w m (ForeignExport GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCExport GhcPs -> XRec GhcPs CExportSpec -> ForeignExport GhcPs
forall pass.
XCExport pass -> XRec pass CExportSpec -> ForeignExport pass
CExport (SrcSpan -> SourceText -> GenLocated SrcSpan SourceText
forall l e. l -> e -> GenLocated l e
L SrcSpan
ls SourceText
src) XRec GhcPs CExportSpec
GenLocated SrcSpan CExportSpec
spec')

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

instance ExactPrint CExportSpec where
  getAnnotationEntry :: CExportSpec -> Entry
getAnnotationEntry = Entry -> CExportSpec -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: CExportSpec -> Anchor -> EpAnnComments -> CExportSpec
setAnnotationAnchor CExportSpec
a Anchor
_ EpAnnComments
_ = CExportSpec
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CExportSpec -> EP w m CExportSpec
exact (CExportStatic SourceText
st FastString
lbl CCallConv
cconv) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"CExportStatic starting"
    CCallConv
cconv' <- CCallConv -> EP w m CCallConv
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated CCallConv
cconv
    CExportSpec -> EP w m CExportSpec
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SourceText -> FastString -> CCallConv -> CExportSpec
CExportStatic SourceText
st FastString
lbl CCallConv
cconv')

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

instance ExactPrint Safety where
  getAnnotationEntry :: Safety -> Entry
getAnnotationEntry = Entry -> Safety -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: Safety -> Anchor -> EpAnnComments -> Safety
setAnnotationAnchor Safety
a Anchor
_ EpAnnComments
_ = Safety
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Safety -> EP w m Safety
exact = Safety -> EP w m Safety
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr

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

instance ExactPrint CCallConv where
  getAnnotationEntry :: CCallConv -> Entry
getAnnotationEntry = Entry -> CCallConv -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: CCallConv -> Anchor -> EpAnnComments -> CCallConv
setAnnotationAnchor CCallConv
a Anchor
_ EpAnnComments
_ = CCallConv
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CCallConv -> EP w m CCallConv
exact = CCallConv -> EP w m CCallConv
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr

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

instance ExactPrint (WarnDecls GhcPs) where
  getAnnotationEntry :: WarnDecls GhcPs -> Entry
getAnnotationEntry (Warnings (EpAnn [AddEpAnn]
an,SourceText
_) [LWarnDecl GhcPs]
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: WarnDecls GhcPs -> Anchor -> EpAnnComments -> WarnDecls GhcPs
setAnnotationAnchor (Warnings (EpAnn [AddEpAnn]
an,SourceText
a) [LWarnDecl GhcPs]
b) Anchor
anc EpAnnComments
cs = XWarnings GhcPs -> [LWarnDecl GhcPs] -> WarnDecls GhcPs
forall pass. XWarnings pass -> [LWarnDecl pass] -> WarnDecls pass
Warnings ((EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs),SourceText
a) [LWarnDecl GhcPs]
b

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
WarnDecls GhcPs -> EP w m (WarnDecls GhcPs)
exact (Warnings (EpAnn [AddEpAnn]
an,SourceText
src) [LWarnDecl GhcPs]
warns) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
markAnnOpen EpAnn [AddEpAnn]
an SourceText
src String
"{-# WARNING" -- Note: might be {-# DEPRECATED
    [GenLocated SrcSpanAnnA (WarnDecl GhcPs)]
warns' <- [GenLocated SrcSpanAnnA (WarnDecl GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (WarnDecl GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LWarnDecl GhcPs]
[GenLocated SrcSpanAnnA (WarnDecl GhcPs)]
warns
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"#-}")
    WarnDecls GhcPs -> EP w m (WarnDecls GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XWarnings GhcPs -> [LWarnDecl GhcPs] -> WarnDecls GhcPs
forall pass. XWarnings pass -> [LWarnDecl pass] -> WarnDecls pass
Warnings (EpAnn [AddEpAnn]
an1,SourceText
src) [LWarnDecl GhcPs]
[GenLocated SrcSpanAnnA (WarnDecl GhcPs)]
warns')

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

instance ExactPrint (WarnDecl GhcPs) where
  getAnnotationEntry :: WarnDecl GhcPs -> Entry
getAnnotationEntry (Warning XWarning GhcPs
an [LIdP GhcPs]
_ WarningTxt GhcPs
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XWarning GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: WarnDecl GhcPs -> Anchor -> EpAnnComments -> WarnDecl GhcPs
setAnnotationAnchor (Warning XWarning GhcPs
an [LIdP GhcPs]
a WarningTxt GhcPs
b) Anchor
anc EpAnnComments
cs = XWarning GhcPs
-> [LIdP GhcPs] -> WarningTxt GhcPs -> WarnDecl GhcPs
forall pass.
XWarning pass -> [LIdP pass] -> WarningTxt pass -> WarnDecl pass
Warning (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XWarning GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) [LIdP GhcPs]
a WarningTxt GhcPs
b

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
WarnDecl GhcPs -> EP w m (WarnDecl GhcPs)
exact (Warning XWarning GhcPs
an [LIdP GhcPs]
lns WarningTxt GhcPs
txt) = do
    [GenLocated SrcSpanAnnN RdrName]
lns' <- [GenLocated SrcSpanAnnN RdrName]
-> EP w m [GenLocated SrcSpanAnnN RdrName]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
lns
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XWarning GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenS -- "["
    WarningTxt GhcPs
txt' <-
      case WarningTxt GhcPs
txt of
        WarningTxt    GenLocated SrcSpan SourceText
src [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ls -> do
          [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ls' <- [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
-> EP w m [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ls
          WarningTxt GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (WarningTxt GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpan SourceText
-> [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
-> WarningTxt GhcPs
forall pass.
GenLocated SrcSpan SourceText
-> [Located (WithHsDocIdentifiers StringLiteral pass)]
-> WarningTxt pass
WarningTxt    GenLocated SrcSpan SourceText
src [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ls')
        DeprecatedTxt GenLocated SrcSpan SourceText
src [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ls -> do
          [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ls' <- [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
-> EP w m [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ls
          WarningTxt GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (WarningTxt GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpan SourceText
-> [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
-> WarningTxt GhcPs
forall pass.
GenLocated SrcSpan SourceText
-> [Located (WithHsDocIdentifiers StringLiteral pass)]
-> WarningTxt pass
DeprecatedTxt GenLocated SrcSpan SourceText
src [Located (WithHsDocIdentifiers StringLiteral GhcPs)]
ls')
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseS -- "]"
    WarnDecl GhcPs -> EP w m (WarnDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XWarning GhcPs
-> [LIdP GhcPs] -> WarningTxt GhcPs -> WarnDecl GhcPs
forall pass.
XWarning pass -> [LIdP pass] -> WarningTxt pass -> WarnDecl pass
Warning XWarning GhcPs
EpAnn [AddEpAnn]
an1 [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
lns' WarningTxt GhcPs
txt')

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

instance ExactPrint StringLiteral where
  getAnnotationEntry :: StringLiteral -> Entry
getAnnotationEntry = Entry -> StringLiteral -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: StringLiteral -> Anchor -> EpAnnComments -> StringLiteral
setAnnotationAnchor StringLiteral
a Anchor
_ EpAnnComments
_ = StringLiteral
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
StringLiteral -> EP w m StringLiteral
exact l :: StringLiteral
l@(StringLiteral SourceText
src FastString
fs Maybe RealSrcSpan
mcomma) = do
    SourceText -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SourceText -> String -> EP w m ()
printSourceText SourceText
src (ShowS
forall a. Show a => a -> String
show (FastString -> String
unpackFS FastString
fs))
    (RealSrcSpan
 -> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation)
-> Maybe RealSrcSpan -> EP w m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (\RealSrcSpan
r -> RealSrcSpan
-> String
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRs RealSrcSpan
r String
",") Maybe RealSrcSpan
mcomma
    StringLiteral -> EP w m StringLiteral
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return StringLiteral
l

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

instance ExactPrint FastString where
  getAnnotationEntry :: FastString -> Entry
getAnnotationEntry = Entry -> FastString -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: FastString -> Anchor -> EpAnnComments -> FastString
setAnnotationAnchor FastString
a Anchor
_ EpAnnComments
_ = FastString
a

  -- TODO: https://ghc.haskell.org/trac/ghc/ticket/10313 applies.
  -- exact fs = printStringAdvance (show (unpackFS fs))
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
FastString -> EP w m FastString
exact FastString
fs = String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance (FastString -> String
unpackFS FastString
fs) EP w m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m FastString
-> RWST (EPOptions m w) (EPWriter w) EPState m FastString
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> FastString
-> RWST (EPOptions m w) (EPWriter w) EPState m FastString
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return FastString
fs

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

instance ExactPrint (RuleDecls GhcPs) where
  getAnnotationEntry :: RuleDecls GhcPs -> Entry
getAnnotationEntry (HsRules (EpAnn [AddEpAnn]
an,SourceText
_) [LRuleDecl GhcPs]
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: RuleDecls GhcPs -> Anchor -> EpAnnComments -> RuleDecls GhcPs
setAnnotationAnchor (HsRules (EpAnn [AddEpAnn]
an,SourceText
a) [LRuleDecl GhcPs]
b) Anchor
anc EpAnnComments
cs = XCRuleDecls GhcPs -> [LRuleDecl GhcPs] -> RuleDecls GhcPs
forall pass. XCRuleDecls pass -> [LRuleDecl pass] -> RuleDecls pass
HsRules ((EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs),SourceText
a) [LRuleDecl GhcPs]
b
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RuleDecls GhcPs -> EP w m (RuleDecls GhcPs)
exact (HsRules (EpAnn [AddEpAnn]
an, SourceText
src) [LRuleDecl GhcPs]
rules) = do
    EpAnn [AddEpAnn]
an0 <-
      case SourceText
src of
        SourceText
NoSourceText      -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpen  (String -> Maybe String
forall a. a -> Maybe a
Just String
"{-# RULES")
        SourceText String
srcTxt -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpen  (String -> Maybe String
forall a. a -> Maybe a
Just String
srcTxt)
    [GenLocated SrcSpanAnnA (RuleDecl GhcPs)]
rules' <- [GenLocated SrcSpanAnnA (RuleDecl GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (RuleDecl GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LRuleDecl GhcPs]
[GenLocated SrcSpanAnnA (RuleDecl GhcPs)]
rules
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"#-}")
    RuleDecls GhcPs -> EP w m (RuleDecls GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCRuleDecls GhcPs -> [LRuleDecl GhcPs] -> RuleDecls GhcPs
forall pass. XCRuleDecls pass -> [LRuleDecl pass] -> RuleDecls pass
HsRules (EpAnn [AddEpAnn]
an1,SourceText
src) [LRuleDecl GhcPs]
[GenLocated SrcSpanAnnA (RuleDecl GhcPs)]
rules')

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

instance ExactPrint (RuleDecl GhcPs) where
  getAnnotationEntry :: RuleDecl GhcPs -> Entry
getAnnotationEntry (HsRule {rd_ext :: forall pass. RuleDecl pass -> XHsRule pass
rd_ext = (EpAnn HsRuleAnn
an,SourceText
_)}) = EpAnn HsRuleAnn -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn HsRuleAnn
an
  setAnnotationAnchor :: RuleDecl GhcPs -> Anchor -> EpAnnComments -> RuleDecl GhcPs
setAnnotationAnchor r :: RuleDecl GhcPs
r@(HsRule {rd_ext :: forall pass. RuleDecl pass -> XHsRule pass
rd_ext = (EpAnn HsRuleAnn
an,SourceText
a)}) Anchor
anc EpAnnComments
cs
    = RuleDecl GhcPs
r { rd_ext = (setAnchorEpa an anc cs, a)}
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RuleDecl GhcPs -> EP w m (RuleDecl GhcPs)
exact (HsRule (EpAnn HsRuleAnn
an,SourceText
nsrc) (L SrcAnn NoEpAnns
ln FastString
n) Activation
act Maybe [LHsTyVarBndr () (NoGhcTc GhcPs)]
mtybndrs [LRuleBndr GhcPs]
termbndrs XRec GhcPs (HsExpr GhcPs)
lhs XRec GhcPs (HsExpr GhcPs)
rhs) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM String
"HsRule entered"
    (L SrcAnn NoEpAnns
ln' (SourceText, FastString)
_) <- GenLocated (SrcAnn NoEpAnns) (SourceText, FastString)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (SourceText, FastString))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated (SrcAnn NoEpAnns
-> (SourceText, FastString)
-> GenLocated (SrcAnn NoEpAnns) (SourceText, FastString)
forall l e. l -> e -> GenLocated l e
L SrcAnn NoEpAnns
ln (SourceText
nsrc, FastString
n))
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM String
"HsRule after ln"
    EpAnn HsRuleAnn
an0 <- EpAnn HsRuleAnn
-> Lens HsRuleAnn [AddEpAnn]
-> Activation
-> EP w m (EpAnn HsRuleAnn)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> Activation -> EP w m (EpAnn a)
markActivation EpAnn HsRuleAnn
an ([AddEpAnn] -> f [AddEpAnn]) -> HsRuleAnn -> f HsRuleAnn
Lens HsRuleAnn [AddEpAnn]
lra_rest Activation
act
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM String
"HsRule after act"
    (EpAnn HsRuleAnn
an1, Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
mtybndrs') <-
      case Maybe [LHsTyVarBndr () (NoGhcTc GhcPs)]
mtybndrs of
        Maybe [LHsTyVarBndr () (NoGhcTc GhcPs)]
Nothing -> (EpAnn HsRuleAnn,
 Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn HsRuleAnn,
      Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn HsRuleAnn
an0, Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall a. Maybe a
Nothing)
        Just [LHsTyVarBndr () (NoGhcTc GhcPs)]
bndrs -> do
          EpAnn HsRuleAnn
an1 <-  EpAnn HsRuleAnn
-> Lens HsRuleAnn (Maybe AddEpAnn) -> EP w m (EpAnn HsRuleAnn)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn HsRuleAnn
an0 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> HsRuleAnn -> f HsRuleAnn
Lens HsRuleAnn (Maybe AddEpAnn)
lra_tyanns_fst  -- AnnForall
          [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
bndrs' <- (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)))
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsTyVarBndr () (NoGhcTc GhcPs)]
[GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
bndrs
          EpAnn HsRuleAnn
an2 <- EpAnn HsRuleAnn
-> Lens HsRuleAnn (Maybe AddEpAnn) -> EP w m (EpAnn HsRuleAnn)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn HsRuleAnn
an1 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> HsRuleAnn -> f HsRuleAnn
Lens HsRuleAnn (Maybe AddEpAnn)
lra_tyanns_snd  -- AnnDot
          (EpAnn HsRuleAnn,
 Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn HsRuleAnn,
      Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn HsRuleAnn
an2, [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall a. a -> Maybe a
Just [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
bndrs')

    EpAnn HsRuleAnn
an2 <- EpAnn HsRuleAnn
-> Lens HsRuleAnn (Maybe AddEpAnn) -> EP w m (EpAnn HsRuleAnn)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn HsRuleAnn
an1 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> HsRuleAnn -> f HsRuleAnn
Lens HsRuleAnn (Maybe AddEpAnn)
lra_tmanns_fst  -- AnnForall
    [GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcPs)]
termbndrs' <- (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcPs)
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcPs)))
-> [GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcPs)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LRuleBndr GhcPs]
[GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcPs)]
termbndrs
    EpAnn HsRuleAnn
an3 <- EpAnn HsRuleAnn
-> Lens HsRuleAnn (Maybe AddEpAnn) -> EP w m (EpAnn HsRuleAnn)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn HsRuleAnn
an2 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> HsRuleAnn -> f HsRuleAnn
Lens HsRuleAnn (Maybe AddEpAnn)
lra_tmanns_snd  -- AnnDot

    GenLocated SrcSpanAnnA (HsExpr GhcPs)
lhs' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
lhs
    EpAnn HsRuleAnn
an4 <- EpAnn HsRuleAnn
-> Lens HsRuleAnn [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn HsRuleAnn)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn HsRuleAnn
an3 ([AddEpAnn] -> f [AddEpAnn]) -> HsRuleAnn -> f HsRuleAnn
Lens HsRuleAnn [AddEpAnn]
lra_rest AnnKeywordId
AnnEqual
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
rhs' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
rhs
    RuleDecl GhcPs -> EP w m (RuleDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsRule GhcPs
-> XRec GhcPs FastString
-> Activation
-> Maybe [LHsTyVarBndr () (NoGhcTc GhcPs)]
-> [LRuleBndr GhcPs]
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> RuleDecl GhcPs
forall pass.
XHsRule pass
-> XRec pass FastString
-> Activation
-> Maybe [LHsTyVarBndr () (NoGhcTc pass)]
-> [LRuleBndr pass]
-> XRec pass (HsExpr pass)
-> XRec pass (HsExpr pass)
-> RuleDecl pass
HsRule (EpAnn HsRuleAnn
an4,SourceText
nsrc) (SrcAnn NoEpAnns
-> FastString -> GenLocated (SrcAnn NoEpAnns) FastString
forall l e. l -> e -> GenLocated l e
L SrcAnn NoEpAnns
ln' FastString
n) Activation
act Maybe [LHsTyVarBndr () (NoGhcTc GhcPs)]
Maybe [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
mtybndrs' [LRuleBndr GhcPs]
[GenLocated (SrcAnn NoEpAnns) (RuleBndr GhcPs)]
termbndrs' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
lhs' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
rhs')

markActivation :: (Monad m, Monoid w)
  => EpAnn a -> Lens a [AddEpAnn] -> Activation -> EP w m (EpAnn a)
markActivation :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> Activation -> EP w m (EpAnn a)
markActivation EpAnn a
an Lens a [AddEpAnn]
l Activation
act = do
  case Activation
act of
    ActiveBefore SourceText
src Int
phase -> do
      EpAnn a
an0 <- EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn a)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn a
an ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
AnnOpenS --  '['
      EpAnn a
an1 <- EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn a)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn a
an0 ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
AnnTilde -- ~
      EpAnn a
an2 <- EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn a
an1 ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
AnnVal (String -> Maybe String
forall a. a -> Maybe a
Just (SourceText -> String -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix SourceText
src (Int -> String
forall a. Show a => a -> String
show Int
phase) String
""))
      EpAnn a
an3 <- EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn a)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn a
an2 ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
AnnCloseS -- ']'
      EpAnn a -> EP w m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
an3
    ActiveAfter SourceText
src Int
phase -> do
      EpAnn a
an0 <- EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn a)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn a
an ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
AnnOpenS --  '['
      EpAnn a
an1 <- EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn a
an0 ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
AnnVal (String -> Maybe String
forall a. a -> Maybe a
Just (SourceText -> String -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix SourceText
src (Int -> String
forall a. Show a => a -> String
show Int
phase) String
""))
      EpAnn a
an2 <- EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn a)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn a
an1 ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
AnnCloseS -- ']'
      EpAnn a -> EP w m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
an2
    Activation
NeverActive -> do
      EpAnn a
an0 <- EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn a)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn a
an ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
AnnOpenS --  '['
      EpAnn a
an1 <- EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn a)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn a
an0 ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
AnnTilde -- ~
      EpAnn a
an2 <- EpAnn a -> Lens a [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn a)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn a
an1 ([AddEpAnn] -> f [AddEpAnn]) -> a -> f a
Lens a [AddEpAnn]
l AnnKeywordId
AnnCloseS -- ']'
      EpAnn a -> EP w m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
an2
    Activation
_ -> EpAnn a -> EP w m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
an

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

instance ExactPrint (SpliceDecl GhcPs) where
  getAnnotationEntry :: SpliceDecl GhcPs -> Entry
getAnnotationEntry = Entry -> SpliceDecl GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: SpliceDecl GhcPs -> Anchor -> EpAnnComments -> SpliceDecl GhcPs
setAnnotationAnchor SpliceDecl GhcPs
a Anchor
_ EpAnnComments
_ = SpliceDecl GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SpliceDecl GhcPs -> EP w m (SpliceDecl GhcPs)
exact (SpliceDecl XSpliceDecl GhcPs
x XRec GhcPs (HsUntypedSplice GhcPs)
splice SpliceDecoration
flag) = do
    GenLocated SrcSpanAnnA (HsUntypedSplice GhcPs)
splice' <- GenLocated SrcSpanAnnA (HsUntypedSplice GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsUntypedSplice GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsUntypedSplice GhcPs)
GenLocated SrcSpanAnnA (HsUntypedSplice GhcPs)
splice
    SpliceDecl GhcPs -> EP w m (SpliceDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSpliceDecl GhcPs
-> XRec GhcPs (HsUntypedSplice GhcPs)
-> SpliceDecoration
-> SpliceDecl GhcPs
forall p.
XSpliceDecl p
-> XRec p (HsUntypedSplice p) -> SpliceDecoration -> SpliceDecl p
SpliceDecl XSpliceDecl GhcPs
x XRec GhcPs (HsUntypedSplice GhcPs)
GenLocated SrcSpanAnnA (HsUntypedSplice GhcPs)
splice' SpliceDecoration
flag)

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

instance ExactPrint (DocDecl GhcPs) where
  getAnnotationEntry :: DocDecl GhcPs -> Entry
getAnnotationEntry = Entry -> DocDecl GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: DocDecl GhcPs -> Anchor -> EpAnnComments -> DocDecl GhcPs
setAnnotationAnchor DocDecl GhcPs
a Anchor
_ EpAnnComments
_ = DocDecl GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DocDecl GhcPs -> EP w m (DocDecl GhcPs)
exact DocDecl GhcPs
v = DocDecl GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (DocDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return DocDecl GhcPs
v
  -- exact v = case v of
  --   (DocCommentNext ds)    -> DocCommentNext <$> exact ds
  --   (DocCommentPrev ds)    -> DocCommentPrev <$> exact ds
  --   (DocCommentNamed s ds) -> DocCommentNamed s <$> exact ds
  --   (DocGroup i ds)        -> DocGroup i <$> exact ds

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

instance ExactPrint (RoleAnnotDecl GhcPs) where
  getAnnotationEntry :: RoleAnnotDecl GhcPs -> Entry
getAnnotationEntry (RoleAnnotDecl XCRoleAnnotDecl GhcPs
an LIdP GhcPs
_ [XRec GhcPs (Maybe Role)]
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCRoleAnnotDecl GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: RoleAnnotDecl GhcPs
-> Anchor -> EpAnnComments -> RoleAnnotDecl GhcPs
setAnnotationAnchor (RoleAnnotDecl XCRoleAnnotDecl GhcPs
an LIdP GhcPs
a [XRec GhcPs (Maybe Role)]
b) Anchor
anc EpAnnComments
cs = XCRoleAnnotDecl GhcPs
-> LIdP GhcPs -> [XRec GhcPs (Maybe Role)] -> RoleAnnotDecl GhcPs
forall pass.
XCRoleAnnotDecl pass
-> LIdP pass -> [XRec pass (Maybe Role)] -> RoleAnnotDecl pass
RoleAnnotDecl (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCRoleAnnotDecl GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LIdP GhcPs
a [XRec GhcPs (Maybe Role)]
b
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RoleAnnotDecl GhcPs -> EP w m (RoleAnnotDecl GhcPs)
exact (RoleAnnotDecl XCRoleAnnotDecl GhcPs
an LIdP GhcPs
ltycon [XRec GhcPs (Maybe Role)]
roles) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCRoleAnnotDecl GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnType
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnRole
    GenLocated SrcSpanAnnN RdrName
ltycon' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ltycon
    let markRole :: GenLocated (SrcSpanAnn' a) (Maybe a)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated (SrcSpanAnn' a) (Maybe a))
markRole (L SrcSpanAnn' a
l (Just a
r)) = do
          (L SrcSpanAnn' a
_ a
r') <- GenLocated (SrcSpanAnn' a) a
-> EP w m (GenLocated (SrcSpanAnn' a) a)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated (SrcSpanAnn' a -> a -> GenLocated (SrcSpanAnn' a) a
forall l e. l -> e -> GenLocated l e
L SrcSpanAnn' a
l a
r)
          GenLocated (SrcSpanAnn' a) (Maybe a)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated (SrcSpanAnn' a) (Maybe a))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnn' a -> Maybe a -> GenLocated (SrcSpanAnn' a) (Maybe a)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnn' a
l (a -> Maybe a
forall a. a -> Maybe a
Just a
r'))
        markRole (L SrcSpanAnn' a
l Maybe a
Nothing) = do
          SrcSpan -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SrcSpan -> String -> EP w m ()
printStringAtSs (SrcSpanAnn' a -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnn' a
l) String
"_"
          GenLocated (SrcSpanAnn' a) (Maybe a)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated (SrcSpanAnn' a) (Maybe a))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnn' a -> Maybe a -> GenLocated (SrcSpanAnn' a) (Maybe a)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnn' a
l Maybe a
forall a. Maybe a
Nothing)
    [GenLocated (SrcAnn NoEpAnns) (Maybe Role)]
roles' <- (GenLocated (SrcAnn NoEpAnns) (Maybe Role)
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated (SrcAnn NoEpAnns) (Maybe Role)))
-> [GenLocated (SrcAnn NoEpAnns) (Maybe Role)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated (SrcAnn NoEpAnns) (Maybe Role)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated (SrcAnn NoEpAnns) (Maybe Role)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated (SrcAnn NoEpAnns) (Maybe Role))
forall {w} {m :: * -> *} {a} {a}.
(Monoid w, Monad m, ExactPrint (GenLocated (SrcSpanAnn' a) a),
 Typeable a, Typeable a) =>
GenLocated (SrcSpanAnn' a) (Maybe a)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated (SrcSpanAnn' a) (Maybe a))
markRole [XRec GhcPs (Maybe Role)]
[GenLocated (SrcAnn NoEpAnns) (Maybe Role)]
roles
    RoleAnnotDecl GhcPs -> EP w m (RoleAnnotDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCRoleAnnotDecl GhcPs
-> LIdP GhcPs -> [XRec GhcPs (Maybe Role)] -> RoleAnnotDecl GhcPs
forall pass.
XCRoleAnnotDecl pass
-> LIdP pass -> [XRec pass (Maybe Role)] -> RoleAnnotDecl pass
RoleAnnotDecl XCRoleAnnotDecl GhcPs
EpAnn [AddEpAnn]
an1 LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ltycon' [XRec GhcPs (Maybe Role)]
[GenLocated (SrcAnn NoEpAnns) (Maybe Role)]
roles')

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

instance ExactPrint Role where
  getAnnotationEntry :: Role -> Entry
getAnnotationEntry = Entry -> Role -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: Role -> Anchor -> EpAnnComments -> Role
setAnnotationAnchor Role
a Anchor
_ EpAnnComments
_ = Role
a
  exact :: forall (m :: * -> *) w. (Monad m, Monoid w) => Role -> EP w m Role
exact = Role -> EP w m Role
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr

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

instance ExactPrint (RuleBndr GhcPs) where
  getAnnotationEntry :: RuleBndr GhcPs -> Entry
getAnnotationEntry = Entry -> RuleBndr GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: RuleBndr GhcPs -> Anchor -> EpAnnComments -> RuleBndr GhcPs
setAnnotationAnchor RuleBndr GhcPs
a Anchor
_ EpAnnComments
_ = RuleBndr GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RuleBndr GhcPs -> EP w m (RuleBndr GhcPs)
exact (RuleBndr XCRuleBndr GhcPs
x LIdP GhcPs
ln) = do
    GenLocated SrcSpanAnnN RdrName
ln' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ln
    RuleBndr GhcPs -> EP w m (RuleBndr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCRuleBndr GhcPs -> LIdP GhcPs -> RuleBndr GhcPs
forall pass. XCRuleBndr pass -> LIdP pass -> RuleBndr pass
RuleBndr XCRuleBndr GhcPs
x LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ln')
  exact (RuleBndrSig XRuleBndrSig GhcPs
an LIdP GhcPs
ln (HsPS XHsPS GhcPs
x LHsType GhcPs
ty)) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XRuleBndrSig GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenP -- "("
    GenLocated SrcSpanAnnN RdrName
ln' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ln
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseP -- ")"
    RuleBndr GhcPs -> EP w m (RuleBndr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XRuleBndrSig GhcPs
-> LIdP GhcPs -> HsPatSigType GhcPs -> RuleBndr GhcPs
forall pass.
XRuleBndrSig pass
-> LIdP pass -> HsPatSigType pass -> RuleBndr pass
RuleBndrSig XRuleBndrSig GhcPs
EpAnn [AddEpAnn]
an2 LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ln' (XHsPS GhcPs -> LHsType GhcPs -> HsPatSigType GhcPs
forall pass. XHsPS pass -> LHsType pass -> HsPatSigType pass
HsPS XHsPS GhcPs
x LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty'))

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

instance (ExactPrint body) => ExactPrint (FamEqn GhcPs body) where
  getAnnotationEntry :: FamEqn GhcPs body -> Entry
getAnnotationEntry (FamEqn { feqn_ext :: forall pass rhs. FamEqn pass rhs -> XCFamEqn pass rhs
feqn_ext = XCFamEqn GhcPs body
an}) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCFamEqn GhcPs body
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: FamEqn GhcPs body -> Anchor -> EpAnnComments -> FamEqn GhcPs body
setAnnotationAnchor FamEqn GhcPs body
fe Anchor
anc EpAnnComments
cs = FamEqn GhcPs body
fe {feqn_ext = setAnchorEpa (feqn_ext fe) anc cs}
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
FamEqn GhcPs body -> EP w m (FamEqn GhcPs body)
exact (FamEqn { feqn_ext :: forall pass rhs. FamEqn pass rhs -> XCFamEqn pass rhs
feqn_ext = XCFamEqn GhcPs body
an
                , feqn_tycon :: forall pass rhs. FamEqn pass rhs -> LIdP pass
feqn_tycon  = LIdP GhcPs
tycon
                , feqn_bndrs :: forall pass rhs. FamEqn pass rhs -> HsOuterFamEqnTyVarBndrs pass
feqn_bndrs  = HsOuterFamEqnTyVarBndrs GhcPs
bndrs
                , feqn_pats :: forall pass rhs. FamEqn pass rhs -> HsTyPats pass
feqn_pats   = HsTyPats GhcPs
pats
                , feqn_fixity :: forall pass rhs. FamEqn pass rhs -> LexicalFixity
feqn_fixity = LexicalFixity
fixity
                , feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
feqn_rhs    = body
rhs }) = do
    (EpAnn [AddEpAnn]
an0, GenLocated SrcSpanAnnN RdrName
tycon', HsOuterFamEqnTyVarBndrs GhcPs
bndrs', [HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
pats', Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
_) <- EpAnn [AddEpAnn]
-> GenLocated SrcSpanAnnN RdrName
-> HsOuterFamEqnTyVarBndrs GhcPs
-> HsTyPats GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsOuterFamEqnTyVarBndrs GhcPs, HsTyPats GhcPs,
      Maybe (LHsContext GhcPs))
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> GenLocated SrcSpanAnnN RdrName
-> HsOuterFamEqnTyVarBndrs GhcPs
-> HsTyPats GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsOuterFamEqnTyVarBndrs GhcPs, HsTyPats GhcPs,
      Maybe (LHsContext GhcPs))
exactHsFamInstLHS XCFamEqn GhcPs body
EpAnn [AddEpAnn]
an LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
tycon HsOuterFamEqnTyVarBndrs GhcPs
bndrs HsTyPats GhcPs
pats LexicalFixity
fixity Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall a. Maybe a
Nothing
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnEqual
    body
rhs' <- body -> EP w m body
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated body
rhs
    FamEqn GhcPs body -> EP w m (FamEqn GhcPs body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (FamEqn { feqn_ext :: XCFamEqn GhcPs body
feqn_ext = XCFamEqn GhcPs body
EpAnn [AddEpAnn]
an1
                   , feqn_tycon :: LIdP GhcPs
feqn_tycon  = LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
tycon'
                   , feqn_bndrs :: HsOuterFamEqnTyVarBndrs GhcPs
feqn_bndrs  = HsOuterFamEqnTyVarBndrs GhcPs
bndrs'
                   , feqn_pats :: HsTyPats GhcPs
feqn_pats   = HsTyPats GhcPs
[HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
pats'
                   , feqn_fixity :: LexicalFixity
feqn_fixity = LexicalFixity
fixity
                   , feqn_rhs :: body
feqn_rhs    = body
rhs' })

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

exactHsFamInstLHS ::
      (Monad m, Monoid w)
   => EpAnn [AddEpAnn]
   -> LocatedN RdrName
   -> HsOuterTyVarBndrs () GhcPs
   -> HsTyPats GhcPs
   -> LexicalFixity
   -> Maybe (LHsContext GhcPs)
   -> EP w m ( EpAnn [AddEpAnn]
             , LocatedN RdrName
             , HsOuterTyVarBndrs () GhcPs
             , HsTyPats GhcPs, Maybe (LHsContext GhcPs))
exactHsFamInstLHS :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> GenLocated SrcSpanAnnN RdrName
-> HsOuterFamEqnTyVarBndrs GhcPs
-> HsTyPats GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsOuterFamEqnTyVarBndrs GhcPs, HsTyPats GhcPs,
      Maybe (LHsContext GhcPs))
exactHsFamInstLHS EpAnn [AddEpAnn]
an GenLocated SrcSpanAnnN RdrName
thing HsOuterFamEqnTyVarBndrs GhcPs
bndrs HsTyPats GhcPs
typats LexicalFixity
fixity Maybe (LHsContext GhcPs)
mb_ctxt = do
  EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnForall
  HsOuterFamEqnTyVarBndrs GhcPs
bndrs' <- HsOuterFamEqnTyVarBndrs GhcPs
-> EP w m (HsOuterFamEqnTyVarBndrs GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsOuterFamEqnTyVarBndrs GhcPs
bndrs
  EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDot
  Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mb_ctxt' <- (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
-> Maybe
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe
        (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mb_ctxt
  (EpAnn [AddEpAnn]
an2, GenLocated SrcSpanAnnN RdrName
thing', [HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
typats') <- EpAnn [AddEpAnn]
-> HsTyPats GhcPs
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName, HsTyPats GhcPs)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> HsTyPats GhcPs
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName, HsTyPats GhcPs)
exact_pats EpAnn [AddEpAnn]
an1 HsTyPats GhcPs
typats
  (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
 HsOuterFamEqnTyVarBndrs GhcPs,
 [HsArg
    (GenLocated SrcSpanAnnA (HsType GhcPs))
    (GenLocated SrcSpanAnnA (HsType GhcPs))],
 Maybe
   (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsOuterFamEqnTyVarBndrs GhcPs,
      [HsArg
         (GenLocated SrcSpanAnnA (HsType GhcPs))
         (GenLocated SrcSpanAnnA (HsType GhcPs))],
      Maybe
        (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an2, GenLocated SrcSpanAnnN RdrName
thing', HsOuterFamEqnTyVarBndrs GhcPs
bndrs', [HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
typats', Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mb_ctxt')
  where
    exact_pats :: (Monad m, Monoid w)
      => EpAnn [AddEpAnn] -> HsTyPats GhcPs -> EP w m (EpAnn [AddEpAnn], LocatedN RdrName, HsTyPats GhcPs)
    exact_pats :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> HsTyPats GhcPs
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName, HsTyPats GhcPs)
exact_pats EpAnn [AddEpAnn]
an' (LHsTypeArg GhcPs
patl:LHsTypeArg GhcPs
patr:HsTyPats GhcPs
pats)
      | LexicalFixity
Infix <- LexicalFixity
fixity
      = let exact_op_app :: RWST
  (EPOptions m w)
  (EPWriter w)
  EPState
  m
  (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
   [HsArg
      (GenLocated SrcSpanAnnA (HsType GhcPs))
      (GenLocated SrcSpanAnnA (HsType GhcPs))])
exact_op_app = do
              EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn [AddEpAnn]
an' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenP
              HsArg
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
patl' <- HsArg
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
-> EP
     w
     m
     (HsArg
        (GenLocated SrcSpanAnnA (HsType GhcPs))
        (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsTypeArg GhcPs
HsArg
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
patl
              GenLocated SrcSpanAnnN RdrName
thing' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated SrcSpanAnnN RdrName
thing
              HsArg
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
patr' <- HsArg
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
-> EP
     w
     m
     (HsArg
        (GenLocated SrcSpanAnnA (HsType GhcPs))
        (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsTypeArg GhcPs
HsArg
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
patr
              EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseP
              (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
 [HsArg
    (GenLocated SrcSpanAnnA (HsType GhcPs))
    (GenLocated SrcSpanAnnA (HsType GhcPs))])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      [HsArg
         (GenLocated SrcSpanAnnA (HsType GhcPs))
         (GenLocated SrcSpanAnnA (HsType GhcPs))])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, GenLocated SrcSpanAnnN RdrName
thing', [HsArg
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
patl',HsArg
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
patr'])
        in case HsTyPats GhcPs
pats of
             [] -> EP
  w
  m
  (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName, HsTyPats GhcPs)
RWST
  (EPOptions m w)
  (EPWriter w)
  EPState
  m
  (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
   [HsArg
      (GenLocated SrcSpanAnnA (HsType GhcPs))
      (GenLocated SrcSpanAnnA (HsType GhcPs))])
exact_op_app
             HsTyPats GhcPs
_  -> do
               (EpAnn [AddEpAnn]
an0, GenLocated SrcSpanAnnN RdrName
thing', [HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
p) <- RWST
  (EPOptions m w)
  (EPWriter w)
  EPState
  m
  (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
   [HsArg
      (GenLocated SrcSpanAnnA (HsType GhcPs))
      (GenLocated SrcSpanAnnA (HsType GhcPs))])
exact_op_app
               [HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
pats' <- (HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))
 -> EP
      w
      m
      (HsArg
         (GenLocated SrcSpanAnnA (HsType GhcPs))
         (GenLocated SrcSpanAnnA (HsType GhcPs))))
-> [HsArg
      (GenLocated SrcSpanAnnA (HsType GhcPs))
      (GenLocated SrcSpanAnnA (HsType GhcPs))]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [HsArg
        (GenLocated SrcSpanAnnA (HsType GhcPs))
        (GenLocated SrcSpanAnnA (HsType GhcPs))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM HsArg
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
-> EP
     w
     m
     (HsArg
        (GenLocated SrcSpanAnnA (HsType GhcPs))
        (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsTyPats GhcPs
[HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
pats
               (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
 [HsArg
    (GenLocated SrcSpanAnnA (HsType GhcPs))
    (GenLocated SrcSpanAnnA (HsType GhcPs))])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      [HsArg
         (GenLocated SrcSpanAnnA (HsType GhcPs))
         (GenLocated SrcSpanAnnA (HsType GhcPs))])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, GenLocated SrcSpanAnnN RdrName
thing', [HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
p[HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
-> [HsArg
      (GenLocated SrcSpanAnnA (HsType GhcPs))
      (GenLocated SrcSpanAnnA (HsType GhcPs))]
-> [HsArg
      (GenLocated SrcSpanAnnA (HsType GhcPs))
      (GenLocated SrcSpanAnnA (HsType GhcPs))]
forall a. [a] -> [a] -> [a]
++[HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
pats')

    exact_pats EpAnn [AddEpAnn]
an' HsTyPats GhcPs
pats = do
      EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn [AddEpAnn]
an' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenP
      GenLocated SrcSpanAnnN RdrName
thing' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated SrcSpanAnnN RdrName
thing
      [HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
pats' <- [HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [HsArg
        (GenLocated SrcSpanAnnA (HsType GhcPs))
        (GenLocated SrcSpanAnnA (HsType GhcPs))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsTyPats GhcPs
[HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
pats
      EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseP
      (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
 [HsArg
    (GenLocated SrcSpanAnnA (HsType GhcPs))
    (GenLocated SrcSpanAnnA (HsType GhcPs))])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      [HsArg
         (GenLocated SrcSpanAnnA (HsType GhcPs))
         (GenLocated SrcSpanAnnA (HsType GhcPs))])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, GenLocated SrcSpanAnnN RdrName
thing', [HsArg
   (GenLocated SrcSpanAnnA (HsType GhcPs))
   (GenLocated SrcSpanAnnA (HsType GhcPs))]
pats')

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

instance (ExactPrint tm, ExactPrint ty, Outputable tm, Outputable ty)
     =>  ExactPrint (HsArg tm ty) where
  getAnnotationEntry :: HsArg tm ty -> Entry
getAnnotationEntry = Entry -> HsArg tm ty -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: HsArg tm ty -> Anchor -> EpAnnComments -> HsArg tm ty
setAnnotationAnchor HsArg tm ty
a Anchor
_ EpAnnComments
_ = HsArg tm ty
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsArg tm ty -> EP w m (HsArg tm ty)
exact a :: HsArg tm ty
a@(HsValArg tm
tm)    = tm -> EP w m tm
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated tm
tm EP w m tm
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsArg tm ty)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsArg tm ty)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HsArg tm ty
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsArg tm ty)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsArg tm ty
a
  exact a :: HsArg tm ty
a@(HsTypeArg SrcSpan
ss ty
ty) = SrcSpan -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SrcSpan -> String -> EP w m ()
printStringAtSs SrcSpan
ss String
"@" EP w m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ty
-> RWST (EPOptions m w) (EPWriter w) EPState m ty
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ty -> RWST (EPOptions m w) (EPWriter w) EPState m ty
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ty
ty RWST (EPOptions m w) (EPWriter w) EPState m ty
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsArg tm ty)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsArg tm ty)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HsArg tm ty
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsArg tm ty)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsArg tm ty
a
  exact x :: HsArg tm ty
x@(HsArgPar SrcSpan
_sp)   = HsArg tm ty
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsArg tm ty)
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr HsArg tm ty
x -- Does not appear in original source

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

instance ExactPrint (ClsInstDecl GhcPs) where
  getAnnotationEntry :: ClsInstDecl GhcPs -> Entry
getAnnotationEntry ClsInstDecl GhcPs
cid = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn ((EpAnn [AddEpAnn], AnnSortKey) -> EpAnn [AddEpAnn]
forall a b. (a, b) -> a
fst ((EpAnn [AddEpAnn], AnnSortKey) -> EpAnn [AddEpAnn])
-> (EpAnn [AddEpAnn], AnnSortKey) -> EpAnn [AddEpAnn]
forall a b. (a -> b) -> a -> b
$ ClsInstDecl GhcPs -> XCClsInstDecl GhcPs
forall pass. ClsInstDecl pass -> XCClsInstDecl pass
cid_ext ClsInstDecl GhcPs
cid)
  setAnnotationAnchor :: ClsInstDecl GhcPs -> Anchor -> EpAnnComments -> ClsInstDecl GhcPs
setAnnotationAnchor ClsInstDecl GhcPs
cid Anchor
anc EpAnnComments
cs
    = ClsInstDecl GhcPs
cid { cid_ext = (setAnchorEpa (fst $ cid_ext cid) anc cs, (snd $ cid_ext cid)) }

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
ClsInstDecl GhcPs -> EP w m (ClsInstDecl GhcPs)
exact (ClsInstDecl { cid_ext :: forall pass. ClsInstDecl pass -> XCClsInstDecl pass
cid_ext = (EpAnn [AddEpAnn]
an, AnnSortKey
sortKey)
                     , cid_poly_ty :: forall pass. ClsInstDecl pass -> LHsSigType pass
cid_poly_ty = LHsSigType GhcPs
inst_ty, cid_binds :: forall pass. ClsInstDecl pass -> LHsBinds pass
cid_binds = LHsBinds GhcPs
binds
                     , cid_sigs :: forall pass. ClsInstDecl pass -> [LSig pass]
cid_sigs = [LSig GhcPs]
sigs, cid_tyfam_insts :: forall pass. ClsInstDecl pass -> [LTyFamInstDecl pass]
cid_tyfam_insts = [LTyFamInstDecl GhcPs]
ats
                     , cid_overlap_mode :: forall pass. ClsInstDecl pass -> Maybe (XRec pass OverlapMode)
cid_overlap_mode = Maybe (XRec GhcPs OverlapMode)
mbOverlap
                     , cid_datafam_insts :: forall pass. ClsInstDecl pass -> [LDataFamInstDecl pass]
cid_datafam_insts = [LDataFamInstDecl GhcPs]
adts })
      = do
          (EpAnn [AddEpAnn]
an0, Maybe (GenLocated SrcSpanAnnP OverlapMode)
mbOverlap', GenLocated SrcSpanAnnA (HsSigType GhcPs)
inst_ty') <- RWST
  (EPOptions m w)
  (EPWriter w)
  EPState
  m
  (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnP OverlapMode),
   GenLocated SrcSpanAnnA (HsSigType GhcPs))
top_matter
          EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC
          EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
AnnSemi
          [Dynamic]
ds <- AnnSortKey -> [(RealSrcSpan, EP w m Dynamic)] -> EP w m [Dynamic]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnSortKey -> [(RealSrcSpan, EP w m Dynamic)] -> EP w m [Dynamic]
withSortKey AnnSortKey
sortKey
                               ([LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
[LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationA [LTyFamInstDecl GhcPs]
[LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
ats
                             [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall a. [a] -> [a] -> [a]
++ EpAnn [AddEpAnn]
-> [LDataFamInstDecl GhcPs] -> [(RealSrcSpan, EP w m Dynamic)]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> [LDataFamInstDecl GhcPs] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationF EpAnn [AddEpAnn]
an [LDataFamInstDecl GhcPs]
adts
                             [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall a. [a] -> [a] -> [a]
++ [LocatedAn AnnListItem (HsBind GhcPs)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
[LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationA (Bag (LocatedAn AnnListItem (HsBind GhcPs))
-> [LocatedAn AnnListItem (HsBind GhcPs)]
forall a. Bag a -> [a]
bagToList LHsBinds GhcPs
Bag (LocatedAn AnnListItem (HsBind GhcPs))
binds)
                             [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall a. [a] -> [a] -> [a]
++ [LocatedAn AnnListItem (Sig GhcPs)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
[LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationA [LSig GhcPs]
[LocatedAn AnnListItem (Sig GhcPs)]
sigs
                               )
          EpAnn [AddEpAnn]
an3 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an2 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC -- '}'
          let
            ats' :: [LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
ats'   = [Dynamic] -> [LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds
            adts' :: [GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)]
adts'  = [Dynamic] -> [GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)]
forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds
            binds' :: Bag (LocatedAn AnnListItem (HsBind GhcPs))
binds' = [LocatedAn AnnListItem (HsBind GhcPs)]
-> Bag (LocatedAn AnnListItem (HsBind GhcPs))
forall a. [a] -> Bag a
listToBag ([LocatedAn AnnListItem (HsBind GhcPs)]
 -> Bag (LocatedAn AnnListItem (HsBind GhcPs)))
-> [LocatedAn AnnListItem (HsBind GhcPs)]
-> Bag (LocatedAn AnnListItem (HsBind GhcPs))
forall a b. (a -> b) -> a -> b
$ [Dynamic] -> [LocatedAn AnnListItem (HsBind GhcPs)]
forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds
            sigs' :: [LocatedAn AnnListItem (Sig GhcPs)]
sigs'  = [Dynamic] -> [LocatedAn AnnListItem (Sig GhcPs)]
forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds
          ClsInstDecl GhcPs -> EP w m (ClsInstDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (ClsInstDecl { cid_ext :: XCClsInstDecl GhcPs
cid_ext = (EpAnn [AddEpAnn]
an3, AnnSortKey
sortKey)
                              , cid_poly_ty :: LHsSigType GhcPs
cid_poly_ty = LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
inst_ty', cid_binds :: LHsBinds GhcPs
cid_binds = LHsBinds GhcPs
Bag (LocatedAn AnnListItem (HsBind GhcPs))
binds'
                              , cid_sigs :: [LSig GhcPs]
cid_sigs = [LSig GhcPs]
[LocatedAn AnnListItem (Sig GhcPs)]
sigs', cid_tyfam_insts :: [LTyFamInstDecl GhcPs]
cid_tyfam_insts = [LTyFamInstDecl GhcPs]
[LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
ats'
                              , cid_overlap_mode :: Maybe (XRec GhcPs OverlapMode)
cid_overlap_mode = Maybe (XRec GhcPs OverlapMode)
Maybe (GenLocated SrcSpanAnnP OverlapMode)
mbOverlap'
                              , cid_datafam_insts :: [LDataFamInstDecl GhcPs]
cid_datafam_insts = [LDataFamInstDecl GhcPs]
[GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)]
adts' })

      where
        top_matter :: RWST
  (EPOptions m w)
  (EPWriter w)
  EPState
  m
  (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnP OverlapMode),
   GenLocated SrcSpanAnnA (HsSigType GhcPs))
top_matter = do
          EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnInstance
          Maybe (GenLocated SrcSpanAnnP OverlapMode)
mo <- (GenLocated SrcSpanAnnP OverlapMode
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnP OverlapMode))
-> Maybe (GenLocated SrcSpanAnnP OverlapMode)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (GenLocated SrcSpanAnnP OverlapMode))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM GenLocated SrcSpanAnnP OverlapMode
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnP OverlapMode)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (XRec GhcPs OverlapMode)
Maybe (GenLocated SrcSpanAnnP OverlapMode)
mbOverlap
          GenLocated SrcSpanAnnA (HsSigType GhcPs)
it <- GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
inst_ty
          EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnWhere -- Optional
          (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnP OverlapMode),
 GenLocated SrcSpanAnnA (HsSigType GhcPs))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnP OverlapMode),
      GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, Maybe (GenLocated SrcSpanAnnP OverlapMode)
mo,GenLocated SrcSpanAnnA (HsSigType GhcPs)
it)

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

instance ExactPrint (TyFamInstDecl GhcPs) where
  getAnnotationEntry :: TyFamInstDecl GhcPs -> Entry
getAnnotationEntry (TyFamInstDecl XCTyFamInstDecl GhcPs
an TyFamInstEqn GhcPs
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCTyFamInstDecl GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: TyFamInstDecl GhcPs
-> Anchor -> EpAnnComments -> TyFamInstDecl GhcPs
setAnnotationAnchor (TyFamInstDecl XCTyFamInstDecl GhcPs
an TyFamInstEqn GhcPs
a) Anchor
anc EpAnnComments
cs = XCTyFamInstDecl GhcPs -> TyFamInstEqn GhcPs -> TyFamInstDecl GhcPs
forall pass.
XCTyFamInstDecl pass -> TyFamInstEqn pass -> TyFamInstDecl pass
TyFamInstDecl (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCTyFamInstDecl GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) TyFamInstEqn GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
TyFamInstDecl GhcPs -> EP w m (TyFamInstDecl GhcPs)
exact d :: TyFamInstDecl GhcPs
d@(TyFamInstDecl { tfid_xtn :: forall pass. TyFamInstDecl pass -> XCTyFamInstDecl pass
tfid_xtn = XCTyFamInstDecl GhcPs
an, tfid_eqn :: forall pass. TyFamInstDecl pass -> TyFamInstEqn pass
tfid_eqn = TyFamInstEqn GhcPs
eqn }) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCTyFamInstDecl GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnType
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnInstance
    FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
eqn' <- FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> EP w m (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated TyFamInstEqn GhcPs
FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
eqn
    TyFamInstDecl GhcPs -> EP w m (TyFamInstDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (TyFamInstDecl GhcPs
d { tfid_xtn = an1, tfid_eqn = eqn' })

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

instance ExactPrint (LocatedP OverlapMode) where
  getAnnotationEntry :: GenLocated SrcSpanAnnP OverlapMode -> Entry
getAnnotationEntry = GenLocated SrcSpanAnnP OverlapMode -> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: GenLocated SrcSpanAnnP OverlapMode
-> Anchor -> EpAnnComments -> GenLocated SrcSpanAnnP OverlapMode
setAnnotationAnchor = GenLocated SrcSpanAnnP OverlapMode
-> Anchor -> EpAnnComments -> GenLocated SrcSpanAnnP OverlapMode
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn

  -- NOTE: NoOverlap is only used in the typechecker
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated SrcSpanAnnP OverlapMode
-> EP w m (GenLocated SrcSpanAnnP OverlapMode)
exact (L (SrcSpanAnn EpAnn AnnPragma
an SrcSpan
l) (NoOverlap SourceText
src)) = do
    EpAnn AnnPragma
an0 <- EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
src String
"{-# NO_OVERLAP"
    EpAnn AnnPragma
an1 <- EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an0
    GenLocated SrcSpanAnnP OverlapMode
-> EP w m (GenLocated SrcSpanAnnP OverlapMode)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnP -> OverlapMode -> GenLocated SrcSpanAnnP OverlapMode
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnPragma -> SrcSpan -> SrcSpanAnnP
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnPragma
an1 SrcSpan
l) (SourceText -> OverlapMode
NoOverlap SourceText
src))

  exact (L (SrcSpanAnn EpAnn AnnPragma
an SrcSpan
l) (Overlappable SourceText
src)) = do
    EpAnn AnnPragma
an0 <- EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
src String
"{-# OVERLAPPABLE"
    EpAnn AnnPragma
an1 <- EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an0
    GenLocated SrcSpanAnnP OverlapMode
-> EP w m (GenLocated SrcSpanAnnP OverlapMode)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnP -> OverlapMode -> GenLocated SrcSpanAnnP OverlapMode
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnPragma -> SrcSpan -> SrcSpanAnnP
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnPragma
an1 SrcSpan
l) (SourceText -> OverlapMode
Overlappable SourceText
src))

  exact (L (SrcSpanAnn EpAnn AnnPragma
an SrcSpan
l) (Overlapping SourceText
src)) = do
    EpAnn AnnPragma
an0 <- EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
src String
"{-# OVERLAPPING"
    EpAnn AnnPragma
an1 <- EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an0
    GenLocated SrcSpanAnnP OverlapMode
-> EP w m (GenLocated SrcSpanAnnP OverlapMode)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnP -> OverlapMode -> GenLocated SrcSpanAnnP OverlapMode
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnPragma -> SrcSpan -> SrcSpanAnnP
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnPragma
an1 SrcSpan
l) (SourceText -> OverlapMode
Overlapping SourceText
src))

  exact (L (SrcSpanAnn EpAnn AnnPragma
an SrcSpan
l) (Overlaps SourceText
src)) = do
    EpAnn AnnPragma
an0 <- EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
src String
"{-# OVERLAPS"
    EpAnn AnnPragma
an1 <- EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an0
    GenLocated SrcSpanAnnP OverlapMode
-> EP w m (GenLocated SrcSpanAnnP OverlapMode)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnP -> OverlapMode -> GenLocated SrcSpanAnnP OverlapMode
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnPragma -> SrcSpan -> SrcSpanAnnP
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnPragma
an1 SrcSpan
l) (SourceText -> OverlapMode
Overlaps SourceText
src))

  exact (L (SrcSpanAnn EpAnn AnnPragma
an SrcSpan
l) (Incoherent SourceText
src)) = do
    EpAnn AnnPragma
an0 <- EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
src String
"{-# INCOHERENT"
    EpAnn AnnPragma
an1 <- EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an0
    GenLocated SrcSpanAnnP OverlapMode
-> EP w m (GenLocated SrcSpanAnnP OverlapMode)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnP -> OverlapMode -> GenLocated SrcSpanAnnP OverlapMode
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnPragma -> SrcSpan -> SrcSpanAnnP
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnPragma
an1 SrcSpan
l) (SourceText -> OverlapMode
Incoherent SourceText
src))

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

instance ExactPrint (HsBind GhcPs) where
  getAnnotationEntry :: HsBind GhcPs -> Entry
getAnnotationEntry FunBind{} = Entry
NoEntryVal
  getAnnotationEntry PatBind{pat_ext :: forall idL idR. HsBindLR idL idR -> XPatBind idL idR
pat_ext=XPatBind GhcPs GhcPs
an} = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XPatBind GhcPs GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry VarBind{} = Entry
NoEntryVal
  getAnnotationEntry PatSynBind{} = Entry
NoEntryVal

  setAnnotationAnchor :: HsBind GhcPs -> Anchor -> EpAnnComments -> HsBind GhcPs
setAnnotationAnchor pb :: HsBind GhcPs
pb@PatBind{} Anchor
anc EpAnnComments
cs = HsBind GhcPs
pb { pat_ext = setAnchorEpa (pat_ext pb) anc cs}
  setAnnotationAnchor HsBind GhcPs
a Anchor
_ EpAnnComments
_ = HsBind GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsBind GhcPs -> EP w m (HsBind GhcPs)
exact (FunBind XFunBind GhcPs GhcPs
x LIdP GhcPs
fid MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
matches) = do
    MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
matches' <- MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP
     w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
matches
    let
      fun_id' :: LIdP GhcPs
fun_id' = case GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> [GenLocated
      SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall l e. GenLocated l e -> e
unLoc (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> XRec
     GhcPs [LMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
forall p body. MatchGroup p body -> XRec p [LMatch p body]
mg_alts MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
matches') of
        [] -> LIdP GhcPs
fid
        (L SrcSpanAnnA
_ Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
m:[GenLocated
   SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
_) -> case Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> HsMatchContext GhcPs
forall p body. Match p body -> HsMatchContext p
m_ctxt Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
m of
          FunRhs LIdP (NoGhcTc GhcPs)
f LexicalFixity
_ SrcStrictness
_ -> LIdP (NoGhcTc GhcPs)
LIdP GhcPs
f
          HsMatchContext GhcPs
_ -> LIdP GhcPs
fid
    HsBind GhcPs -> EP w m (HsBind GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XFunBind GhcPs GhcPs
-> LIdP GhcPs
-> MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
-> HsBind GhcPs
forall idL idR.
XFunBind idL idR
-> LIdP idL -> MatchGroup idR (LHsExpr idR) -> HsBindLR idL idR
FunBind XFunBind GhcPs GhcPs
x LIdP GhcPs
fun_id' MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
matches')

  exact (PatBind XPatBind GhcPs GhcPs
x LPat GhcPs
pat GRHSs GhcPs (XRec GhcPs (HsExpr GhcPs))
grhss) = do
    GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
    GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
grhss' <- GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP w m (GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GRHSs GhcPs (XRec GhcPs (HsExpr GhcPs))
GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
grhss
    HsBind GhcPs -> EP w m (HsBind GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XPatBind GhcPs GhcPs
-> LPat GhcPs
-> GRHSs GhcPs (XRec GhcPs (HsExpr GhcPs))
-> HsBind GhcPs
forall idL idR.
XPatBind idL idR
-> LPat idL -> GRHSs idR (LHsExpr idR) -> HsBindLR idL idR
PatBind XPatBind GhcPs GhcPs
x LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat' GRHSs GhcPs (XRec GhcPs (HsExpr GhcPs))
GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
grhss')
  exact (PatSynBind XPatSynBind GhcPs GhcPs
x PatSynBind GhcPs GhcPs
bind) = do
    PatSynBind GhcPs GhcPs
bind' <- PatSynBind GhcPs GhcPs -> EP w m (PatSynBind GhcPs GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated PatSynBind GhcPs GhcPs
bind
    HsBind GhcPs -> EP w m (HsBind GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XPatSynBind GhcPs GhcPs -> PatSynBind GhcPs GhcPs -> HsBind GhcPs
forall idL idR.
XPatSynBind idL idR -> PatSynBind idL idR -> HsBindLR idL idR
PatSynBind XPatSynBind GhcPs GhcPs
x PatSynBind GhcPs GhcPs
bind')

  exact HsBind GhcPs
x = String -> EP w m (HsBind GhcPs)
forall a. HasCallStack => String -> a
error (String -> EP w m (HsBind GhcPs))
-> String -> EP w m (HsBind GhcPs)
forall a b. (a -> b) -> a -> b
$ String
"HsBind: exact for " String -> ShowS
forall a. [a] -> [a] -> [a]
++ HsBind GhcPs -> String
forall a. Data a => a -> String
showAst HsBind GhcPs
x

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

instance ExactPrint (PatSynBind GhcPs GhcPs) where
  getAnnotationEntry :: PatSynBind GhcPs GhcPs -> Entry
getAnnotationEntry (PSB { psb_ext :: forall idL idR. PatSynBind idL idR -> XPSB idL idR
psb_ext = XPSB GhcPs GhcPs
an}) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XPSB GhcPs GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: PatSynBind GhcPs GhcPs
-> Anchor -> EpAnnComments -> PatSynBind GhcPs GhcPs
setAnnotationAnchor PatSynBind GhcPs GhcPs
p Anchor
anc EpAnnComments
cs = PatSynBind GhcPs GhcPs
p { psb_ext = setAnchorEpa (psb_ext p) anc cs}

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
PatSynBind GhcPs GhcPs -> EP w m (PatSynBind GhcPs GhcPs)
exact (PSB{ psb_ext :: forall idL idR. PatSynBind idL idR -> XPSB idL idR
psb_ext = XPSB GhcPs GhcPs
an
            , psb_id :: forall idL idR. PatSynBind idL idR -> LIdP idL
psb_id = LIdP GhcPs
psyn, psb_args :: forall idL idR. PatSynBind idL idR -> HsPatSynDetails idR
psb_args = HsPatSynDetails GhcPs
details
            , psb_def :: forall idL idR. PatSynBind idL idR -> LPat idR
psb_def = LPat GhcPs
pat
            , psb_dir :: forall idL idR. PatSynBind idL idR -> HsPatSynDir idR
psb_dir = HsPatSynDir GhcPs
dir }) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XPSB GhcPs GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnPattern
    (EpAnn [AddEpAnn]
an1, GenLocated SrcSpanAnnN RdrName
psyn', HsConDetails
  Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs]
details') <-
      case HsPatSynDetails GhcPs
details of
        InfixCon LIdP GhcPs
v1 LIdP GhcPs
v2 -> do
          GenLocated SrcSpanAnnN RdrName
v1' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
v1
          GenLocated SrcSpanAnnN RdrName
psyn' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
psyn
          GenLocated SrcSpanAnnN RdrName
v2' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
v2
          (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
 HsConDetails
   Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsConDetails
        Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, GenLocated SrcSpanAnnN RdrName
psyn',GenLocated SrcSpanAnnN RdrName
-> GenLocated SrcSpanAnnN RdrName
-> HsConDetails
     Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs]
forall tyarg arg rec. arg -> arg -> HsConDetails tyarg arg rec
InfixCon GenLocated SrcSpanAnnN RdrName
v1' GenLocated SrcSpanAnnN RdrName
v2')
        PrefixCon [Void]
tvs [LIdP GhcPs]
vs -> do
          GenLocated SrcSpanAnnN RdrName
psyn' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
psyn
          [Void]
tvs' <- [Void] -> EP w m [Void]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [Void]
tvs
          [GenLocated SrcSpanAnnN RdrName]
vs' <- [GenLocated SrcSpanAnnN RdrName]
-> EP w m [GenLocated SrcSpanAnnN RdrName]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
vs
          (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
 HsConDetails
   Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsConDetails
        Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, GenLocated SrcSpanAnnN RdrName
psyn', [Void]
-> [GenLocated SrcSpanAnnN RdrName]
-> HsConDetails
     Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs]
forall tyarg arg rec.
[tyarg] -> [arg] -> HsConDetails tyarg arg rec
PrefixCon [Void]
tvs' [GenLocated SrcSpanAnnN RdrName]
vs')
        RecCon [RecordPatSynField GhcPs]
vs -> do
          GenLocated SrcSpanAnnN RdrName
psyn' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
psyn
          EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC  -- '{'
          [RecordPatSynField GhcPs]
vs' <- [RecordPatSynField GhcPs] -> EP w m [RecordPatSynField GhcPs]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [RecordPatSynField GhcPs]
vs
          EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC -- '}'
          (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
 HsConDetails
   Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsConDetails
        Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an2, GenLocated SrcSpanAnnN RdrName
psyn', [RecordPatSynField GhcPs]
-> HsConDetails
     Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs]
forall tyarg arg rec. rec -> HsConDetails tyarg arg rec
RecCon [RecordPatSynField GhcPs]
vs')

    (EpAnn [AddEpAnn]
an2, GenLocated SrcSpanAnnA (Pat GhcPs)
pat', HsPatSynDir GhcPs
dir') <-
      case HsPatSynDir GhcPs
dir of
        HsPatSynDir GhcPs
Unidirectional           -> do
          EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnLarrow
          GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
          (EpAnn [AddEpAnn], GenLocated SrcSpanAnnA (Pat GhcPs),
 HsPatSynDir GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnA (Pat GhcPs),
      HsPatSynDir GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an2, GenLocated SrcSpanAnnA (Pat GhcPs)
pat', HsPatSynDir GhcPs
dir)
        HsPatSynDir GhcPs
ImplicitBidirectional    -> do
          EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnEqual
          GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
          (EpAnn [AddEpAnn], GenLocated SrcSpanAnnA (Pat GhcPs),
 HsPatSynDir GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnA (Pat GhcPs),
      HsPatSynDir GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an2, GenLocated SrcSpanAnnA (Pat GhcPs)
pat', HsPatSynDir GhcPs
dir)
        ExplicitBidirectional MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
mg -> do
          EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnLarrow
          GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
          EpAnn [AddEpAnn]
an3 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an2 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl  AnnKeywordId
AnnWhere
          MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
mg' <- MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP
     w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
mg
          (EpAnn [AddEpAnn], GenLocated SrcSpanAnnA (Pat GhcPs),
 HsPatSynDir GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnA (Pat GhcPs),
      HsPatSynDir GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an3, GenLocated SrcSpanAnnA (Pat GhcPs)
pat', MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs)) -> HsPatSynDir GhcPs
forall id. MatchGroup id (LHsExpr id) -> HsPatSynDir id
ExplicitBidirectional MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
mg')

    PatSynBind GhcPs GhcPs -> EP w m (PatSynBind GhcPs GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (PSB{ psb_ext :: XPSB GhcPs GhcPs
psb_ext = XPSB GhcPs GhcPs
EpAnn [AddEpAnn]
an2
               , psb_id :: LIdP GhcPs
psb_id = LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
psyn', psb_args :: HsPatSynDetails GhcPs
psb_args = HsPatSynDetails GhcPs
HsConDetails
  Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs]
details'
               , psb_def :: LPat GhcPs
psb_def = LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat'
               , psb_dir :: HsPatSynDir GhcPs
psb_dir = HsPatSynDir GhcPs
dir' })


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

instance ExactPrint (RecordPatSynField GhcPs) where
  getAnnotationEntry :: RecordPatSynField GhcPs -> Entry
getAnnotationEntry = Entry -> RecordPatSynField GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: RecordPatSynField GhcPs
-> Anchor -> EpAnnComments -> RecordPatSynField GhcPs
setAnnotationAnchor RecordPatSynField GhcPs
a Anchor
_ EpAnnComments
_ = RecordPatSynField GhcPs
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RecordPatSynField GhcPs -> EP w m (RecordPatSynField GhcPs)
exact r :: RecordPatSynField GhcPs
r@(RecordPatSynField { recordPatSynField :: forall pass. RecordPatSynField pass -> FieldOcc pass
recordPatSynField = FieldOcc GhcPs
v }) = FieldOcc GhcPs -> EP w m (FieldOcc GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated FieldOcc GhcPs
v
        EP w m (FieldOcc GhcPs)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (RecordPatSynField GhcPs)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (RecordPatSynField GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> RecordPatSynField GhcPs
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (RecordPatSynField GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return RecordPatSynField GhcPs
r

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

instance ExactPrint (Match GhcPs (LocatedA (HsCmd GhcPs))) where
  getAnnotationEntry :: Match GhcPs (LocatedA (HsCmd GhcPs)) -> Entry
getAnnotationEntry (Match XCMatch GhcPs (LocatedA (HsCmd GhcPs))
ann HsMatchContext GhcPs
_ [LPat GhcPs]
_ GRHSs GhcPs (LocatedA (HsCmd GhcPs))
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCMatch GhcPs (LocatedA (HsCmd GhcPs))
EpAnn [AddEpAnn]
ann
  setAnnotationAnchor :: Match GhcPs (LocatedA (HsCmd GhcPs))
-> Anchor -> EpAnnComments -> Match GhcPs (LocatedA (HsCmd GhcPs))
setAnnotationAnchor (Match XCMatch GhcPs (LocatedA (HsCmd GhcPs))
an HsMatchContext GhcPs
a [LPat GhcPs]
b GRHSs GhcPs (LocatedA (HsCmd GhcPs))
c) Anchor
anc EpAnnComments
cs = XCMatch GhcPs (LocatedA (HsCmd GhcPs))
-> HsMatchContext GhcPs
-> [LPat GhcPs]
-> GRHSs GhcPs (LocatedA (HsCmd GhcPs))
-> Match GhcPs (LocatedA (HsCmd GhcPs))
forall p body.
XCMatch p body
-> HsMatchContext p -> [LPat p] -> GRHSs p body -> Match p body
Match (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCMatch GhcPs (LocatedA (HsCmd GhcPs))
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) HsMatchContext GhcPs
a [LPat GhcPs]
b GRHSs GhcPs (LocatedA (HsCmd GhcPs))
c

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Match GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (Match GhcPs (LocatedA (HsCmd GhcPs)))
exact (Match XCMatch GhcPs (LocatedA (HsCmd GhcPs))
an HsMatchContext GhcPs
mctxt [LPat GhcPs]
pats GRHSs GhcPs (LocatedA (HsCmd GhcPs))
grhss) =
    Match GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (Match GhcPs (LocatedA (HsCmd GhcPs)))
forall (m :: * -> *) w body.
(Monad m, Monoid w, ExactPrint (GRHSs GhcPs body)) =>
Match GhcPs body -> EP w m (Match GhcPs body)
exactMatch (XCMatch GhcPs (LocatedA (HsCmd GhcPs))
-> HsMatchContext GhcPs
-> [LPat GhcPs]
-> GRHSs GhcPs (LocatedA (HsCmd GhcPs))
-> Match GhcPs (LocatedA (HsCmd GhcPs))
forall p body.
XCMatch p body
-> HsMatchContext p -> [LPat p] -> GRHSs p body -> Match p body
Match XCMatch GhcPs (LocatedA (HsCmd GhcPs))
an HsMatchContext GhcPs
mctxt [LPat GhcPs]
pats GRHSs GhcPs (LocatedA (HsCmd GhcPs))
grhss)

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

instance ExactPrint (Match GhcPs (LocatedA (HsExpr GhcPs))) where
  getAnnotationEntry :: Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)) -> Entry
getAnnotationEntry (Match XCMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
ann HsMatchContext GhcPs
_ [LPat GhcPs]
_ GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn [AddEpAnn]
ann
  setAnnotationAnchor :: Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> Anchor
-> EpAnnComments
-> Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
setAnnotationAnchor (Match XCMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
an HsMatchContext GhcPs
a [LPat GhcPs]
b GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
c) Anchor
anc EpAnnComments
cs = XCMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> HsMatchContext GhcPs
-> [LPat GhcPs]
-> GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall p body.
XCMatch p body
-> HsMatchContext p -> [LPat p] -> GRHSs p body -> Match p body
Match (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) HsMatchContext GhcPs
a [LPat GhcPs]
b GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
c

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP w m (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
exact (Match XCMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
an HsMatchContext GhcPs
mctxt [LPat GhcPs]
pats GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
grhss) =
    Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP w m (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall (m :: * -> *) w body.
(Monad m, Monoid w, ExactPrint (GRHSs GhcPs body)) =>
Match GhcPs body -> EP w m (Match GhcPs body)
exactMatch (XCMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> HsMatchContext GhcPs
-> [LPat GhcPs]
-> GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall p body.
XCMatch p body
-> HsMatchContext p -> [LPat p] -> GRHSs p body -> Match p body
Match XCMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
an HsMatchContext GhcPs
mctxt [LPat GhcPs]
pats GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
grhss)

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

exactMatch :: (Monad m, Monoid w) => (ExactPrint (GRHSs GhcPs body)) => (Match GhcPs body) -> EP w m (Match GhcPs body)
exactMatch :: forall (m :: * -> *) w body.
(Monad m, Monoid w, ExactPrint (GRHSs GhcPs body)) =>
Match GhcPs body -> EP w m (Match GhcPs body)
exactMatch (Match XCMatch GhcPs body
an HsMatchContext GhcPs
mctxt [LPat GhcPs]
pats GRHSs GhcPs body
grhss) = do

  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"exact Match entered"

  (EpAnn [AddEpAnn]
an0, HsMatchContext GhcPs
mctxt', [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats') <-
    case HsMatchContext GhcPs
mctxt of
      FunRhs LIdP (NoGhcTc GhcPs)
fun LexicalFixity
fixity SrcStrictness
strictness -> do
        String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"exact Match FunRhs:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ GenLocated SrcSpanAnnN RdrName -> String
forall a. Outputable a => a -> String
showPprUnsafe LIdP (NoGhcTc GhcPs)
GenLocated SrcSpanAnnN RdrName
fun
        EpAnn [AddEpAnn]
an0' <-
          case SrcStrictness
strictness of
            SrcStrictness
SrcStrict -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCMatch GhcPs body
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnBang
            SrcStrictness
_ -> EpAnn [AddEpAnn]
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure XCMatch GhcPs body
EpAnn [AddEpAnn]
an
        case LexicalFixity
fixity of
          LexicalFixity
Prefix -> do
            EpAnn [AddEpAnn]
an' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> [AnnKeywordId]
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> [AnnKeywordId] -> EP w m (EpAnn a)
annotationsToComments EpAnn [AddEpAnn]
an0' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl [AnnKeywordId
AnnOpenP,AnnKeywordId
AnnCloseP]
            GenLocated SrcSpanAnnN RdrName
fun' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP (NoGhcTc GhcPs)
GenLocated SrcSpanAnnN RdrName
fun
            [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats' <- [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (Pat GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats
            (EpAnn [AddEpAnn], HsMatchContext GhcPs,
 [GenLocated SrcSpanAnnA (Pat GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], HsMatchContext GhcPs,
      [GenLocated SrcSpanAnnA (Pat GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an', LIdP (NoGhcTc GhcPs)
-> LexicalFixity -> SrcStrictness -> HsMatchContext GhcPs
forall p.
LIdP (NoGhcTc p)
-> LexicalFixity -> SrcStrictness -> HsMatchContext p
FunRhs LIdP (NoGhcTc GhcPs)
GenLocated SrcSpanAnnN RdrName
fun' LexicalFixity
fixity SrcStrictness
strictness, [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats')
          LexicalFixity
Infix ->
            case [LPat GhcPs]
pats of
              (LPat GhcPs
p1:LPat GhcPs
p2:[LPat GhcPs]
rest)
                | [GenLocated SrcSpanAnnA (Pat GhcPs)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
rest -> do
                    GenLocated SrcSpanAnnA (Pat GhcPs)
p1'  <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
p1
                    GenLocated SrcSpanAnnN RdrName
fun' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP (NoGhcTc GhcPs)
GenLocated SrcSpanAnnN RdrName
fun
                    GenLocated SrcSpanAnnA (Pat GhcPs)
p2'  <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
p2
                    (EpAnn [AddEpAnn], HsMatchContext GhcPs,
 [GenLocated SrcSpanAnnA (Pat GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], HsMatchContext GhcPs,
      [GenLocated SrcSpanAnnA (Pat GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0', LIdP (NoGhcTc GhcPs)
-> LexicalFixity -> SrcStrictness -> HsMatchContext GhcPs
forall p.
LIdP (NoGhcTc p)
-> LexicalFixity -> SrcStrictness -> HsMatchContext p
FunRhs LIdP (NoGhcTc GhcPs)
GenLocated SrcSpanAnnN RdrName
fun' LexicalFixity
fixity SrcStrictness
strictness, [GenLocated SrcSpanAnnA (Pat GhcPs)
p1',GenLocated SrcSpanAnnA (Pat GhcPs)
p2'])
                | Bool
otherwise -> do
                    EpAnn [AddEpAnn]
an0  <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenP
                    GenLocated SrcSpanAnnA (Pat GhcPs)
p1'  <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
p1
                    GenLocated SrcSpanAnnN RdrName
fun' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP (NoGhcTc GhcPs)
GenLocated SrcSpanAnnN RdrName
fun
                    GenLocated SrcSpanAnnA (Pat GhcPs)
p2'  <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
p2
                    EpAnn [AddEpAnn]
an1  <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseP
                    [GenLocated SrcSpanAnnA (Pat GhcPs)]
rest' <- (GenLocated SrcSpanAnnA (Pat GhcPs)
 -> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs)))
-> [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (Pat GhcPs)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
rest
                    (EpAnn [AddEpAnn], HsMatchContext GhcPs,
 [GenLocated SrcSpanAnnA (Pat GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], HsMatchContext GhcPs,
      [GenLocated SrcSpanAnnA (Pat GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, LIdP (NoGhcTc GhcPs)
-> LexicalFixity -> SrcStrictness -> HsMatchContext GhcPs
forall p.
LIdP (NoGhcTc p)
-> LexicalFixity -> SrcStrictness -> HsMatchContext p
FunRhs LIdP (NoGhcTc GhcPs)
GenLocated SrcSpanAnnN RdrName
fun' LexicalFixity
fixity SrcStrictness
strictness, GenLocated SrcSpanAnnA (Pat GhcPs)
p1'GenLocated SrcSpanAnnA (Pat GhcPs)
-> [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> [GenLocated SrcSpanAnnA (Pat GhcPs)]
forall a. a -> [a] -> [a]
:GenLocated SrcSpanAnnA (Pat GhcPs)
p2'GenLocated SrcSpanAnnA (Pat GhcPs)
-> [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> [GenLocated SrcSpanAnnA (Pat GhcPs)]
forall a. a -> [a] -> [a]
:[GenLocated SrcSpanAnnA (Pat GhcPs)]
rest')
              [LPat GhcPs]
_ -> String
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], HsMatchContext GhcPs,
      [GenLocated SrcSpanAnnA (Pat GhcPs)])
forall a. HasCallStack => String -> a
panic String
"FunRhs"
      HsMatchContext GhcPs
LambdaExpr -> do
        EpAnn [AddEpAnn]
an0' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCMatch GhcPs body
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnLam
        [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats' <- [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (Pat GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats
        (EpAnn [AddEpAnn], HsMatchContext GhcPs,
 [GenLocated SrcSpanAnnA (Pat GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], HsMatchContext GhcPs,
      [GenLocated SrcSpanAnnA (Pat GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0', HsMatchContext GhcPs
forall p. HsMatchContext p
LambdaExpr, [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats')
      HsMatchContext GhcPs
CaseAlt -> do
        [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats' <- [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (Pat GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats
        (EpAnn [AddEpAnn], HsMatchContext GhcPs,
 [GenLocated SrcSpanAnnA (Pat GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], HsMatchContext GhcPs,
      [GenLocated SrcSpanAnnA (Pat GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCMatch GhcPs body
EpAnn [AddEpAnn]
an, HsMatchContext GhcPs
forall p. HsMatchContext p
CaseAlt, [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats')
      LamCaseAlt LamCaseVariant
v -> do
        [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats' <- [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (Pat GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats
        (EpAnn [AddEpAnn], HsMatchContext GhcPs,
 [GenLocated SrcSpanAnnA (Pat GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], HsMatchContext GhcPs,
      [GenLocated SrcSpanAnnA (Pat GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCMatch GhcPs body
EpAnn [AddEpAnn]
an, LamCaseVariant -> HsMatchContext GhcPs
forall p. LamCaseVariant -> HsMatchContext p
LamCaseAlt LamCaseVariant
v, [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats')
      HsMatchContext GhcPs
_ -> do
        HsMatchContext GhcPs
mctxt' <- HsMatchContext GhcPs -> EP w m (HsMatchContext GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr HsMatchContext GhcPs
mctxt
        (EpAnn [AddEpAnn], HsMatchContext GhcPs,
 [GenLocated SrcSpanAnnA (Pat GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], HsMatchContext GhcPs,
      [GenLocated SrcSpanAnnA (Pat GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCMatch GhcPs body
EpAnn [AddEpAnn]
an, HsMatchContext GhcPs
mctxt', [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats)

  GRHSs GhcPs body
grhss' <- GRHSs GhcPs body -> EP w m (GRHSs GhcPs body)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GRHSs GhcPs body
grhss

  Match GhcPs body -> EP w m (Match GhcPs body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCMatch GhcPs body
-> HsMatchContext GhcPs
-> [LPat GhcPs]
-> GRHSs GhcPs body
-> Match GhcPs body
forall p body.
XCMatch p body
-> HsMatchContext p -> [LPat p] -> GRHSs p body -> Match p body
Match XCMatch GhcPs body
EpAnn [AddEpAnn]
an0 HsMatchContext GhcPs
mctxt' [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats' GRHSs GhcPs body
grhss')

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

instance ExactPrint (GRHSs GhcPs (LocatedA (HsExpr GhcPs))) where
  getAnnotationEntry :: GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)) -> Entry
getAnnotationEntry (GRHSs XCGRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
_ [LGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
_ HsLocalBinds GhcPs
_) = Entry
NoEntryVal
  setAnnotationAnchor :: GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> Anchor
-> EpAnnComments
-> GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
setAnnotationAnchor GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
a Anchor
_ EpAnnComments
_ = GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP w m (GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
exact (GRHSs XCGRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
cs [LGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
grhss HsLocalBinds GhcPs
binds) = do
    [LEpaComment] -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[LEpaComment] -> EP w m ()
addCommentsA ([LEpaComment] -> EP w m ()) -> [LEpaComment] -> EP w m ()
forall a b. (a -> b) -> a -> b
$ EpAnnComments -> [LEpaComment]
priorComments XCGRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnnComments
cs
    [LEpaComment] -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[LEpaComment] -> EP w m ()
addCommentsA ([LEpaComment] -> EP w m ()) -> [LEpaComment] -> EP w m ()
forall a b. (a -> b) -> a -> b
$ EpAnnComments -> [LEpaComment]
getFollowingComments XCGRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnnComments
cs
    [GenLocated
   (SrcAnn NoEpAnns)
   (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
grhss' <- [GenLocated
   (SrcAnn NoEpAnns)
   (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     [GenLocated
        (SrcAnn NoEpAnns)
        (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
[GenLocated
   (SrcAnn NoEpAnns)
   (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
grhss
    HsLocalBinds GhcPs
binds' <- HsLocalBinds GhcPs -> EP w m (HsLocalBinds GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsLocalBinds GhcPs
binds
    -- The comments will be added back as they are printed
    GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP w m (GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCGRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> [LGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
-> HsLocalBinds GhcPs
-> GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall p body.
XCGRHSs p body -> [LGRHS p body] -> HsLocalBinds p -> GRHSs p body
GRHSs XCGRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnnComments
emptyComments [LGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
[GenLocated
   (SrcAnn NoEpAnns)
   (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
grhss' HsLocalBinds GhcPs
binds')


instance ExactPrint (GRHSs GhcPs (LocatedA (HsCmd GhcPs))) where
  getAnnotationEntry :: GRHSs GhcPs (LocatedA (HsCmd GhcPs)) -> Entry
getAnnotationEntry (GRHSs XCGRHSs GhcPs (LocatedA (HsCmd GhcPs))
_ [LGRHS GhcPs (LocatedA (HsCmd GhcPs))]
_ HsLocalBinds GhcPs
_) = Entry
NoEntryVal
  setAnnotationAnchor :: GRHSs GhcPs (LocatedA (HsCmd GhcPs))
-> Anchor -> EpAnnComments -> GRHSs GhcPs (LocatedA (HsCmd GhcPs))
setAnnotationAnchor GRHSs GhcPs (LocatedA (HsCmd GhcPs))
a Anchor
_ EpAnnComments
_ = GRHSs GhcPs (LocatedA (HsCmd GhcPs))
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GRHSs GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (GRHSs GhcPs (LocatedA (HsCmd GhcPs)))
exact (GRHSs XCGRHSs GhcPs (LocatedA (HsCmd GhcPs))
cs [LGRHS GhcPs (LocatedA (HsCmd GhcPs))]
grhss HsLocalBinds GhcPs
binds) = do
    [LEpaComment] -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[LEpaComment] -> EP w m ()
addCommentsA ([LEpaComment] -> EP w m ()) -> [LEpaComment] -> EP w m ()
forall a b. (a -> b) -> a -> b
$ EpAnnComments -> [LEpaComment]
priorComments XCGRHSs GhcPs (LocatedA (HsCmd GhcPs))
EpAnnComments
cs
    [LEpaComment] -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[LEpaComment] -> EP w m ()
addCommentsA ([LEpaComment] -> EP w m ()) -> [LEpaComment] -> EP w m ()
forall a b. (a -> b) -> a -> b
$ EpAnnComments -> [LEpaComment]
getFollowingComments XCGRHSs GhcPs (LocatedA (HsCmd GhcPs))
EpAnnComments
cs
    [GenLocated
   (SrcAnn NoEpAnns) (GRHS GhcPs (LocatedA (HsCmd GhcPs)))]
grhss' <- [GenLocated
   (SrcAnn NoEpAnns) (GRHS GhcPs (LocatedA (HsCmd GhcPs)))]
-> EP
     w
     m
     [GenLocated
        (SrcAnn NoEpAnns) (GRHS GhcPs (LocatedA (HsCmd GhcPs)))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LGRHS GhcPs (LocatedA (HsCmd GhcPs))]
[GenLocated
   (SrcAnn NoEpAnns) (GRHS GhcPs (LocatedA (HsCmd GhcPs)))]
grhss
    HsLocalBinds GhcPs
binds' <- HsLocalBinds GhcPs -> EP w m (HsLocalBinds GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsLocalBinds GhcPs
binds
    -- The comments will be added back as they are printed
    GRHSs GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (GRHSs GhcPs (LocatedA (HsCmd GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCGRHSs GhcPs (LocatedA (HsCmd GhcPs))
-> [LGRHS GhcPs (LocatedA (HsCmd GhcPs))]
-> HsLocalBinds GhcPs
-> GRHSs GhcPs (LocatedA (HsCmd GhcPs))
forall p body.
XCGRHSs p body -> [LGRHS p body] -> HsLocalBinds p -> GRHSs p body
GRHSs XCGRHSs GhcPs (LocatedA (HsCmd GhcPs))
EpAnnComments
emptyComments [LGRHS GhcPs (LocatedA (HsCmd GhcPs))]
[GenLocated
   (SrcAnn NoEpAnns) (GRHS GhcPs (LocatedA (HsCmd GhcPs)))]
grhss' HsLocalBinds GhcPs
binds')

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

instance ExactPrint (HsLocalBinds GhcPs) where
  getAnnotationEntry :: HsLocalBinds GhcPs -> Entry
getAnnotationEntry (HsValBinds XHsValBinds GhcPs GhcPs
an HsValBindsLR GhcPs GhcPs
_) = EpAnn AnnList -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XHsValBinds GhcPs GhcPs
EpAnn AnnList
an
  getAnnotationEntry (HsIPBinds{}) = Entry
NoEntryVal
  getAnnotationEntry (EmptyLocalBinds{}) = Entry
NoEntryVal

  setAnnotationAnchor :: HsLocalBinds GhcPs -> Anchor -> EpAnnComments -> HsLocalBinds GhcPs
setAnnotationAnchor (HsValBinds XHsValBinds GhcPs GhcPs
an HsValBindsLR GhcPs GhcPs
a) Anchor
anc EpAnnComments
cs = XHsValBinds GhcPs GhcPs
-> HsValBindsLR GhcPs GhcPs -> HsLocalBinds GhcPs
forall idL idR.
XHsValBinds idL idR
-> HsValBindsLR idL idR -> HsLocalBindsLR idL idR
HsValBinds (EpAnn AnnList -> Anchor -> EpAnnComments -> EpAnn AnnList
setAnchorEpaL XHsValBinds GhcPs GhcPs
EpAnn AnnList
an Anchor
anc EpAnnComments
cs) HsValBindsLR GhcPs GhcPs
a
  setAnnotationAnchor HsLocalBinds GhcPs
a Anchor
_ EpAnnComments
_ = HsLocalBinds GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsLocalBinds GhcPs -> EP w m (HsLocalBinds GhcPs)
exact (HsValBinds XHsValBinds GhcPs GhcPs
an HsValBindsLR GhcPs GhcPs
valbinds) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"exact HsValBinds: an=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpAnn AnnList -> String
forall a. Data a => a -> String
showAst XHsValBinds GhcPs GhcPs
EpAnn AnnList
an
    EpAnn AnnList
an0 <- EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XHsValBinds GhcPs GhcPs
EpAnn AnnList
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
AnnWhere

    let manc :: Maybe Anchor
manc = case XHsValBinds GhcPs GhcPs
an of
                 XHsValBinds GhcPs GhcPs
EpAnn AnnList
EpAnnNotUsed -> Maybe Anchor
forall a. Maybe a
Nothing
                 XHsValBinds GhcPs GhcPs
_ -> AnnList -> Maybe Anchor
al_anchor (AnnList -> Maybe Anchor) -> AnnList -> Maybe Anchor
forall a b. (a -> b) -> a -> b
$ EpAnn AnnList -> AnnList
forall ann. EpAnn ann -> ann
anns XHsValBinds GhcPs GhcPs
EpAnn AnnList
an

    case Maybe Anchor
manc of
      Just Anchor
anc -> do
        Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ HsValBindsLR GhcPs GhcPs -> Bool
forall (a :: Pass) (b :: Pass).
HsValBindsLR (GhcPass a) (GhcPass b) -> Bool
isEmptyValBinds HsValBindsLR GhcPs GhcPs
valbinds) (RWST (EPOptions m w) (EPWriter w) EPState m ()
 -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ Maybe Anchor -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe Anchor -> EP w m ()
setExtraDP (Anchor -> Maybe Anchor
forall a. a -> Maybe a
Just Anchor
anc)
      Maybe Anchor
_ -> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

    (EpAnn AnnList
an1, HsValBindsLR GhcPs GhcPs
valbinds') <- Bool
-> EpAnn AnnList
-> EP w m (HsValBindsLR GhcPs GhcPs)
-> EP w m (EpAnn AnnList, HsValBindsLR GhcPs GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList Bool
False EpAnn AnnList
an0 (EP w m (HsValBindsLR GhcPs GhcPs)
 -> EP w m (EpAnn AnnList, HsValBindsLR GhcPs GhcPs))
-> EP w m (HsValBindsLR GhcPs GhcPs)
-> EP w m (EpAnn AnnList, HsValBindsLR GhcPs GhcPs)
forall a b. (a -> b) -> a -> b
$ HsValBindsLR GhcPs GhcPs -> EP w m (HsValBindsLR GhcPs GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotatedWithLayout HsValBindsLR GhcPs GhcPs
valbinds
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"exact HsValBinds: an1=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpAnn AnnList -> String
forall a. Data a => a -> String
showAst EpAnn AnnList
an1
    HsLocalBinds GhcPs -> EP w m (HsLocalBinds GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsValBinds GhcPs GhcPs
-> HsValBindsLR GhcPs GhcPs -> HsLocalBinds GhcPs
forall idL idR.
XHsValBinds idL idR
-> HsValBindsLR idL idR -> HsLocalBindsLR idL idR
HsValBinds XHsValBinds GhcPs GhcPs
EpAnn AnnList
an1 HsValBindsLR GhcPs GhcPs
valbinds')

  exact (HsIPBinds XHsIPBinds GhcPs GhcPs
an HsIPBinds GhcPs
bs) = do
    (EpAnn AnnList
as, HsLocalBinds GhcPs
ipb) <- Bool
-> EpAnn AnnList
-> EP w m (HsLocalBinds GhcPs)
-> EP w m (EpAnn AnnList, HsLocalBinds GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList Bool
True XHsIPBinds GhcPs GhcPs
EpAnn AnnList
an (EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XHsIPBinds GhcPs GhcPs
EpAnn AnnList
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
AnnWhere
                           EP w m (EpAnn AnnList)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsIPBinds GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsIPBinds GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HsIPBinds GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsIPBinds GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsIPBinds GhcPs
bs
                           RWST (EPOptions m w) (EPWriter w) EPState m (HsIPBinds GhcPs)
-> (HsIPBinds GhcPs -> EP w m (HsLocalBinds GhcPs))
-> EP w m (HsLocalBinds GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> (a -> RWST (EPOptions m w) (EPWriter w) EPState m b)
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \HsIPBinds GhcPs
bs' -> HsLocalBinds GhcPs -> EP w m (HsLocalBinds GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsIPBinds GhcPs GhcPs -> HsIPBinds GhcPs -> HsLocalBinds GhcPs
forall idL idR.
XHsIPBinds idL idR -> HsIPBinds idR -> HsLocalBindsLR idL idR
HsIPBinds XHsIPBinds GhcPs GhcPs
an HsIPBinds GhcPs
bs'::HsLocalBinds GhcPs))
    case HsLocalBinds GhcPs
ipb of
      HsIPBinds XHsIPBinds GhcPs GhcPs
_ HsIPBinds GhcPs
bs' -> HsLocalBinds GhcPs -> EP w m (HsLocalBinds GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsIPBinds GhcPs GhcPs -> HsIPBinds GhcPs -> HsLocalBinds GhcPs
forall idL idR.
XHsIPBinds idL idR -> HsIPBinds idR -> HsLocalBindsLR idL idR
HsIPBinds XHsIPBinds GhcPs GhcPs
EpAnn AnnList
as HsIPBinds GhcPs
bs'::HsLocalBinds GhcPs)
      HsLocalBinds GhcPs
_ -> String -> EP w m (HsLocalBinds GhcPs)
forall a. HasCallStack => String -> a
error String
"should not happen HsIPBinds"
  exact b :: HsLocalBinds GhcPs
b@(EmptyLocalBinds XEmptyLocalBinds GhcPs GhcPs
_) = HsLocalBinds GhcPs -> EP w m (HsLocalBinds GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsLocalBinds GhcPs
b


-- ---------------------------------------------------------------------
instance ExactPrint (HsValBindsLR GhcPs GhcPs) where
  getAnnotationEntry :: HsValBindsLR GhcPs GhcPs -> Entry
getAnnotationEntry HsValBindsLR GhcPs GhcPs
_ = Entry
NoEntryVal
  setAnnotationAnchor :: HsValBindsLR GhcPs GhcPs
-> Anchor -> EpAnnComments -> HsValBindsLR GhcPs GhcPs
setAnnotationAnchor HsValBindsLR GhcPs GhcPs
a Anchor
_ EpAnnComments
_ = HsValBindsLR GhcPs GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsValBindsLR GhcPs GhcPs -> EP w m (HsValBindsLR GhcPs GhcPs)
exact (ValBinds XValBinds GhcPs GhcPs
sortKey LHsBinds GhcPs
binds [LSig GhcPs]
sigs) = do
    [Dynamic]
ds <- EP w m [Dynamic] -> EP w m [Dynamic]
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutBoth (EP w m [Dynamic] -> EP w m [Dynamic])
-> EP w m [Dynamic] -> EP w m [Dynamic]
forall a b. (a -> b) -> a -> b
$ AnnSortKey -> [(RealSrcSpan, EP w m Dynamic)] -> EP w m [Dynamic]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnSortKey -> [(RealSrcSpan, EP w m Dynamic)] -> EP w m [Dynamic]
withSortKey XValBinds GhcPs GhcPs
AnnSortKey
sortKey
       ([LocatedAn AnnListItem (HsBind GhcPs)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
[LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationA (Bag (LocatedAn AnnListItem (HsBind GhcPs))
-> [LocatedAn AnnListItem (HsBind GhcPs)]
forall a. Bag a -> [a]
bagToList LHsBinds GhcPs
Bag (LocatedAn AnnListItem (HsBind GhcPs))
binds)
     [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall a. [a] -> [a] -> [a]
++ [LocatedAn AnnListItem (Sig GhcPs)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
[LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationA [LSig GhcPs]
[LocatedAn AnnListItem (Sig GhcPs)]
sigs
       )
    let
      binds' :: Bag (LocatedAn AnnListItem (HsBind GhcPs))
binds' = [LocatedAn AnnListItem (HsBind GhcPs)]
-> Bag (LocatedAn AnnListItem (HsBind GhcPs))
forall a. [a] -> Bag a
listToBag ([LocatedAn AnnListItem (HsBind GhcPs)]
 -> Bag (LocatedAn AnnListItem (HsBind GhcPs)))
-> [LocatedAn AnnListItem (HsBind GhcPs)]
-> Bag (LocatedAn AnnListItem (HsBind GhcPs))
forall a b. (a -> b) -> a -> b
$ [Dynamic] -> [LocatedAn AnnListItem (HsBind GhcPs)]
forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds
      sigs' :: [LocatedAn AnnListItem (Sig GhcPs)]
sigs'  = [Dynamic] -> [LocatedAn AnnListItem (Sig GhcPs)]
forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds
    HsValBindsLR GhcPs GhcPs -> EP w m (HsValBindsLR GhcPs GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (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
sortKey LHsBinds GhcPs
Bag (LocatedAn AnnListItem (HsBind GhcPs))
binds' [LSig GhcPs]
[LocatedAn AnnListItem (Sig GhcPs)]
sigs')
  exact (XValBindsLR XXValBindsLR GhcPs GhcPs
_) = String -> EP w m (HsValBindsLR GhcPs GhcPs)
forall a. HasCallStack => String -> a
panic String
"XValBindsLR"

undynamic :: Typeable a => [Dynamic] -> [a]
undynamic :: forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds = (Dynamic -> Maybe a) -> [Dynamic] -> [a]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe Dynamic -> Maybe a
forall a. Typeable a => Dynamic -> Maybe a
fromDynamic [Dynamic]
ds

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

instance ExactPrint (HsIPBinds GhcPs) where
  getAnnotationEntry :: HsIPBinds GhcPs -> Entry
getAnnotationEntry = Entry -> HsIPBinds GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: HsIPBinds GhcPs -> Anchor -> EpAnnComments -> HsIPBinds GhcPs
setAnnotationAnchor HsIPBinds GhcPs
a Anchor
_ EpAnnComments
_ = HsIPBinds GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsIPBinds GhcPs -> EP w m (HsIPBinds GhcPs)
exact b :: HsIPBinds GhcPs
b@(IPBinds XIPBinds GhcPs
_ [LIPBind GhcPs]
binds) = EP w m (HsIPBinds GhcPs) -> EP w m (HsIPBinds GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutBoth (EP w m (HsIPBinds GhcPs) -> EP w m (HsIPBinds GhcPs))
-> EP w m (HsIPBinds GhcPs) -> EP w m (HsIPBinds GhcPs)
forall a b. (a -> b) -> a -> b
$ [GenLocated SrcSpanAnnA (IPBind GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (IPBind GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LIPBind GhcPs]
[GenLocated SrcSpanAnnA (IPBind GhcPs)]
binds EP w m [GenLocated SrcSpanAnnA (IPBind GhcPs)]
-> EP w m (HsIPBinds GhcPs) -> EP w m (HsIPBinds GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HsIPBinds GhcPs -> EP w m (HsIPBinds GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsIPBinds GhcPs
b

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

instance ExactPrint (IPBind GhcPs) where
  getAnnotationEntry :: IPBind GhcPs -> Entry
getAnnotationEntry (IPBind XCIPBind GhcPs
an XRec GhcPs HsIPName
_ XRec GhcPs (HsExpr GhcPs)
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCIPBind GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: IPBind GhcPs -> Anchor -> EpAnnComments -> IPBind GhcPs
setAnnotationAnchor (IPBind XCIPBind GhcPs
an XRec GhcPs HsIPName
a XRec GhcPs (HsExpr GhcPs)
b) Anchor
anc EpAnnComments
cs = XCIPBind GhcPs
-> XRec GhcPs HsIPName -> XRec GhcPs (HsExpr GhcPs) -> IPBind GhcPs
forall id.
XCIPBind id -> XRec id HsIPName -> LHsExpr id -> IPBind id
IPBind (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCIPBind GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs HsIPName
a XRec GhcPs (HsExpr GhcPs)
b

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
IPBind GhcPs -> EP w m (IPBind GhcPs)
exact (IPBind XCIPBind GhcPs
an XRec GhcPs HsIPName
lr XRec GhcPs (HsExpr GhcPs)
rhs) = do
    GenLocated (SrcAnn NoEpAnns) HsIPName
lr' <- GenLocated (SrcAnn NoEpAnns) HsIPName
-> EP w m (GenLocated (SrcAnn NoEpAnns) HsIPName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs HsIPName
GenLocated (SrcAnn NoEpAnns) HsIPName
lr
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCIPBind GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnEqual
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
rhs' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
rhs
    IPBind GhcPs -> EP w m (IPBind GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCIPBind GhcPs
-> XRec GhcPs HsIPName -> XRec GhcPs (HsExpr GhcPs) -> IPBind GhcPs
forall id.
XCIPBind id -> XRec id HsIPName -> LHsExpr id -> IPBind id
IPBind XCIPBind GhcPs
EpAnn [AddEpAnn]
an0 XRec GhcPs HsIPName
GenLocated (SrcAnn NoEpAnns) HsIPName
lr' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
rhs')


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

instance ExactPrint HsIPName where
  getAnnotationEntry :: HsIPName -> Entry
getAnnotationEntry = Entry -> HsIPName -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: HsIPName -> Anchor -> EpAnnComments -> HsIPName
setAnnotationAnchor HsIPName
a Anchor
_ EpAnnComments
_ = HsIPName
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsIPName -> EP w m HsIPName
exact i :: HsIPName
i@(HsIPName FastString
fs) = String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance (String
"?" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (FastString -> String
unpackFS FastString
fs)) EP w m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m HsIPName
-> RWST (EPOptions m w) (EPWriter w) EPState m HsIPName
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HsIPName -> RWST (EPOptions m w) (EPWriter w) EPState m HsIPName
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsIPName
i

-- ---------------------------------------------------------------------
-- Managing lists which have been separated, e.g. Sigs and Binds

prepareListAnnotationF :: (Monad m, Monoid w) =>
  EpAnn [AddEpAnn] -> [LDataFamInstDecl GhcPs] -> [(RealSrcSpan,EP w m Dynamic)]
prepareListAnnotationF :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> [LDataFamInstDecl GhcPs] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationF EpAnn [AddEpAnn]
an [LDataFamInstDecl GhcPs]
ls = (GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)
 -> (RealSrcSpan, EP w m Dynamic))
-> [GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall a b. (a -> b) -> [a] -> [b]
map (\GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)
b -> (SrcSpan -> RealSrcSpan
realSrcSpan (SrcSpan -> RealSrcSpan) -> SrcSpan -> RealSrcSpan
forall a b. (a -> b) -> a -> b
$ GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs) -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)
b, GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs) -> EP w m Dynamic
go GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)
b)) [LDataFamInstDecl GhcPs]
[GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)]
ls
  where
    go :: GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs) -> EP w m Dynamic
go (L SrcSpanAnnA
l DataFamInstDecl GhcPs
a) = do
      DataFamInstDeclWithContext
d' <- DataFamInstDeclWithContext -> EP w m DataFamInstDeclWithContext
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated (EpAnn [AddEpAnn]
-> TopLevelFlag
-> DataFamInstDecl GhcPs
-> DataFamInstDeclWithContext
DataFamInstDeclWithContext EpAnn [AddEpAnn]
an TopLevelFlag
NotTopLevel DataFamInstDecl GhcPs
a)
      Dynamic -> EP w m Dynamic
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs) -> Dynamic
forall a. Typeable a => a -> Dynamic
toDyn (SrcSpanAnnA
-> DataFamInstDecl GhcPs
-> GenLocated SrcSpanAnnA (DataFamInstDecl GhcPs)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnA
l (DataFamInstDeclWithContext -> DataFamInstDecl GhcPs
dc_d DataFamInstDeclWithContext
d')))

prepareListAnnotationA :: (Monad m, Monoid w, ExactPrint (LocatedAn an a))
  => [LocatedAn an a] -> [(RealSrcSpan,EP w m Dynamic)]
prepareListAnnotationA :: forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
[LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationA [LocatedAn an a]
ls = (LocatedAn an a -> (RealSrcSpan, EP w m Dynamic))
-> [LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
forall a b. (a -> b) -> [a] -> [b]
map (\LocatedAn an a
b -> (SrcSpan -> RealSrcSpan
realSrcSpan (SrcSpan -> RealSrcSpan) -> SrcSpan -> RealSrcSpan
forall a b. (a -> b) -> a -> b
$ LocatedAn an a -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA LocatedAn an a
b,LocatedAn an a -> EP w m Dynamic
forall {w} {m :: * -> *} {a}.
(Monoid w, Monad m, ExactPrint a) =>
a -> RWST (EPOptions m w) (EPWriter w) EPState m Dynamic
go LocatedAn an a
b)) [LocatedAn an a]
ls
  where
    go :: a -> RWST (EPOptions m w) (EPWriter w) EPState m Dynamic
go a
b = do
      a
b' <- a -> EP w m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated a
b
      Dynamic -> RWST (EPOptions m w) (EPWriter w) EPState m Dynamic
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Dynamic
forall a. Typeable a => a -> Dynamic
toDyn a
b')

withSortKey :: (Monad m, Monoid w) => AnnSortKey -> [(RealSrcSpan, EP w m Dynamic)] -> EP w m [Dynamic]
withSortKey :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnSortKey -> [(RealSrcSpan, EP w m Dynamic)] -> EP w m [Dynamic]
withSortKey AnnSortKey
annSortKey [(RealSrcSpan, EP w m Dynamic)]
xs = do
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"withSortKey:annSortKey=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ AnnSortKey -> String
forall a. Data a => a -> String
showAst AnnSortKey
annSortKey
  let ordered :: [(RealSrcSpan, EP w m Dynamic)]
ordered = case AnnSortKey
annSortKey of
                  AnnSortKey
NoAnnSortKey -> ((RealSrcSpan, EP w m Dynamic)
 -> (RealSrcSpan, EP w m Dynamic) -> Ordering)
-> [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (RealSrcSpan, EP w m Dynamic)
-> (RealSrcSpan, EP w m Dynamic) -> Ordering
forall a b1 b2. Ord a => (a, b1) -> (a, b2) -> Ordering
orderByFst [(RealSrcSpan, EP w m Dynamic)]
xs
                  -- Just keys -> error $ "withSortKey: keys" ++ show keys
                  AnnSortKey [RealSrcSpan]
keys -> [(RealSrcSpan, EP w m Dynamic)]
-> [RealSrcSpan] -> [(RealSrcSpan, EP w m Dynamic)]
forall a. [(RealSrcSpan, a)] -> [RealSrcSpan] -> [(RealSrcSpan, a)]
orderByKey [(RealSrcSpan, EP w m Dynamic)]
xs [RealSrcSpan]
keys
                                -- `debug` ("withSortKey:" ++
                                --          showPprUnsafe (map fst (sortBy (comparing (flip elemIndex keys . fst)) xs),
                                --                  map fst xs,
                                --                  keys)
                                --          )
  ((RealSrcSpan, EP w m Dynamic) -> EP w m Dynamic)
-> [(RealSrcSpan, EP w m Dynamic)] -> EP w m [Dynamic]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (RealSrcSpan, EP w m Dynamic) -> EP w m Dynamic
forall a b. (a, b) -> b
snd [(RealSrcSpan, EP w m Dynamic)]
ordered

orderByFst :: Ord a => (a, b1) -> (a, b2) -> Ordering
orderByFst :: forall a b1 b2. Ord a => (a, b1) -> (a, b2) -> Ordering
orderByFst (a
a,b1
_) (a
b,b2
_) = a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare a
a a
b

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

instance ExactPrint (Sig GhcPs) where
  getAnnotationEntry :: Sig GhcPs -> Entry
getAnnotationEntry (TypeSig XTypeSig GhcPs
a [LIdP GhcPs]
_ LHsSigWcType GhcPs
_)  = EpAnn AnnSig -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XTypeSig GhcPs
EpAnn AnnSig
a
  getAnnotationEntry (PatSynSig XPatSynSig GhcPs
a [LIdP GhcPs]
_ LHsSigType GhcPs
_) = EpAnn AnnSig -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XPatSynSig GhcPs
EpAnn AnnSig
a
  getAnnotationEntry (ClassOpSig XClassOpSig GhcPs
a Bool
_ [LIdP GhcPs]
_ LHsSigType GhcPs
_) = EpAnn AnnSig -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XClassOpSig GhcPs
EpAnn AnnSig
a
  getAnnotationEntry (FixSig XFixSig GhcPs
a FixitySig GhcPs
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XFixSig GhcPs
EpAnn [AddEpAnn]
a
  getAnnotationEntry (InlineSig XInlineSig GhcPs
a LIdP GhcPs
_ InlinePragma
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XInlineSig GhcPs
EpAnn [AddEpAnn]
a
  getAnnotationEntry (SpecSig XSpecSig GhcPs
a LIdP GhcPs
_ [LHsSigType GhcPs]
_ InlinePragma
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XSpecSig GhcPs
EpAnn [AddEpAnn]
a
  getAnnotationEntry (SpecInstSig (EpAnn [AddEpAnn]
a, SourceText
_) LHsSigType GhcPs
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn [AddEpAnn]
a
  getAnnotationEntry (MinimalSig (EpAnn [AddEpAnn]
a, SourceText
_) LBooleanFormula (LIdP GhcPs)
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn [AddEpAnn]
a
  getAnnotationEntry (SCCFunSig (EpAnn [AddEpAnn]
a, SourceText
_) LIdP GhcPs
_ Maybe (XRec GhcPs StringLiteral)
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn [AddEpAnn]
a
  getAnnotationEntry (CompleteMatchSig (EpAnn [AddEpAnn]
a, SourceText
_) XRec GhcPs [LIdP GhcPs]
_ Maybe (LIdP GhcPs)
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn [AddEpAnn]
a

  setAnnotationAnchor :: Sig GhcPs -> Anchor -> EpAnnComments -> Sig GhcPs
setAnnotationAnchor (TypeSig XTypeSig GhcPs
a [LIdP GhcPs]
x LHsSigWcType GhcPs
y)  Anchor
anc           EpAnnComments
cs = (XTypeSig GhcPs -> [LIdP GhcPs] -> LHsSigWcType GhcPs -> Sig GhcPs
forall pass.
XTypeSig pass -> [LIdP pass] -> LHsSigWcType pass -> Sig pass
TypeSig (EpAnn AnnSig -> Anchor -> EpAnnComments -> EpAnn AnnSig
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XTypeSig GhcPs
EpAnn AnnSig
a Anchor
anc EpAnnComments
cs) [LIdP GhcPs]
x LHsSigWcType GhcPs
y)
  setAnnotationAnchor (PatSynSig XPatSynSig GhcPs
a [LIdP GhcPs]
x LHsSigType GhcPs
y) Anchor
anc          EpAnnComments
cs = (XPatSynSig GhcPs -> [LIdP GhcPs] -> LHsSigType GhcPs -> Sig GhcPs
forall pass.
XPatSynSig pass -> [LIdP pass] -> LHsSigType pass -> Sig pass
PatSynSig (EpAnn AnnSig -> Anchor -> EpAnnComments -> EpAnn AnnSig
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XPatSynSig GhcPs
EpAnn AnnSig
a Anchor
anc EpAnnComments
cs) [LIdP GhcPs]
x LHsSigType GhcPs
y)
  setAnnotationAnchor (ClassOpSig XClassOpSig GhcPs
a Bool
x [LIdP GhcPs]
y LHsSigType GhcPs
z) Anchor
anc       EpAnnComments
cs = (XClassOpSig GhcPs
-> Bool -> [LIdP GhcPs] -> LHsSigType GhcPs -> Sig GhcPs
forall pass.
XClassOpSig pass
-> Bool -> [LIdP pass] -> LHsSigType pass -> Sig pass
ClassOpSig (EpAnn AnnSig -> Anchor -> EpAnnComments -> EpAnn AnnSig
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XClassOpSig GhcPs
EpAnn AnnSig
a Anchor
anc EpAnnComments
cs) Bool
x [LIdP GhcPs]
y LHsSigType GhcPs
z)
  setAnnotationAnchor (FixSig XFixSig GhcPs
a FixitySig GhcPs
x) Anchor
anc               EpAnnComments
cs = (XFixSig GhcPs -> FixitySig GhcPs -> Sig GhcPs
forall pass. XFixSig pass -> FixitySig pass -> Sig pass
FixSig (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XFixSig GhcPs
EpAnn [AddEpAnn]
a Anchor
anc EpAnnComments
cs) FixitySig GhcPs
x)
  setAnnotationAnchor (InlineSig XInlineSig GhcPs
a LIdP GhcPs
x InlinePragma
y) Anchor
anc          EpAnnComments
cs = (XInlineSig GhcPs -> LIdP GhcPs -> InlinePragma -> Sig GhcPs
forall pass.
XInlineSig pass -> LIdP pass -> InlinePragma -> Sig pass
InlineSig (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XInlineSig GhcPs
EpAnn [AddEpAnn]
a Anchor
anc EpAnnComments
cs) LIdP GhcPs
x InlinePragma
y)
  setAnnotationAnchor (SpecSig XSpecSig GhcPs
a LIdP GhcPs
x [LHsSigType GhcPs]
y InlinePragma
z) Anchor
anc          EpAnnComments
cs = (XSpecSig GhcPs
-> LIdP GhcPs -> [LHsSigType GhcPs] -> InlinePragma -> Sig GhcPs
forall pass.
XSpecSig pass
-> LIdP pass -> [LHsSigType pass] -> InlinePragma -> Sig pass
SpecSig (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XSpecSig GhcPs
EpAnn [AddEpAnn]
a Anchor
anc EpAnnComments
cs) LIdP GhcPs
x [LHsSigType GhcPs]
y InlinePragma
z)
  setAnnotationAnchor (SpecInstSig (EpAnn [AddEpAnn]
a,SourceText
x) LHsSigType GhcPs
y) Anchor
anc      EpAnnComments
cs = (XSpecInstSig GhcPs -> LHsSigType GhcPs -> Sig GhcPs
forall pass. XSpecInstSig pass -> LHsSigType pass -> Sig pass
SpecInstSig ((EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa EpAnn [AddEpAnn]
a Anchor
anc EpAnnComments
cs),SourceText
x) LHsSigType GhcPs
y)
  setAnnotationAnchor (MinimalSig (EpAnn [AddEpAnn]
a,SourceText
x) LBooleanFormula (LIdP GhcPs)
y) Anchor
anc       EpAnnComments
cs = (XMinimalSig GhcPs -> LBooleanFormula (LIdP GhcPs) -> Sig GhcPs
forall pass.
XMinimalSig pass -> LBooleanFormula (LIdP pass) -> Sig pass
MinimalSig ((EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa EpAnn [AddEpAnn]
a Anchor
anc EpAnnComments
cs),SourceText
x) LBooleanFormula (LIdP GhcPs)
y)
  setAnnotationAnchor (SCCFunSig (EpAnn [AddEpAnn]
a,SourceText
x) LIdP GhcPs
y Maybe (XRec GhcPs StringLiteral)
z) Anchor
anc      EpAnnComments
cs = (XSCCFunSig GhcPs
-> LIdP GhcPs -> Maybe (XRec GhcPs StringLiteral) -> Sig GhcPs
forall pass.
XSCCFunSig pass
-> LIdP pass -> Maybe (XRec pass StringLiteral) -> Sig pass
SCCFunSig ((EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa EpAnn [AddEpAnn]
a Anchor
anc EpAnnComments
cs),SourceText
x) LIdP GhcPs
y Maybe (XRec GhcPs StringLiteral)
z)
  setAnnotationAnchor (CompleteMatchSig (EpAnn [AddEpAnn]
a,SourceText
x) XRec GhcPs [LIdP GhcPs]
y Maybe (LIdP GhcPs)
z) Anchor
anc EpAnnComments
cs = (XCompleteMatchSig GhcPs
-> XRec GhcPs [LIdP GhcPs] -> Maybe (LIdP GhcPs) -> Sig GhcPs
forall pass.
XCompleteMatchSig pass
-> XRec pass [LIdP pass] -> Maybe (LIdP pass) -> Sig pass
CompleteMatchSig ((EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa EpAnn [AddEpAnn]
a Anchor
anc EpAnnComments
cs),SourceText
x) XRec GhcPs [LIdP GhcPs]
y Maybe (LIdP GhcPs)
z)

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Sig GhcPs -> EP w m (Sig GhcPs)
exact (TypeSig XTypeSig GhcPs
an [LIdP GhcPs]
vars LHsSigWcType GhcPs
ty)  = do
    (EpAnn AnnSig
an', [GenLocated SrcSpanAnnN RdrName]
vars', HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
ty') <- EpAnn AnnSig
-> [GenLocated SrcSpanAnnN RdrName]
-> HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
-> EP
     w
     m
     (EpAnn AnnSig, [GenLocated SrcSpanAnnN RdrName],
      HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
EpAnn AnnSig
-> [GenLocated SrcSpanAnnN RdrName]
-> a
-> EP w m (EpAnn AnnSig, [GenLocated SrcSpanAnnN RdrName], a)
exactVarSig XTypeSig GhcPs
EpAnn AnnSig
an [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
vars LHsSigWcType GhcPs
HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
ty
    Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XTypeSig GhcPs -> [LIdP GhcPs] -> LHsSigWcType GhcPs -> Sig GhcPs
forall pass.
XTypeSig pass -> [LIdP pass] -> LHsSigWcType pass -> Sig pass
TypeSig XTypeSig GhcPs
EpAnn AnnSig
an' [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
vars' LHsSigWcType GhcPs
HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
ty')

  exact (PatSynSig XPatSynSig GhcPs
an [LIdP GhcPs]
lns LHsSigType GhcPs
typ) = do
    EpAnn AnnSig
an0 <- EpAnn AnnSig
-> Lens AnnSig [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn AnnSig)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XPatSynSig GhcPs
EpAnn AnnSig
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnSig -> f AnnSig
Lens AnnSig [AddEpAnn]
lasRest AnnKeywordId
AnnPattern
    [GenLocated SrcSpanAnnN RdrName]
lns' <- [GenLocated SrcSpanAnnN RdrName]
-> EP w m [GenLocated SrcSpanAnnN RdrName]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
lns
    EpAnn AnnSig
an1 <- EpAnn AnnSig -> Lens AnnSig AddEpAnn -> EP w m (EpAnn AnnSig)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA EpAnn AnnSig
an0 (AddEpAnn -> f AddEpAnn) -> AnnSig -> f AnnSig
Lens AnnSig AddEpAnn
lasDcolon
    GenLocated SrcSpanAnnA (HsSigType GhcPs)
typ' <- GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
typ
    Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XPatSynSig GhcPs -> [LIdP GhcPs] -> LHsSigType GhcPs -> Sig GhcPs
forall pass.
XPatSynSig pass -> [LIdP pass] -> LHsSigType pass -> Sig pass
PatSynSig XPatSynSig GhcPs
EpAnn AnnSig
an1 [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
lns' LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
typ')

  exact (ClassOpSig XClassOpSig GhcPs
an Bool
is_deflt [LIdP GhcPs]
vars LHsSigType GhcPs
ty)
    | Bool
is_deflt  = do
        EpAnn AnnSig
an0 <- EpAnn AnnSig
-> Lens AnnSig [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn AnnSig)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XClassOpSig GhcPs
EpAnn AnnSig
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnSig -> f AnnSig
Lens AnnSig [AddEpAnn]
lasRest AnnKeywordId
AnnDefault
        (EpAnn AnnSig
an1, [GenLocated SrcSpanAnnN RdrName]
vars',GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty') <- EpAnn AnnSig
-> [GenLocated SrcSpanAnnN RdrName]
-> GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> EP
     w
     m
     (EpAnn AnnSig, [GenLocated SrcSpanAnnN RdrName],
      GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
EpAnn AnnSig
-> [GenLocated SrcSpanAnnN RdrName]
-> a
-> EP w m (EpAnn AnnSig, [GenLocated SrcSpanAnnN RdrName], a)
exactVarSig EpAnn AnnSig
an0 [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
vars LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty
        Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XClassOpSig GhcPs
-> Bool -> [LIdP GhcPs] -> LHsSigType GhcPs -> Sig GhcPs
forall pass.
XClassOpSig pass
-> Bool -> [LIdP pass] -> LHsSigType pass -> Sig pass
ClassOpSig XClassOpSig GhcPs
EpAnn AnnSig
an1 Bool
is_deflt [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
vars' LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty')
    | Bool
otherwise = do
        (EpAnn AnnSig
an0, [GenLocated SrcSpanAnnN RdrName]
vars',GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty') <- EpAnn AnnSig
-> [GenLocated SrcSpanAnnN RdrName]
-> GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> EP
     w
     m
     (EpAnn AnnSig, [GenLocated SrcSpanAnnN RdrName],
      GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
EpAnn AnnSig
-> [GenLocated SrcSpanAnnN RdrName]
-> a
-> EP w m (EpAnn AnnSig, [GenLocated SrcSpanAnnN RdrName], a)
exactVarSig XClassOpSig GhcPs
EpAnn AnnSig
an [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
vars LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty
        Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XClassOpSig GhcPs
-> Bool -> [LIdP GhcPs] -> LHsSigType GhcPs -> Sig GhcPs
forall pass.
XClassOpSig pass
-> Bool -> [LIdP pass] -> LHsSigType pass -> Sig pass
ClassOpSig XClassOpSig GhcPs
EpAnn AnnSig
an0 Bool
is_deflt [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
vars' LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty')

  exact (FixSig XFixSig GhcPs
an (FixitySig XFixitySig GhcPs
x [LIdP GhcPs]
names (Fixity SourceText
src Int
v FixityDirection
fdir))) = do
    let fixstr :: String
fixstr = case FixityDirection
fdir of
         FixityDirection
InfixL -> String
"infixl"
         FixityDirection
InfixR -> String
"infixr"
         FixityDirection
InfixN -> String
"infix"
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS XFixSig GhcPs
EpAnn [AddEpAnn]
an  ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnInfix (String -> Maybe String
forall a. a -> Maybe a
Just String
fixstr)
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnVal (String -> Maybe String
forall a. a -> Maybe a
Just (SourceText -> ShowS
sourceTextToString SourceText
src (Int -> String
forall a. Show a => a -> String
show Int
v)))
    [GenLocated SrcSpanAnnN RdrName]
names' <- [GenLocated SrcSpanAnnN RdrName]
-> EP w m [GenLocated SrcSpanAnnN RdrName]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
names
    Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XFixSig GhcPs -> FixitySig GhcPs -> Sig GhcPs
forall pass. XFixSig pass -> FixitySig pass -> Sig pass
FixSig XFixSig GhcPs
EpAnn [AddEpAnn]
an1 (XFixitySig GhcPs -> [LIdP GhcPs] -> Fixity -> FixitySig GhcPs
forall pass.
XFixitySig pass -> [LIdP pass] -> Fixity -> FixitySig pass
FixitySig XFixitySig GhcPs
x [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
names' (SourceText -> Int -> FixityDirection -> Fixity
Fixity SourceText
src Int
v FixityDirection
fdir)))

  exact (InlineSig XInlineSig GhcPs
an LIdP GhcPs
ln InlinePragma
inl) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
markAnnOpen XInlineSig GhcPs
EpAnn [AddEpAnn]
an (InlinePragma -> SourceText
inl_src InlinePragma
inl) String
"{-# INLINE"
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> Activation
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> Activation -> EP w m (EpAnn a)
markActivation EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a. a -> a
Lens [AddEpAnn] [AddEpAnn]
id (InlinePragma -> Activation
inl_act InlinePragma
inl)
    GenLocated SrcSpanAnnN RdrName
ln' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ln
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"InlineSig:an=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpAnn [AddEpAnn] -> String
forall a. Data a => a -> String
showAst XInlineSig GhcPs
EpAnn [AddEpAnn]
an
    Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"InlineSig: p=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Pos -> String
forall a. Show a => a -> String
show Pos
p
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"#-}")
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"InlineSig:done"
    Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XInlineSig GhcPs -> LIdP GhcPs -> InlinePragma -> Sig GhcPs
forall pass.
XInlineSig pass -> LIdP pass -> InlinePragma -> Sig pass
InlineSig XInlineSig GhcPs
EpAnn [AddEpAnn]
an2 LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ln' InlinePragma
inl)

  exact (SpecSig XSpecSig GhcPs
an LIdP GhcPs
ln [LHsSigType GhcPs]
typs InlinePragma
inl) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
markAnnOpen XSpecSig GhcPs
EpAnn [AddEpAnn]
an (InlinePragma -> SourceText
inl_src InlinePragma
inl) String
"{-# SPECIALISE" -- Note: may be {-# SPECIALISE_INLINE
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> Activation
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> Activation -> EP w m (EpAnn a)
markActivation EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl (InlinePragma -> Activation
inl_act InlinePragma
inl)
    GenLocated SrcSpanAnnN RdrName
ln' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ln
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
    [GenLocated SrcSpanAnnA (HsSigType GhcPs)]
typs' <- [GenLocated SrcSpanAnnA (HsSigType GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsSigType GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsSigType GhcPs]
[GenLocated SrcSpanAnnA (HsSigType GhcPs)]
typs
    EpAnn [AddEpAnn]
an3 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an2 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"#-}")
    Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSpecSig GhcPs
-> LIdP GhcPs -> [LHsSigType GhcPs] -> InlinePragma -> Sig GhcPs
forall pass.
XSpecSig pass
-> LIdP pass -> [LHsSigType pass] -> InlinePragma -> Sig pass
SpecSig XSpecSig GhcPs
EpAnn [AddEpAnn]
an3 LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ln' [LHsSigType GhcPs]
[GenLocated SrcSpanAnnA (HsSigType GhcPs)]
typs' InlinePragma
inl)

  exact (SpecInstSig (EpAnn [AddEpAnn]
an,SourceText
src) LHsSigType GhcPs
typ) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
markAnnOpen EpAnn [AddEpAnn]
an SourceText
src String
"{-# SPECIALISE"
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnInstance
    GenLocated SrcSpanAnnA (HsSigType GhcPs)
typ' <- GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
typ
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"#-}")
    Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSpecInstSig GhcPs -> LHsSigType GhcPs -> Sig GhcPs
forall pass. XSpecInstSig pass -> LHsSigType pass -> Sig pass
SpecInstSig (EpAnn [AddEpAnn]
an2,SourceText
src) LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
typ')

  exact (MinimalSig (EpAnn [AddEpAnn]
an,SourceText
src) LBooleanFormula (LIdP GhcPs)
formula) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
markAnnOpen EpAnn [AddEpAnn]
an SourceText
src String
"{-# MINIMAL"
    LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
formula' <- LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> EP w m (LBooleanFormula (GenLocated SrcSpanAnnN RdrName))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LBooleanFormula (LIdP GhcPs)
LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
formula
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"#-}")
    Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XMinimalSig GhcPs -> LBooleanFormula (LIdP GhcPs) -> Sig GhcPs
forall pass.
XMinimalSig pass -> LBooleanFormula (LIdP pass) -> Sig pass
MinimalSig (EpAnn [AddEpAnn]
an1,SourceText
src) LBooleanFormula (LIdP GhcPs)
LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
formula')

  exact (SCCFunSig (EpAnn [AddEpAnn]
an,SourceText
src) LIdP GhcPs
ln Maybe (XRec GhcPs StringLiteral)
ml) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
markAnnOpen EpAnn [AddEpAnn]
an SourceText
src String
"{-# SCC"
    GenLocated SrcSpanAnnN RdrName
ln' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ln
    Maybe (GenLocated (SrcAnn NoEpAnns) StringLiteral)
ml' <- Maybe (GenLocated (SrcAnn NoEpAnns) StringLiteral)
-> EP w m (Maybe (GenLocated (SrcAnn NoEpAnns) StringLiteral))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (XRec GhcPs StringLiteral)
Maybe (GenLocated (SrcAnn NoEpAnns) StringLiteral)
ml
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"#-}")
    Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSCCFunSig GhcPs
-> LIdP GhcPs -> Maybe (XRec GhcPs StringLiteral) -> Sig GhcPs
forall pass.
XSCCFunSig pass
-> LIdP pass -> Maybe (XRec pass StringLiteral) -> Sig pass
SCCFunSig (EpAnn [AddEpAnn]
an1,SourceText
src) LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ln' Maybe (XRec GhcPs StringLiteral)
Maybe (GenLocated (SrcAnn NoEpAnns) StringLiteral)
ml')

  exact (CompleteMatchSig (EpAnn [AddEpAnn]
an,SourceText
src) XRec GhcPs [LIdP GhcPs]
cs Maybe (LIdP GhcPs)
mty) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> SourceText -> String -> EP w m (EpAnn [AddEpAnn])
markAnnOpen EpAnn [AddEpAnn]
an SourceText
src String
"{-# COMPLETE"
    GenLocated SrcSpan [GenLocated SrcSpanAnnN RdrName]
cs' <- GenLocated SrcSpan [GenLocated SrcSpanAnnN RdrName]
-> EP w m (GenLocated SrcSpan [GenLocated SrcSpanAnnN RdrName])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs [LIdP GhcPs]
GenLocated SrcSpan [GenLocated SrcSpanAnnN RdrName]
cs
    (EpAnn [AddEpAnn]
an1, Maybe (GenLocated SrcSpanAnnN RdrName)
mty') <-
      case Maybe (LIdP GhcPs)
mty of
        Maybe (LIdP GhcPs)
Nothing -> (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnN RdrName))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnN RdrName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, Maybe (LIdP GhcPs)
Maybe (GenLocated SrcSpanAnnN RdrName)
mty)
        Just LIdP GhcPs
ty -> do
          EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
          GenLocated SrcSpanAnnN RdrName
ty' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ty
          (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnN RdrName))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnN RdrName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, GenLocated SrcSpanAnnN RdrName
-> Maybe (GenLocated SrcSpanAnnN RdrName)
forall a. a -> Maybe a
Just GenLocated SrcSpanAnnN RdrName
ty')
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"#-}")
    Sig GhcPs -> EP w m (Sig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCompleteMatchSig GhcPs
-> XRec GhcPs [LIdP GhcPs] -> Maybe (LIdP GhcPs) -> Sig GhcPs
forall pass.
XCompleteMatchSig pass
-> XRec pass [LIdP pass] -> Maybe (LIdP pass) -> Sig pass
CompleteMatchSig (EpAnn [AddEpAnn]
an2,SourceText
src) XRec GhcPs [LIdP GhcPs]
GenLocated SrcSpan [GenLocated SrcSpanAnnN RdrName]
cs' Maybe (LIdP GhcPs)
Maybe (GenLocated SrcSpanAnnN RdrName)
mty')

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

exactVarSig :: (Monad m, Monoid w, ExactPrint a)
  => EpAnn AnnSig -> [LocatedN RdrName] -> a -> EP w m (EpAnn AnnSig, [LocatedN RdrName], a)
exactVarSig :: forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
EpAnn AnnSig
-> [GenLocated SrcSpanAnnN RdrName]
-> a
-> EP w m (EpAnn AnnSig, [GenLocated SrcSpanAnnN RdrName], a)
exactVarSig EpAnn AnnSig
an [GenLocated SrcSpanAnnN RdrName]
vars a
ty = do
  [GenLocated SrcSpanAnnN RdrName]
vars' <- (GenLocated SrcSpanAnnN RdrName
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnN RdrName))
-> [GenLocated SrcSpanAnnN RdrName]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated SrcSpanAnnN RdrName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated SrcSpanAnnN RdrName
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GenLocated SrcSpanAnnN RdrName]
vars
  EpAnn AnnSig
an0 <- EpAnn AnnSig -> Lens AnnSig AddEpAnn -> EP w m (EpAnn AnnSig)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA EpAnn AnnSig
an (AddEpAnn -> f AddEpAnn) -> AnnSig -> f AnnSig
Lens AnnSig AddEpAnn
lasDcolon
  a
ty' <- a -> EP w m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated a
ty
  (EpAnn AnnSig, [GenLocated SrcSpanAnnN RdrName], a)
-> EP w m (EpAnn AnnSig, [GenLocated SrcSpanAnnN RdrName], a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnSig
an0, [GenLocated SrcSpanAnnN RdrName]
vars', a
ty')

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

instance ExactPrint (StandaloneKindSig GhcPs) where
  getAnnotationEntry :: StandaloneKindSig GhcPs -> Entry
getAnnotationEntry (StandaloneKindSig XStandaloneKindSig GhcPs
an LIdP GhcPs
_ LHsSigType GhcPs
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XStandaloneKindSig GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: StandaloneKindSig GhcPs
-> Anchor -> EpAnnComments -> StandaloneKindSig GhcPs
setAnnotationAnchor (StandaloneKindSig XStandaloneKindSig GhcPs
an LIdP GhcPs
a LHsSigType GhcPs
b) Anchor
anc EpAnnComments
cs = XStandaloneKindSig GhcPs
-> LIdP GhcPs -> LHsSigType GhcPs -> StandaloneKindSig GhcPs
forall pass.
XStandaloneKindSig pass
-> LIdP pass -> LHsSigType pass -> StandaloneKindSig pass
StandaloneKindSig (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XStandaloneKindSig GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LIdP GhcPs
a LHsSigType GhcPs
b

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
StandaloneKindSig GhcPs -> EP w m (StandaloneKindSig GhcPs)
exact (StandaloneKindSig XStandaloneKindSig GhcPs
an LIdP GhcPs
vars LHsSigType GhcPs
sig) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XStandaloneKindSig GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnType
    GenLocated SrcSpanAnnN RdrName
vars' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
vars
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
    GenLocated SrcSpanAnnA (HsSigType GhcPs)
sig' <- GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
sig
    StandaloneKindSig GhcPs -> EP w m (StandaloneKindSig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XStandaloneKindSig GhcPs
-> LIdP GhcPs -> LHsSigType GhcPs -> StandaloneKindSig GhcPs
forall pass.
XStandaloneKindSig pass
-> LIdP pass -> LHsSigType pass -> StandaloneKindSig pass
StandaloneKindSig XStandaloneKindSig GhcPs
EpAnn [AddEpAnn]
an1 LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
vars' LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
sig')

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

instance ExactPrint (DefaultDecl GhcPs) where
  getAnnotationEntry :: DefaultDecl GhcPs -> Entry
getAnnotationEntry (DefaultDecl XCDefaultDecl GhcPs
an [LHsType GhcPs]
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCDefaultDecl GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: DefaultDecl GhcPs -> Anchor -> EpAnnComments -> DefaultDecl GhcPs
setAnnotationAnchor (DefaultDecl XCDefaultDecl GhcPs
an [LHsType GhcPs]
a) Anchor
anc EpAnnComments
cs = XCDefaultDecl GhcPs -> [LHsType GhcPs] -> DefaultDecl GhcPs
forall pass.
XCDefaultDecl pass -> [LHsType pass] -> DefaultDecl pass
DefaultDecl (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCDefaultDecl GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) [LHsType GhcPs]
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DefaultDecl GhcPs -> EP w m (DefaultDecl GhcPs)
exact (DefaultDecl XCDefaultDecl GhcPs
an [LHsType GhcPs]
tys) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCDefaultDecl GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDefault
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenP
    [GenLocated SrcSpanAnnA (HsType GhcPs)]
tys' <- [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsType GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsType GhcPs]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
tys
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseP
    DefaultDecl GhcPs -> EP w m (DefaultDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCDefaultDecl GhcPs -> [LHsType GhcPs] -> DefaultDecl GhcPs
forall pass.
XCDefaultDecl pass -> [LHsType pass] -> DefaultDecl pass
DefaultDecl XCDefaultDecl GhcPs
EpAnn [AddEpAnn]
an2 [LHsType GhcPs]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
tys')

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

instance ExactPrint (AnnDecl GhcPs) where
  getAnnotationEntry :: AnnDecl GhcPs -> Entry
getAnnotationEntry (HsAnnotation (EpAnn AnnPragma
an, SourceText
_) AnnProvenance GhcPs
_ XRec GhcPs (HsExpr GhcPs)
_) = EpAnn AnnPragma -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn AnnPragma
an
  setAnnotationAnchor :: AnnDecl GhcPs -> Anchor -> EpAnnComments -> AnnDecl GhcPs
setAnnotationAnchor (HsAnnotation (EpAnn AnnPragma
an,SourceText
a) AnnProvenance GhcPs
b XRec GhcPs (HsExpr GhcPs)
c) Anchor
anc EpAnnComments
cs = XHsAnnotation GhcPs
-> AnnProvenance GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> AnnDecl GhcPs
forall pass.
XHsAnnotation pass
-> AnnProvenance pass -> XRec pass (HsExpr pass) -> AnnDecl pass
HsAnnotation ((EpAnn AnnPragma -> Anchor -> EpAnnComments -> EpAnn AnnPragma
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa EpAnn AnnPragma
an Anchor
anc EpAnnComments
cs),SourceText
a) AnnProvenance GhcPs
b XRec GhcPs (HsExpr GhcPs)
c

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnDecl GhcPs -> EP w m (AnnDecl GhcPs)
exact (HsAnnotation (EpAnn AnnPragma
an, SourceText
src) AnnProvenance GhcPs
prov XRec GhcPs (HsExpr GhcPs)
e) = do
    EpAnn AnnPragma
an0 <- EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
src String
"{-# ANN"
    (EpAnn AnnPragma
an1, AnnProvenance GhcPs
prov') <-
      case AnnProvenance GhcPs
prov of
        (ValueAnnProvenance LIdP GhcPs
n) -> do
          GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
          (EpAnn AnnPragma, AnnProvenance GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnPragma, AnnProvenance GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnPragma
an0, LIdP GhcPs -> AnnProvenance GhcPs
forall pass. LIdP pass -> AnnProvenance pass
ValueAnnProvenance LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n')
        (TypeAnnProvenance LIdP GhcPs
n) -> do
          EpAnn AnnPragma
an1 <- EpAnn AnnPragma
-> Lens AnnPragma [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn AnnPragma
an0 ([AddEpAnn] -> f [AddEpAnn]) -> AnnPragma -> f AnnPragma
Lens AnnPragma [AddEpAnn]
lapr_rest AnnKeywordId
AnnType
          GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
          (EpAnn AnnPragma, AnnProvenance GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnPragma, AnnProvenance GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnPragma
an1, LIdP GhcPs -> AnnProvenance GhcPs
forall pass. LIdP pass -> AnnProvenance pass
TypeAnnProvenance LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n')
        AnnProvenance GhcPs
ModuleAnnProvenance -> do
          EpAnn AnnPragma
an1 <- EpAnn AnnPragma
-> Lens AnnPragma [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn AnnPragma
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnPragma -> f AnnPragma
Lens AnnPragma [AddEpAnn]
lapr_rest AnnKeywordId
AnnModule
          (EpAnn AnnPragma, AnnProvenance GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnPragma, AnnProvenance GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnPragma
an1, AnnProvenance GhcPs
prov)

    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
    EpAnn AnnPragma
an2 <- EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an1
    AnnDecl GhcPs -> EP w m (AnnDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsAnnotation GhcPs
-> AnnProvenance GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> AnnDecl GhcPs
forall pass.
XHsAnnotation pass
-> AnnProvenance pass -> XRec pass (HsExpr pass) -> AnnDecl pass
HsAnnotation (EpAnn AnnPragma
an2,SourceText
src) AnnProvenance GhcPs
prov' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e')

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

instance ExactPrint (BF.BooleanFormula (LocatedN RdrName)) where
  getAnnotationEntry :: BooleanFormula (GenLocated SrcSpanAnnN RdrName) -> Entry
getAnnotationEntry = Entry -> BooleanFormula (GenLocated SrcSpanAnnN RdrName) -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: BooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> Anchor
-> EpAnnComments
-> BooleanFormula (GenLocated SrcSpanAnnN RdrName)
setAnnotationAnchor BooleanFormula (GenLocated SrcSpanAnnN RdrName)
a Anchor
_ EpAnnComments
_ = BooleanFormula (GenLocated SrcSpanAnnN RdrName)
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
BooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> EP w m (BooleanFormula (GenLocated SrcSpanAnnN RdrName))
exact (BF.Var GenLocated SrcSpanAnnN RdrName
x)  = do
    GenLocated SrcSpanAnnN RdrName
x' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated SrcSpanAnnN RdrName
x
    BooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> EP w m (BooleanFormula (GenLocated SrcSpanAnnN RdrName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnN RdrName
-> BooleanFormula (GenLocated SrcSpanAnnN RdrName)
forall a. a -> BooleanFormula a
BF.Var GenLocated SrcSpanAnnN RdrName
x')
  exact (BF.Or [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
ls)  = do
    [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
ls' <- [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
-> EP w m [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
ls
    BooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> EP w m (BooleanFormula (GenLocated SrcSpanAnnN RdrName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
-> BooleanFormula (GenLocated SrcSpanAnnN RdrName)
forall a. [LBooleanFormula a] -> BooleanFormula a
BF.Or [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
ls')
  exact (BF.And [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
ls) = do
    [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
ls' <- [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
-> EP w m [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
ls
    BooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> EP w m (BooleanFormula (GenLocated SrcSpanAnnN RdrName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
-> BooleanFormula (GenLocated SrcSpanAnnN RdrName)
forall a. [LBooleanFormula a] -> BooleanFormula a
BF.And [LBooleanFormula (GenLocated SrcSpanAnnN RdrName)]
ls')
  exact (BF.Parens LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
x)  = do
    LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
x' <- LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> EP w m (LBooleanFormula (GenLocated SrcSpanAnnN RdrName))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
x
    BooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> EP w m (BooleanFormula (GenLocated SrcSpanAnnN RdrName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> BooleanFormula (GenLocated SrcSpanAnnN RdrName)
forall a. LBooleanFormula a -> BooleanFormula a
BF.Parens LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
x')

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

instance (ExactPrint body) => ExactPrint (HsWildCardBndrs GhcPs body) where
  getAnnotationEntry :: HsWildCardBndrs GhcPs body -> Entry
getAnnotationEntry = Entry -> HsWildCardBndrs GhcPs body -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: HsWildCardBndrs GhcPs body
-> Anchor -> EpAnnComments -> HsWildCardBndrs GhcPs body
setAnnotationAnchor HsWildCardBndrs GhcPs body
a Anchor
_ EpAnnComments
_ = HsWildCardBndrs GhcPs body
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsWildCardBndrs GhcPs body -> EP w m (HsWildCardBndrs GhcPs body)
exact (HsWC XHsWC GhcPs body
x body
ty) = do
    body
ty' <- body -> EP w m body
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated body
ty
    HsWildCardBndrs GhcPs body -> EP w m (HsWildCardBndrs GhcPs body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsWC GhcPs body -> body -> HsWildCardBndrs GhcPs body
forall pass thing.
XHsWC pass thing -> thing -> HsWildCardBndrs pass thing
HsWC XHsWC GhcPs body
x body
ty')

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

instance ExactPrint (GRHS GhcPs (LocatedA (HsExpr GhcPs))) where
  getAnnotationEntry :: GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)) -> Entry
getAnnotationEntry (GRHS XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
an [GuardLStmt GhcPs]
_ GenLocated SrcSpanAnnA (HsExpr GhcPs)
_) = EpAnn GrhsAnn -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn GrhsAnn
an
  setAnnotationAnchor :: GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> Anchor
-> EpAnnComments
-> GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
setAnnotationAnchor (GRHS XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
an [GuardLStmt GhcPs]
a GenLocated SrcSpanAnnA (HsExpr GhcPs)
b) Anchor
anc EpAnnComments
cs = XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> [GuardLStmt GhcPs]
-> GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall p body.
XCGRHS p body -> [GuardLStmt p] -> body -> GRHS p body
GRHS (EpAnn GrhsAnn -> Anchor -> EpAnnComments -> EpAnn GrhsAnn
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn GrhsAnn
an Anchor
anc EpAnnComments
cs) [GuardLStmt GhcPs]
a GenLocated SrcSpanAnnA (HsExpr GhcPs)
b

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP w m (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
exact (GRHS XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
an [GuardLStmt GhcPs]
guards GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"GRHS comments:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ EpAnnComments -> String
forall a. Outputable a => a -> String
showGhc (EpAnn GrhsAnn -> EpAnnComments
forall ann. EpAnn ann -> EpAnnComments
comments XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn GrhsAnn
an)
    EpAnn GrhsAnn
an0 <- if [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [GuardLStmt GhcPs]
[GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
guards
             then EpAnn GrhsAnn
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn GrhsAnn)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn GrhsAnn
an
             else EpAnn GrhsAnn
-> Lens GrhsAnn (Maybe EpaLocation)
-> AnnKeywordId
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn GrhsAnn)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a (Maybe EpaLocation) -> AnnKeywordId -> EP w m (EpAnn a)
markLensKwM XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn GrhsAnn
an (Maybe EpaLocation -> f (Maybe EpaLocation))
-> GrhsAnn -> f GrhsAnn
Lens GrhsAnn (Maybe EpaLocation)
lga_vbar AnnKeywordId
AnnVbar
    [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
guards' <- [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GuardLStmt GhcPs]
[GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
guards
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"GRHS before matchSeparator"
    EpAnn GrhsAnn
an1 <- EpAnn GrhsAnn
-> Lens GrhsAnn AddEpAnn
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn GrhsAnn)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA EpAnn GrhsAnn
an0 (AddEpAnn -> f AddEpAnn) -> GrhsAnn -> f GrhsAnn
Lens GrhsAnn AddEpAnn
lga_sep -- Mark the matchSeparator for these GRHSs
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"GRHS after matchSeparator"
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr
    GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP w m (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> [GuardLStmt GhcPs]
-> GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall p body.
XCGRHS p body -> [GuardLStmt p] -> body -> GRHS p body
GRHS XCGRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn GrhsAnn
an1 [GuardLStmt GhcPs]
[GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
guards' GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr')

instance ExactPrint (GRHS GhcPs (LocatedA (HsCmd GhcPs))) where
  getAnnotationEntry :: GRHS GhcPs (LocatedA (HsCmd GhcPs)) -> Entry
getAnnotationEntry (GRHS XCGRHS GhcPs (LocatedA (HsCmd GhcPs))
ann [GuardLStmt GhcPs]
_ LocatedA (HsCmd GhcPs)
_) = EpAnn GrhsAnn -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCGRHS GhcPs (LocatedA (HsCmd GhcPs))
EpAnn GrhsAnn
ann
  setAnnotationAnchor :: GRHS GhcPs (LocatedA (HsCmd GhcPs))
-> Anchor -> EpAnnComments -> GRHS GhcPs (LocatedA (HsCmd GhcPs))
setAnnotationAnchor (GRHS XCGRHS GhcPs (LocatedA (HsCmd GhcPs))
an [GuardLStmt GhcPs]
a LocatedA (HsCmd GhcPs)
b) Anchor
anc EpAnnComments
cs = XCGRHS GhcPs (LocatedA (HsCmd GhcPs))
-> [GuardLStmt GhcPs]
-> LocatedA (HsCmd GhcPs)
-> GRHS GhcPs (LocatedA (HsCmd GhcPs))
forall p body.
XCGRHS p body -> [GuardLStmt p] -> body -> GRHS p body
GRHS (EpAnn GrhsAnn -> Anchor -> EpAnnComments -> EpAnn GrhsAnn
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCGRHS GhcPs (LocatedA (HsCmd GhcPs))
EpAnn GrhsAnn
an Anchor
anc EpAnnComments
cs) [GuardLStmt GhcPs]
a LocatedA (HsCmd GhcPs)
b

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GRHS GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (GRHS GhcPs (LocatedA (HsCmd GhcPs)))
exact (GRHS XCGRHS GhcPs (LocatedA (HsCmd GhcPs))
an [GuardLStmt GhcPs]
guards LocatedA (HsCmd GhcPs)
expr) = do
    EpAnn GrhsAnn
an0 <- EpAnn GrhsAnn
-> Lens GrhsAnn (Maybe EpaLocation)
-> AnnKeywordId
-> EP w m (EpAnn GrhsAnn)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a (Maybe EpaLocation) -> AnnKeywordId -> EP w m (EpAnn a)
markLensKwM XCGRHS GhcPs (LocatedA (HsCmd GhcPs))
EpAnn GrhsAnn
an (Maybe EpaLocation -> f (Maybe EpaLocation))
-> GrhsAnn -> f GrhsAnn
Lens GrhsAnn (Maybe EpaLocation)
lga_vbar AnnKeywordId
AnnVbar
    [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
guards' <- [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GuardLStmt GhcPs]
[GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
guards
    EpAnn GrhsAnn
an1 <- EpAnn GrhsAnn -> Lens GrhsAnn AddEpAnn -> EP w m (EpAnn GrhsAnn)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA EpAnn GrhsAnn
an0 (AddEpAnn -> f AddEpAnn) -> GrhsAnn -> f GrhsAnn
Lens GrhsAnn AddEpAnn
lga_sep -- Mark the matchSeparator for these GRHSs
    LocatedA (HsCmd GhcPs)
expr' <- LocatedA (HsCmd GhcPs) -> EP w m (LocatedA (HsCmd GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LocatedA (HsCmd GhcPs)
expr
    GRHS GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (GRHS GhcPs (LocatedA (HsCmd GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCGRHS GhcPs (LocatedA (HsCmd GhcPs))
-> [GuardLStmt GhcPs]
-> LocatedA (HsCmd GhcPs)
-> GRHS GhcPs (LocatedA (HsCmd GhcPs))
forall p body.
XCGRHS p body -> [GuardLStmt p] -> body -> GRHS p body
GRHS XCGRHS GhcPs (LocatedA (HsCmd GhcPs))
EpAnn GrhsAnn
an1 [GuardLStmt GhcPs]
[GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
guards' LocatedA (HsCmd GhcPs)
expr')

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

instance ExactPrint (HsExpr GhcPs) where
  getAnnotationEntry :: HsExpr GhcPs -> Entry
getAnnotationEntry (HsVar{})                    = Entry
NoEntryVal
  getAnnotationEntry (HsUnboundVar XUnboundVar GhcPs
an RdrName
_)          = EpAnn EpAnnUnboundVar -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XUnboundVar GhcPs
EpAnn EpAnnUnboundVar
an
  getAnnotationEntry (HsRecSel{})                 = Entry
NoEntryVal
  getAnnotationEntry (HsOverLabel XOverLabel GhcPs
an SourceText
_ FastString
_)         = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XOverLabel GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsIPVar XIPVar GhcPs
an HsIPName
_)               = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XIPVar GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsOverLit XOverLitE GhcPs
an HsOverLit GhcPs
_)             = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XOverLitE GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsLit XLitE GhcPs
an HsLit GhcPs
_)                 = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XLitE GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsLam XLam GhcPs
_ MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
_)                  = Entry
NoEntryVal
  getAnnotationEntry (HsLamCase XLamCase GhcPs
an LamCaseVariant
_ MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
_)           = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XLamCase GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsApp XApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ XRec GhcPs (HsExpr GhcPs)
_)               = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XApp GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsAppType XAppTypeE GhcPs
_ XRec GhcPs (HsExpr GhcPs)
_ LHsToken "@" GhcPs
_ LHsWcType (NoGhcTc GhcPs)
_)          = Entry
NoEntryVal
  getAnnotationEntry (OpApp XOpApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ XRec GhcPs (HsExpr GhcPs)
_ XRec GhcPs (HsExpr GhcPs)
_)             = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XOpApp GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (NegApp XNegApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ SyntaxExpr GhcPs
_)              = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XNegApp GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsPar XPar GhcPs
an LHsToken "(" GhcPs
_ XRec GhcPs (HsExpr GhcPs)
_ LHsToken ")" GhcPs
_)             = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XPar GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (SectionL XSectionL GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ XRec GhcPs (HsExpr GhcPs)
_)            = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XSectionL GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (SectionR XSectionR GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ XRec GhcPs (HsExpr GhcPs)
_)            = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XSectionR GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (ExplicitTuple XExplicitTuple GhcPs
an [HsTupArg GhcPs]
_ Boxity
_)       = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XExplicitTuple GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (ExplicitSum XExplicitSum GhcPs
an Int
_ Int
_ XRec GhcPs (HsExpr GhcPs)
_)       = EpAnn AnnExplicitSum -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XExplicitSum GhcPs
EpAnn AnnExplicitSum
an
  getAnnotationEntry (HsCase XCase GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
_)              = EpAnn EpAnnHsCase -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCase GhcPs
EpAnn EpAnnHsCase
an
  getAnnotationEntry (HsIf XIf GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ XRec GhcPs (HsExpr GhcPs)
_ XRec GhcPs (HsExpr GhcPs)
_)              = EpAnn AnnsIf -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XIf GhcPs
EpAnn AnnsIf
an
  getAnnotationEntry (HsMultiIf XMultiIf GhcPs
an [LGRHS GhcPs (XRec GhcPs (HsExpr GhcPs))]
_)             = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XMultiIf GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsLet XLet GhcPs
an LHsToken "let" GhcPs
_ HsLocalBinds GhcPs
_ LHsToken "in" GhcPs
_ XRec GhcPs (HsExpr GhcPs)
_)           = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XLet GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsDo XDo GhcPs
an HsDoFlavour
_ XRec GhcPs [GuardLStmt GhcPs]
_)                = EpAnn AnnList -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XDo GhcPs
EpAnn AnnList
an
  getAnnotationEntry (ExplicitList XExplicitList GhcPs
an [XRec GhcPs (HsExpr GhcPs)]
_)          = EpAnn AnnList -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XExplicitList GhcPs
EpAnn AnnList
an
  getAnnotationEntry (RecordCon XRecordCon GhcPs
an XRec GhcPs (ConLikeP GhcPs)
_ HsRecordBinds GhcPs
_)           = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XRecordCon GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (RecordUpd XRecordUpd GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ Either [LHsRecUpdField GhcPs] [LHsRecUpdProj GhcPs]
_)           = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XRecordUpd GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsGetField XGetField GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ XRec GhcPs (DotFieldOcc GhcPs)
_)          = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XGetField GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsProjection XProjection GhcPs
an NonEmpty (XRec GhcPs (DotFieldOcc GhcPs))
_)          = EpAnn AnnProjection -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XProjection GhcPs
EpAnn AnnProjection
an
  getAnnotationEntry (ExprWithTySig XExprWithTySig GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ LHsSigWcType (NoGhcTc GhcPs)
_)       = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XExprWithTySig GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (ArithSeq XArithSeq GhcPs
an Maybe (SyntaxExpr GhcPs)
_ ArithSeqInfo GhcPs
_)            = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XArithSeq GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsTypedBracket XTypedBracket GhcPs
an XRec GhcPs (HsExpr GhcPs)
_)        = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XTypedBracket GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsUntypedBracket XUntypedBracket GhcPs
an HsQuote GhcPs
_)      = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsTypedSplice (EpAnn NoEpAnns
_, EpAnn [AddEpAnn]
an) XRec GhcPs (HsExpr GhcPs)
_)    = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsUntypedSplice XUntypedSplice GhcPs
an HsUntypedSplice GhcPs
_)       = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XUntypedSplice GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsProc XProc GhcPs
an LPat GhcPs
_ LHsCmdTop GhcPs
_)              = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XProc GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsStatic XStatic GhcPs
an XRec GhcPs (HsExpr GhcPs)
_)              = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XStatic GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsPragE{})                  = Entry
NoEntryVal

  setAnnotationAnchor :: HsExpr GhcPs -> Anchor -> EpAnnComments -> HsExpr GhcPs
setAnnotationAnchor a :: HsExpr GhcPs
a@(HsVar{})              Anchor
_ EpAnnComments
_s = HsExpr GhcPs
a
  setAnnotationAnchor (HsUnboundVar XUnboundVar GhcPs
an RdrName
a)    Anchor
anc EpAnnComments
cs = (XUnboundVar GhcPs -> RdrName -> HsExpr GhcPs
forall p. XUnboundVar p -> RdrName -> HsExpr p
HsUnboundVar (EpAnn EpAnnUnboundVar
-> Anchor -> EpAnnComments -> EpAnn EpAnnUnboundVar
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XUnboundVar GhcPs
EpAnn EpAnnUnboundVar
an Anchor
anc EpAnnComments
cs) RdrName
a)
  setAnnotationAnchor a :: HsExpr GhcPs
a@(HsRecSel{})           Anchor
_ EpAnnComments
_s  = HsExpr GhcPs
a
  setAnnotationAnchor (HsOverLabel XOverLabel GhcPs
an SourceText
s FastString
a)   Anchor
anc EpAnnComments
cs = (XOverLabel GhcPs -> SourceText -> FastString -> HsExpr GhcPs
forall p. XOverLabel p -> SourceText -> FastString -> HsExpr p
HsOverLabel (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XOverLabel GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) SourceText
s FastString
a)
  setAnnotationAnchor (HsIPVar XIPVar GhcPs
an HsIPName
a)         Anchor
anc EpAnnComments
cs = (XIPVar GhcPs -> HsIPName -> HsExpr GhcPs
forall p. XIPVar p -> HsIPName -> HsExpr p
HsIPVar (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XIPVar GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) HsIPName
a)
  setAnnotationAnchor (HsOverLit XOverLitE GhcPs
an HsOverLit GhcPs
a)       Anchor
anc EpAnnComments
cs = (XOverLitE GhcPs -> HsOverLit GhcPs -> HsExpr GhcPs
forall p. XOverLitE p -> HsOverLit p -> HsExpr p
HsOverLit (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XOverLitE GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) HsOverLit GhcPs
a)
  setAnnotationAnchor (HsLit XLitE GhcPs
an HsLit GhcPs
a)           Anchor
anc EpAnnComments
cs = (XLitE GhcPs -> HsLit GhcPs -> HsExpr GhcPs
forall p. XLitE p -> HsLit p -> HsExpr p
HsLit (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XLitE GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) HsLit GhcPs
a)
  setAnnotationAnchor a :: HsExpr GhcPs
a@(HsLam XLam GhcPs
_ MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
_)            Anchor
_ EpAnnComments
_s = HsExpr GhcPs
a
  setAnnotationAnchor (HsLamCase XLamCase GhcPs
an LamCaseVariant
a MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
b)     Anchor
anc EpAnnComments
cs = (XLamCase GhcPs
-> LamCaseVariant
-> MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
-> HsExpr GhcPs
forall p.
XLamCase p
-> LamCaseVariant -> MatchGroup p (LHsExpr p) -> HsExpr p
HsLamCase (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XLamCase GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LamCaseVariant
a MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
b)
  setAnnotationAnchor (HsApp XApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b)         Anchor
anc EpAnnComments
cs = (XApp GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p. XApp p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsApp (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XApp GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b)
  setAnnotationAnchor a :: HsExpr GhcPs
a@(HsAppType {})      Anchor
_ EpAnnComments
_s = HsExpr GhcPs
a
  setAnnotationAnchor (OpApp XOpApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b XRec GhcPs (HsExpr GhcPs)
c)       Anchor
anc EpAnnComments
cs = (XOpApp GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p.
XOpApp p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
OpApp (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XOpApp GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b XRec GhcPs (HsExpr GhcPs)
c)
  setAnnotationAnchor (NegApp XNegApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
a SyntaxExpr GhcPs
b)        Anchor
anc EpAnnComments
cs = (XNegApp GhcPs
-> XRec GhcPs (HsExpr GhcPs) -> SyntaxExpr GhcPs -> HsExpr GhcPs
forall p. XNegApp p -> LHsExpr p -> SyntaxExpr p -> HsExpr p
NegApp (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XNegApp GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a SyntaxExpr GhcPs
b)
  setAnnotationAnchor (HsPar XPar GhcPs
an LHsToken "(" GhcPs
a XRec GhcPs (HsExpr GhcPs)
b LHsToken ")" GhcPs
c)       Anchor
anc EpAnnComments
cs = (XPar GhcPs
-> LHsToken "(" GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> LHsToken ")" GhcPs
-> HsExpr GhcPs
forall p.
XPar p -> LHsToken "(" p -> LHsExpr p -> LHsToken ")" p -> HsExpr p
HsPar (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XPar GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) LHsToken "(" GhcPs
a XRec GhcPs (HsExpr GhcPs)
b LHsToken ")" GhcPs
c)
  setAnnotationAnchor (SectionL XSectionL GhcPs
an XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b)      Anchor
anc EpAnnComments
cs = (XSectionL GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p. XSectionL p -> LHsExpr p -> LHsExpr p -> HsExpr p
SectionL (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XSectionL GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b)
  setAnnotationAnchor (SectionR XSectionR GhcPs
an XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b)      Anchor
anc EpAnnComments
cs = (XSectionR GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p. XSectionR p -> LHsExpr p -> LHsExpr p -> HsExpr p
SectionR (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XSectionR GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b)
  setAnnotationAnchor (ExplicitTuple XExplicitTuple GhcPs
an [HsTupArg GhcPs]
a Boxity
b) Anchor
anc EpAnnComments
cs = (XExplicitTuple GhcPs -> [HsTupArg GhcPs] -> Boxity -> HsExpr GhcPs
forall p. XExplicitTuple p -> [HsTupArg p] -> Boxity -> HsExpr p
ExplicitTuple (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XExplicitTuple GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) [HsTupArg GhcPs]
a Boxity
b)
  setAnnotationAnchor (ExplicitSum XExplicitSum GhcPs
an Int
a Int
b XRec GhcPs (HsExpr GhcPs)
c) Anchor
anc EpAnnComments
cs = (XExplicitSum GhcPs
-> Int -> Int -> XRec GhcPs (HsExpr GhcPs) -> HsExpr GhcPs
forall p. XExplicitSum p -> Int -> Int -> LHsExpr p -> HsExpr p
ExplicitSum (EpAnn AnnExplicitSum
-> Anchor -> EpAnnComments -> EpAnn AnnExplicitSum
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XExplicitSum GhcPs
EpAnn AnnExplicitSum
an Anchor
anc EpAnnComments
cs) Int
a Int
b XRec GhcPs (HsExpr GhcPs)
c)
  setAnnotationAnchor (HsCase XCase GhcPs
an XRec GhcPs (HsExpr GhcPs)
a MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
b)        Anchor
anc EpAnnComments
cs = (XCase GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
-> HsExpr GhcPs
forall p.
XCase p -> LHsExpr p -> MatchGroup p (LHsExpr p) -> HsExpr p
HsCase (EpAnn EpAnnHsCase -> Anchor -> EpAnnComments -> EpAnn EpAnnHsCase
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCase GhcPs
EpAnn EpAnnHsCase
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
b)
  setAnnotationAnchor (HsIf XIf GhcPs
an XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b XRec GhcPs (HsExpr GhcPs)
c)        Anchor
anc EpAnnComments
cs = (XIf GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p. XIf p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsIf (EpAnn AnnsIf -> Anchor -> EpAnnComments -> EpAnn AnnsIf
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XIf GhcPs
EpAnn AnnsIf
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b XRec GhcPs (HsExpr GhcPs)
c)
  setAnnotationAnchor (HsMultiIf XMultiIf GhcPs
an [LGRHS GhcPs (XRec GhcPs (HsExpr GhcPs))]
a)       Anchor
anc EpAnnComments
cs = (XMultiIf GhcPs
-> [LGRHS GhcPs (XRec GhcPs (HsExpr GhcPs))] -> HsExpr GhcPs
forall p. XMultiIf p -> [LGRHS p (LHsExpr p)] -> HsExpr p
HsMultiIf (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XMultiIf GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) [LGRHS GhcPs (XRec GhcPs (HsExpr GhcPs))]
a)
  setAnnotationAnchor (HsLet XLet GhcPs
an LHsToken "let" GhcPs
a HsLocalBinds GhcPs
b LHsToken "in" GhcPs
c XRec GhcPs (HsExpr GhcPs)
d)     Anchor
anc EpAnnComments
cs = (XLet GhcPs
-> LHsToken "let" GhcPs
-> HsLocalBinds GhcPs
-> LHsToken "in" GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p.
XLet p
-> LHsToken "let" p
-> HsLocalBinds p
-> LHsToken "in" p
-> LHsExpr p
-> HsExpr p
HsLet (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XLet GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) LHsToken "let" GhcPs
a HsLocalBinds GhcPs
b LHsToken "in" GhcPs
c XRec GhcPs (HsExpr GhcPs)
d)
  setAnnotationAnchor (HsDo XDo GhcPs
an HsDoFlavour
a XRec GhcPs [GuardLStmt GhcPs]
b)          Anchor
anc EpAnnComments
cs = (XDo GhcPs
-> HsDoFlavour -> XRec GhcPs [GuardLStmt GhcPs] -> HsExpr GhcPs
forall p. XDo p -> HsDoFlavour -> XRec p [ExprLStmt p] -> HsExpr p
HsDo (EpAnn AnnList -> Anchor -> EpAnnComments -> EpAnn AnnList
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XDo GhcPs
EpAnn AnnList
an Anchor
anc EpAnnComments
cs) HsDoFlavour
a XRec GhcPs [GuardLStmt GhcPs]
b)
  setAnnotationAnchor (ExplicitList XExplicitList GhcPs
an [XRec GhcPs (HsExpr GhcPs)]
a)    Anchor
anc EpAnnComments
cs = (XExplicitList GhcPs -> [XRec GhcPs (HsExpr GhcPs)] -> HsExpr GhcPs
forall p. XExplicitList p -> [LHsExpr p] -> HsExpr p
ExplicitList (EpAnn AnnList -> Anchor -> EpAnnComments -> EpAnn AnnList
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XExplicitList GhcPs
EpAnn AnnList
an Anchor
anc EpAnnComments
cs) [XRec GhcPs (HsExpr GhcPs)]
a)
  setAnnotationAnchor (RecordCon XRecordCon GhcPs
an XRec GhcPs (ConLikeP GhcPs)
a HsRecordBinds GhcPs
b)     Anchor
anc EpAnnComments
cs = (XRecordCon GhcPs
-> XRec GhcPs (ConLikeP GhcPs)
-> HsRecordBinds GhcPs
-> HsExpr GhcPs
forall p.
XRecordCon p -> XRec p (ConLikeP p) -> HsRecordBinds p -> HsExpr p
RecordCon (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XRecordCon GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (ConLikeP GhcPs)
a HsRecordBinds GhcPs
b)
  setAnnotationAnchor (RecordUpd XRecordUpd GhcPs
an XRec GhcPs (HsExpr GhcPs)
a Either [LHsRecUpdField GhcPs] [LHsRecUpdProj GhcPs]
b)     Anchor
anc EpAnnComments
cs = (XRecordUpd GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> Either [LHsRecUpdField GhcPs] [LHsRecUpdProj GhcPs]
-> HsExpr GhcPs
forall p.
XRecordUpd p
-> LHsExpr p
-> Either [LHsRecUpdField p] [LHsRecUpdProj p]
-> HsExpr p
RecordUpd (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XRecordUpd GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a Either [LHsRecUpdField GhcPs] [LHsRecUpdProj GhcPs]
b)
  setAnnotationAnchor (HsGetField XGetField GhcPs
an XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (DotFieldOcc GhcPs)
b)    Anchor
anc EpAnnComments
cs = (XGetField GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (DotFieldOcc GhcPs)
-> HsExpr GhcPs
forall p.
XGetField p -> LHsExpr p -> XRec p (DotFieldOcc p) -> HsExpr p
HsGetField (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XGetField GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (DotFieldOcc GhcPs)
b)
  setAnnotationAnchor (HsProjection XProjection GhcPs
an NonEmpty (XRec GhcPs (DotFieldOcc GhcPs))
a)    Anchor
anc EpAnnComments
cs = (XProjection GhcPs
-> NonEmpty (XRec GhcPs (DotFieldOcc GhcPs)) -> HsExpr GhcPs
forall p.
XProjection p -> NonEmpty (XRec p (DotFieldOcc p)) -> HsExpr p
HsProjection (EpAnn AnnProjection
-> Anchor -> EpAnnComments -> EpAnn AnnProjection
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XProjection GhcPs
EpAnn AnnProjection
an Anchor
anc EpAnnComments
cs) NonEmpty (XRec GhcPs (DotFieldOcc GhcPs))
a)
  setAnnotationAnchor (ExprWithTySig XExprWithTySig GhcPs
an XRec GhcPs (HsExpr GhcPs)
a LHsSigWcType (NoGhcTc GhcPs)
b) Anchor
anc EpAnnComments
cs = (XExprWithTySig GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> LHsSigWcType (NoGhcTc GhcPs)
-> HsExpr GhcPs
forall p.
XExprWithTySig p
-> LHsExpr p -> LHsSigWcType (NoGhcTc p) -> HsExpr p
ExprWithTySig (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XExprWithTySig GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a LHsSigWcType (NoGhcTc GhcPs)
b)
  setAnnotationAnchor (ArithSeq XArithSeq GhcPs
an Maybe (SyntaxExpr GhcPs)
a ArithSeqInfo GhcPs
b)      Anchor
anc EpAnnComments
cs = (XArithSeq GhcPs
-> Maybe (SyntaxExpr GhcPs) -> ArithSeqInfo GhcPs -> HsExpr GhcPs
forall p.
XArithSeq p -> Maybe (SyntaxExpr p) -> ArithSeqInfo p -> HsExpr p
ArithSeq (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XArithSeq GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) Maybe (SyntaxExpr GhcPs)
a ArithSeqInfo GhcPs
b)
  setAnnotationAnchor (HsTypedBracket XTypedBracket GhcPs
an XRec GhcPs (HsExpr GhcPs)
a)   Anchor
anc EpAnnComments
cs = (XTypedBracket GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsExpr GhcPs
forall p. XTypedBracket p -> LHsExpr p -> HsExpr p
HsTypedBracket (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XTypedBracket GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a)
  setAnnotationAnchor (HsUntypedBracket XUntypedBracket GhcPs
an HsQuote GhcPs
a) Anchor
anc EpAnnComments
cs = (XUntypedBracket GhcPs -> HsQuote GhcPs -> HsExpr GhcPs
forall p. XUntypedBracket p -> HsQuote p -> HsExpr p
HsUntypedBracket (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) HsQuote GhcPs
a)
  setAnnotationAnchor (HsTypedSplice (EpAnn NoEpAnns
x,EpAnn [AddEpAnn]
an) XRec GhcPs (HsExpr GhcPs)
e) Anchor
anc EpAnnComments
cs = (XTypedSplice GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsExpr GhcPs
forall p. XTypedSplice p -> LHsExpr p -> HsExpr p
HsTypedSplice (EpAnn NoEpAnns
x,(EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs)) XRec GhcPs (HsExpr GhcPs)
e)
  setAnnotationAnchor (HsUntypedSplice XUntypedSplice GhcPs
an HsUntypedSplice GhcPs
e)  Anchor
anc EpAnnComments
cs = (XUntypedSplice GhcPs -> HsUntypedSplice GhcPs -> HsExpr GhcPs
forall p. XUntypedSplice p -> HsUntypedSplice p -> HsExpr p
HsUntypedSplice (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XUntypedSplice GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) HsUntypedSplice GhcPs
e)
  setAnnotationAnchor (HsProc XProc GhcPs
an LPat GhcPs
a LHsCmdTop GhcPs
b)         Anchor
anc EpAnnComments
cs = (XProc GhcPs -> LPat GhcPs -> LHsCmdTop GhcPs -> HsExpr GhcPs
forall p. XProc p -> LPat p -> LHsCmdTop p -> HsExpr p
HsProc (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XProc GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LPat GhcPs
a LHsCmdTop GhcPs
b)
  setAnnotationAnchor (HsStatic XStatic GhcPs
an XRec GhcPs (HsExpr GhcPs)
a)         Anchor
anc EpAnnComments
cs = (XStatic GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsExpr GhcPs
forall p. XStatic p -> LHsExpr p -> HsExpr p
HsStatic (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XStatic GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a)
  setAnnotationAnchor a :: HsExpr GhcPs
a@(HsPragE{})            Anchor
_ EpAnnComments
_s = HsExpr GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsExpr GhcPs -> EP w m (HsExpr GhcPs)
exact (HsVar XVar GhcPs
x LIdP GhcPs
n) = do
    GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XVar GhcPs -> LIdP GhcPs -> HsExpr GhcPs
forall p. XVar p -> LIdP p -> HsExpr p
HsVar XVar GhcPs
x LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n')
  exact x :: HsExpr GhcPs
x@(HsUnboundVar XUnboundVar GhcPs
an RdrName
_) = do
    case XUnboundVar GhcPs
an of
      XUnboundVar GhcPs
EpAnn EpAnnUnboundVar
EpAnnNotUsed -> HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr HsExpr GhcPs
x
      EpAnn Anchor
_ (EpAnnUnboundVar (EpaLocation
ob,EpaLocation
cb) EpaLocation
l) EpAnnComments
_ -> do
        EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
ob String
"`" EP w m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
l  String
"_" EP w m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA EpaLocation
cb String
"`" EP w m EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcPs
x
  exact x :: HsExpr GhcPs
x@(HsOverLabel XOverLabel GhcPs
an SourceText
src FastString
l) = do
    let str :: String
str = String
"#" String -> ShowS
forall a. [a] -> [a] -> [a]
++ case SourceText
src of
              SourceText
NoSourceText   -> (FastString -> String
unpackFS FastString
l)
              SourceText String
txt -> String
txt
    case XOverLabel GhcPs
an of
      XOverLabel GhcPs
EpAnn NoEpAnns
EpAnnNotUsed -> Bool -> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> String -> EP w m ()
printString Bool
True String
str
      EpAnn Anchor
anc NoEpAnns
_ EpAnnComments
_ -> do
        GenLocated SrcSpan FastString
_ <- GenLocated SrcSpan FastString
-> EP w m (GenLocated SrcSpan FastString)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated (SrcSpan -> FastString -> GenLocated SrcSpan FastString
forall l e. l -> e -> GenLocated l e
L (RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan (Anchor -> RealSrcSpan
anchor Anchor
anc) Maybe BufSpan
forall a. Maybe a
Strict.Nothing) (String -> FastString
fsLit String
str))
        () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcPs
x

  exact x :: HsExpr GhcPs
x@(HsIPVar XIPVar GhcPs
_ (HsIPName FastString
n))
    = String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance (String
"?" String -> ShowS
forall a. [a] -> [a] -> [a]
++ FastString -> String
unpackFS FastString
n) RWST (EPOptions m w) (EPWriter w) EPState m ()
-> EP w m (HsExpr GhcPs) -> EP w m (HsExpr GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcPs
x

  exact x :: HsExpr GhcPs
x@(HsOverLit XOverLitE GhcPs
_an HsOverLit GhcPs
ol) = do
    let str :: SourceText
str = case HsOverLit GhcPs -> OverLitVal
forall p. HsOverLit p -> OverLitVal
ol_val HsOverLit GhcPs
ol of
                HsIntegral   (IL SourceText
src Bool
_ Integer
_) -> SourceText
src
                HsFractional (FL { fl_text :: FractionalLit -> SourceText
fl_text = SourceText
src }) -> SourceText
src
                HsIsString SourceText
src FastString
_          -> SourceText
src
    case SourceText
str of
      SourceText String
s -> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance String
s RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      SourceText
NoSourceText -> HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr HsExpr GhcPs
x EP w m (HsExpr GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsExpr GhcPs
x

  exact (HsLit XLitE GhcPs
an HsLit GhcPs
lit) = do
    HsLit GhcPs
lit' <- HsLit GhcPs -> EP w m (HsLit GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr HsLit GhcPs
lit
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XLitE GhcPs -> HsLit GhcPs -> HsExpr GhcPs
forall p. XLitE p -> HsLit p -> HsExpr p
HsLit XLitE GhcPs
an HsLit GhcPs
lit')
  exact (HsLam XLam GhcPs
x MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
mg) = do
    MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
mg' <- MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP
     w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
mg
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XLam GhcPs
-> MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs)) -> HsExpr GhcPs
forall p. XLam p -> MatchGroup p (LHsExpr p) -> HsExpr p
HsLam XLam GhcPs
x MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
mg')

  exact (HsLamCase XLamCase GhcPs
an LamCaseVariant
lc_variant MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
mg) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XLamCase GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnLam
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl (case LamCaseVariant
lc_variant of LamCaseVariant
LamCase -> AnnKeywordId
AnnCase
                                                   LamCaseVariant
LamCases -> AnnKeywordId
AnnCases)
    MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
mg' <- MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP
     w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
mg
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XLamCase GhcPs
-> LamCaseVariant
-> MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
-> HsExpr GhcPs
forall p.
XLamCase p
-> LamCaseVariant -> MatchGroup p (LHsExpr p) -> HsExpr p
HsLamCase XLamCase GhcPs
EpAnn [AddEpAnn]
an1 LamCaseVariant
lc_variant MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
mg')

  exact (HsApp XApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
e1 XRec GhcPs (HsExpr GhcPs)
e2) = do
    Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsApp entered. p=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Pos -> String
forall a. Show a => a -> String
show Pos
p
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XApp GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p. XApp p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsApp XApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2')
  exact (HsAppType XAppTypeE GhcPs
ss XRec GhcPs (HsExpr GhcPs)
fun LHsToken "@" GhcPs
at LHsWcType (NoGhcTc GhcPs)
arg) = do
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
fun' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
fun
    GenLocated TokenLocation (HsToken "@")
at' <- LHsToken "@" GhcPs -> EP w m (LHsToken "@" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "@" GhcPs
at
    HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
arg' <- HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> EP
     w m (HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsWcType (NoGhcTc GhcPs)
HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
arg
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XAppTypeE GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> LHsToken "@" GhcPs
-> LHsWcType (NoGhcTc GhcPs)
-> HsExpr GhcPs
forall p.
XAppTypeE p
-> LHsExpr p -> LHsToken "@" p -> LHsWcType (NoGhcTc p) -> HsExpr p
HsAppType XAppTypeE GhcPs
ss XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
fun' LHsToken "@" GhcPs
GenLocated TokenLocation (HsToken "@")
at' LHsWcType (NoGhcTc GhcPs)
HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
arg')
  exact (OpApp XOpApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
e1 XRec GhcPs (HsExpr GhcPs)
e2 XRec GhcPs (HsExpr GhcPs)
e3) = do
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e3' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e3
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XOpApp GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p.
XOpApp p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
OpApp XOpApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e3')

  exact (NegApp XNegApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
e SyntaxExpr GhcPs
s) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XNegApp GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnMinus
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XNegApp GhcPs
-> XRec GhcPs (HsExpr GhcPs) -> SyntaxExpr GhcPs -> HsExpr GhcPs
forall p. XNegApp p -> LHsExpr p -> SyntaxExpr p -> HsExpr p
NegApp XNegApp GhcPs
EpAnn [AddEpAnn]
an0 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' SyntaxExpr GhcPs
s)

  exact (HsPar XPar GhcPs
an LHsToken "(" GhcPs
lpar XRec GhcPs (HsExpr GhcPs)
e LHsToken ")" GhcPs
rpar) = do
    GenLocated TokenLocation (HsToken "(")
lpar' <- LHsToken "(" GhcPs -> EP w m (LHsToken "(" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "(" GhcPs
lpar
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsPar closing paren"
    GenLocated TokenLocation (HsToken ")")
rpar' <- LHsToken ")" GhcPs -> EP w m (LHsToken ")" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken ")" GhcPs
rpar
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsPar done"
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XPar GhcPs
-> LHsToken "(" GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> LHsToken ")" GhcPs
-> HsExpr GhcPs
forall p.
XPar p -> LHsToken "(" p -> LHsExpr p -> LHsToken ")" p -> HsExpr p
HsPar XPar GhcPs
an LHsToken "(" GhcPs
GenLocated TokenLocation (HsToken "(")
lpar' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' LHsToken ")" GhcPs
GenLocated TokenLocation (HsToken ")")
rpar')

  exact (SectionL XSectionL GhcPs
an XRec GhcPs (HsExpr GhcPs)
expr XRec GhcPs (HsExpr GhcPs)
op) = do
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
op' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
op
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSectionL GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p. XSectionL p -> LHsExpr p -> LHsExpr p -> HsExpr p
SectionL XSectionL GhcPs
an XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
op')

  exact (SectionR XSectionR GhcPs
an XRec GhcPs (HsExpr GhcPs)
op XRec GhcPs (HsExpr GhcPs)
expr) = do
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
op' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
op
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSectionR GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p. XSectionR p -> LHsExpr p -> LHsExpr p -> HsExpr p
SectionR XSectionR GhcPs
an XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
op' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr')

  exact (ExplicitTuple XExplicitTuple GhcPs
an [HsTupArg GhcPs]
args Boxity
b) = do
    EpAnn [AddEpAnn]
an0 <- if Boxity
b Boxity -> Boxity -> Bool
forall a. Eq a => a -> a -> Bool
== Boxity
Boxed then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XExplicitTuple GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenP
                         else EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XExplicitTuple GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenPH

    [HsTupArg GhcPs]
args' <- (HsTupArg GhcPs
 -> RWST (EPOptions m w) (EPWriter w) EPState m (HsTupArg GhcPs))
-> [HsTupArg GhcPs]
-> RWST (EPOptions m w) (EPWriter w) EPState m [HsTupArg GhcPs]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM HsTupArg GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsTupArg GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [HsTupArg GhcPs]
args

    EpAnn [AddEpAnn]
an1 <- if Boxity
b Boxity -> Boxity -> Bool
forall a. Eq a => a -> a -> Bool
== Boxity
Boxed then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseP
                         else EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClosePH
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"ExplicitTuple done"
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XExplicitTuple GhcPs -> [HsTupArg GhcPs] -> Boxity -> HsExpr GhcPs
forall p. XExplicitTuple p -> [HsTupArg p] -> Boxity -> HsExpr p
ExplicitTuple XExplicitTuple GhcPs
EpAnn [AddEpAnn]
an1 [HsTupArg GhcPs]
args' Boxity
b)

  exact (ExplicitSum XExplicitSum GhcPs
an Int
alt Int
arity XRec GhcPs (HsExpr GhcPs)
expr) = do
    EpAnn AnnExplicitSum
an0 <- EpAnn AnnExplicitSum
-> Lens AnnExplicitSum EpaLocation
-> AnnKeywordId
-> EP w m (EpAnn AnnExplicitSum)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw XExplicitSum GhcPs
EpAnn AnnExplicitSum
an (EpaLocation -> f EpaLocation)
-> AnnExplicitSum -> f AnnExplicitSum
Lens AnnExplicitSum EpaLocation
laesOpen AnnKeywordId
AnnOpenPH
    EpAnn AnnExplicitSum
an1 <- EpAnn AnnExplicitSum
-> Lens AnnExplicitSum [EpaLocation]
-> AnnKeywordId
-> EP w m (EpAnn AnnExplicitSum)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [EpaLocation] -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwAllL EpAnn AnnExplicitSum
an0 ([EpaLocation] -> f [EpaLocation])
-> AnnExplicitSum -> f AnnExplicitSum
Lens AnnExplicitSum [EpaLocation]
laesBarsBefore AnnKeywordId
AnnVbar
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr
    EpAnn AnnExplicitSum
an2 <- EpAnn AnnExplicitSum
-> Lens AnnExplicitSum [EpaLocation]
-> AnnKeywordId
-> EP w m (EpAnn AnnExplicitSum)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [EpaLocation] -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwAllL EpAnn AnnExplicitSum
an1 ([EpaLocation] -> f [EpaLocation])
-> AnnExplicitSum -> f AnnExplicitSum
Lens AnnExplicitSum [EpaLocation]
laesBarsAfter AnnKeywordId
AnnVbar
    EpAnn AnnExplicitSum
an3 <- EpAnn AnnExplicitSum
-> Lens AnnExplicitSum EpaLocation
-> AnnKeywordId
-> EP w m (EpAnn AnnExplicitSum)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw EpAnn AnnExplicitSum
an2 (EpaLocation -> f EpaLocation)
-> AnnExplicitSum -> f AnnExplicitSum
Lens AnnExplicitSum EpaLocation
laesClose AnnKeywordId
AnnClosePH
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XExplicitSum GhcPs
-> Int -> Int -> XRec GhcPs (HsExpr GhcPs) -> HsExpr GhcPs
forall p. XExplicitSum p -> Int -> Int -> LHsExpr p -> HsExpr p
ExplicitSum XExplicitSum GhcPs
EpAnn AnnExplicitSum
an3 Int
alt Int
arity XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr')

  exact (HsCase XCase GhcPs
an XRec GhcPs (HsExpr GhcPs)
e MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
alts) = do
    EpAnn EpAnnHsCase
an0 <- EpAnn EpAnnHsCase
-> Lens EpAnnHsCase EpaLocation
-> AnnKeywordId
-> EP w m (EpAnn EpAnnHsCase)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwL XCase GhcPs
EpAnn EpAnnHsCase
an (EpaLocation -> f EpaLocation) -> EpAnnHsCase -> f EpAnnHsCase
Lens EpAnnHsCase EpaLocation
lhsCaseAnnCase AnnKeywordId
AnnCase
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
    EpAnn EpAnnHsCase
an1 <- EpAnn EpAnnHsCase
-> Lens EpAnnHsCase EpaLocation
-> AnnKeywordId
-> EP w m (EpAnn EpAnnHsCase)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwL EpAnn EpAnnHsCase
an0 (EpaLocation -> f EpaLocation) -> EpAnnHsCase -> f EpAnnHsCase
Lens EpAnnHsCase EpaLocation
lhsCaseAnnOf AnnKeywordId
AnnOf
    EpAnn EpAnnHsCase
an2 <- EpAnn EpAnnHsCase
-> Lens EpAnnHsCase [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn EpAnnHsCase)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn EpAnnHsCase
an1 ([AddEpAnn] -> f [AddEpAnn]) -> EpAnnHsCase -> f EpAnnHsCase
Lens EpAnnHsCase [AddEpAnn]
lhsCaseAnnsRest AnnKeywordId
AnnOpenC
    EpAnn EpAnnHsCase
an3 <- EpAnn EpAnnHsCase
-> Lens EpAnnHsCase [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn EpAnnHsCase)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn EpAnnHsCase
an2 ([AddEpAnn] -> f [AddEpAnn]) -> EpAnnHsCase -> f EpAnnHsCase
Lens EpAnnHsCase [AddEpAnn]
lhsCaseAnnsRest AnnKeywordId
AnnSemi
    MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
alts' <- EP w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
-> EP
     w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutBoth (EP w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
 -> EP
      w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))))
-> EP
     w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
-> EP
     w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall a b. (a -> b) -> a -> b
$ MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP
     w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
alts
    EpAnn EpAnnHsCase
an4 <- EpAnn EpAnnHsCase
-> Lens EpAnnHsCase [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn EpAnnHsCase)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn EpAnnHsCase
an3 ([AddEpAnn] -> f [AddEpAnn]) -> EpAnnHsCase -> f EpAnnHsCase
Lens EpAnnHsCase [AddEpAnn]
lhsCaseAnnsRest AnnKeywordId
AnnCloseC
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCase GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
-> HsExpr GhcPs
forall p.
XCase p -> LHsExpr p -> MatchGroup p (LHsExpr p) -> HsExpr p
HsCase XCase GhcPs
EpAnn EpAnnHsCase
an4 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' MatchGroup GhcPs (XRec GhcPs (HsExpr GhcPs))
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
alts')

  exact (HsIf XIf GhcPs
an XRec GhcPs (HsExpr GhcPs)
e1 XRec GhcPs (HsExpr GhcPs)
e2 XRec GhcPs (HsExpr GhcPs)
e3) = do
    EpAnn AnnsIf
an0 <- EpAnn AnnsIf
-> Lens AnnsIf EpaLocation -> AnnKeywordId -> EP w m (EpAnn AnnsIf)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwL XIf GhcPs
EpAnn AnnsIf
an (EpaLocation -> f EpaLocation) -> AnnsIf -> f AnnsIf
Lens AnnsIf EpaLocation
laiIf AnnKeywordId
AnnIf
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1
    EpAnn AnnsIf
an1 <- EpAnn AnnsIf
-> Lens AnnsIf (Maybe EpaLocation)
-> AnnKeywordId
-> EP w m (EpAnn AnnsIf)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a (Maybe EpaLocation) -> AnnKeywordId -> EP w m (EpAnn a)
markLensKwM EpAnn AnnsIf
an0 (Maybe EpaLocation -> f (Maybe EpaLocation)) -> AnnsIf -> f AnnsIf
Lens AnnsIf (Maybe EpaLocation)
laiThenSemi AnnKeywordId
AnnSemi
    EpAnn AnnsIf
an2 <- EpAnn AnnsIf
-> Lens AnnsIf EpaLocation -> AnnKeywordId -> EP w m (EpAnn AnnsIf)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwL EpAnn AnnsIf
an1 (EpaLocation -> f EpaLocation) -> AnnsIf -> f AnnsIf
Lens AnnsIf EpaLocation
laiThen AnnKeywordId
AnnThen
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2
    EpAnn AnnsIf
an3 <- EpAnn AnnsIf
-> Lens AnnsIf (Maybe EpaLocation)
-> AnnKeywordId
-> EP w m (EpAnn AnnsIf)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a (Maybe EpaLocation) -> AnnKeywordId -> EP w m (EpAnn a)
markLensKwM EpAnn AnnsIf
an2 (Maybe EpaLocation -> f (Maybe EpaLocation)) -> AnnsIf -> f AnnsIf
Lens AnnsIf (Maybe EpaLocation)
laiElseSemi AnnKeywordId
AnnSemi
    EpAnn AnnsIf
an4 <- EpAnn AnnsIf
-> Lens AnnsIf EpaLocation -> AnnKeywordId -> EP w m (EpAnn AnnsIf)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwL EpAnn AnnsIf
an3 (EpaLocation -> f EpaLocation) -> AnnsIf -> f AnnsIf
Lens AnnsIf EpaLocation
laiElse AnnKeywordId
AnnElse
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e3' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e3
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIf GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p. XIf p -> LHsExpr p -> LHsExpr p -> LHsExpr p -> HsExpr p
HsIf XIf GhcPs
EpAnn AnnsIf
an4 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e3')

  exact (HsMultiIf XMultiIf GhcPs
an [LGRHS GhcPs (XRec GhcPs (HsExpr GhcPs))]
mg) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XMultiIf GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnIf
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC -- optional
    [GenLocated
   (SrcAnn NoEpAnns)
   (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
mg' <- [GenLocated
   (SrcAnn NoEpAnns)
   (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     [GenLocated
        (SrcAnn NoEpAnns)
        (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LGRHS GhcPs (XRec GhcPs (HsExpr GhcPs))]
[GenLocated
   (SrcAnn NoEpAnns)
   (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
mg
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC -- optional
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XMultiIf GhcPs
-> [LGRHS GhcPs (XRec GhcPs (HsExpr GhcPs))] -> HsExpr GhcPs
forall p. XMultiIf p -> [LGRHS p (LHsExpr p)] -> HsExpr p
HsMultiIf XMultiIf GhcPs
EpAnn [AddEpAnn]
an2 [LGRHS GhcPs (XRec GhcPs (HsExpr GhcPs))]
[GenLocated
   (SrcAnn NoEpAnns)
   (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
mg')

  exact (HsLet XLet GhcPs
an LHsToken "let" GhcPs
tkLet HsLocalBinds GhcPs
binds LHsToken "in" GhcPs
tkIn XRec GhcPs (HsExpr GhcPs)
e) = do
    EP w m (HsExpr GhcPs) -> EP w m (HsExpr GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutBoth (EP w m (HsExpr GhcPs) -> EP w m (HsExpr GhcPs))
-> EP w m (HsExpr GhcPs) -> EP w m (HsExpr GhcPs)
forall a b. (a -> b) -> a -> b
$ do -- Make sure the 'in' gets indented too
      GenLocated TokenLocation (HsToken "let")
tkLet' <- LHsToken "let" GhcPs -> EP w m (LHsToken "let" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "let" GhcPs
tkLet
      String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HSlet:binds coming"
      HsLocalBinds GhcPs
binds' <- EP w m (HsLocalBinds GhcPs) -> EP w m (HsLocalBinds GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutBoth (EP w m (HsLocalBinds GhcPs) -> EP w m (HsLocalBinds GhcPs))
-> EP w m (HsLocalBinds GhcPs) -> EP w m (HsLocalBinds GhcPs)
forall a b. (a -> b) -> a -> b
$ HsLocalBinds GhcPs -> EP w m (HsLocalBinds GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsLocalBinds GhcPs
binds
      String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HSlet:binds done"
      GenLocated TokenLocation (HsToken "in")
tkIn' <- LHsToken "in" GhcPs -> EP w m (LHsToken "in" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "in" GhcPs
tkIn
      String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HSlet:expr coming"
      GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
      HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XLet GhcPs
-> LHsToken "let" GhcPs
-> HsLocalBinds GhcPs
-> LHsToken "in" GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> HsExpr GhcPs
forall p.
XLet p
-> LHsToken "let" p
-> HsLocalBinds p
-> LHsToken "in" p
-> LHsExpr p
-> HsExpr p
HsLet XLet GhcPs
an LHsToken "let" GhcPs
GenLocated TokenLocation (HsToken "let")
tkLet' HsLocalBinds GhcPs
binds' LHsToken "in" GhcPs
GenLocated TokenLocation (HsToken "in")
tkIn' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e')

  exact (HsDo XDo GhcPs
an HsDoFlavour
do_or_list_comp XRec GhcPs [GuardLStmt GhcPs]
stmts) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsDo"
    (EpAnn AnnList
an',LocatedL
  [GenLocated
     SrcSpanAnnA
     (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts') <- Bool
-> EpAnn AnnList
-> (EpAnn AnnList
    -> EP
         w
         m
         (EpAnn AnnList,
          LocatedL
            [GenLocated
               SrcSpanAnnA
               (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]))
-> EP
     w
     m
     (EpAnn AnnList,
      LocatedL
        [GenLocated
           SrcSpanAnnA
           (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool
-> EpAnn AnnList
-> (EpAnn AnnList -> EP w m (EpAnn AnnList, a))
-> EP w m (EpAnn AnnList, a)
markAnnListA Bool
True XDo GhcPs
EpAnn AnnList
an ((EpAnn AnnList
  -> EP
       w
       m
       (EpAnn AnnList,
        LocatedL
          [GenLocated
             SrcSpanAnnA
             (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]))
 -> EP
      w
      m
      (EpAnn AnnList,
       LocatedL
         [GenLocated
            SrcSpanAnnA
            (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]))
-> (EpAnn AnnList
    -> EP
         w
         m
         (EpAnn AnnList,
          LocatedL
            [GenLocated
               SrcSpanAnnA
               (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]))
-> EP
     w
     m
     (EpAnn AnnList,
      LocatedL
        [GenLocated
           SrcSpanAnnA
           (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))])
forall a b. (a -> b) -> a -> b
$ \EpAnn AnnList
a -> EpAnn AnnList
-> HsDoFlavour
-> LocatedL
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     (EpAnn AnnList,
      LocatedL
        [GenLocated
           SrcSpanAnnA
           (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))])
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
EpAnn AnnList
-> HsDoFlavour
-> LocatedAn an a
-> EP w m (EpAnn AnnList, LocatedAn an a)
exactDo EpAnn AnnList
a HsDoFlavour
do_or_list_comp XRec GhcPs [GuardLStmt GhcPs]
LocatedL
  [GenLocated
     SrcSpanAnnA
     (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XDo GhcPs
-> HsDoFlavour -> XRec GhcPs [GuardLStmt GhcPs] -> HsExpr GhcPs
forall p. XDo p -> HsDoFlavour -> XRec p [ExprLStmt p] -> HsExpr p
HsDo XDo GhcPs
EpAnn AnnList
an' HsDoFlavour
do_or_list_comp XRec GhcPs [GuardLStmt GhcPs]
LocatedL
  [GenLocated
     SrcSpanAnnA
     (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts')

  exact (ExplicitList XExplicitList GhcPs
an [XRec GhcPs (HsExpr GhcPs)]
es) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"ExplicitList start"
    EpAnn AnnList
an0 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA XExplicitList GhcPs
EpAnn AnnList
an (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_open
    [GenLocated SrcSpanAnnA (HsExpr GhcPs)]
es' <- [GenLocated SrcSpanAnnA (HsExpr GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsExpr GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [XRec GhcPs (HsExpr GhcPs)]
[GenLocated SrcSpanAnnA (HsExpr GhcPs)]
es
    EpAnn AnnList
an1 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn AnnList
an0 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_close
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"ExplicitList end"
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XExplicitList GhcPs -> [XRec GhcPs (HsExpr GhcPs)] -> HsExpr GhcPs
forall p. XExplicitList p -> [LHsExpr p] -> HsExpr p
ExplicitList XExplicitList GhcPs
EpAnn AnnList
an1 [XRec GhcPs (HsExpr GhcPs)]
[GenLocated SrcSpanAnnA (HsExpr GhcPs)]
es')
  exact (RecordCon XRecordCon GhcPs
an XRec GhcPs (ConLikeP GhcPs)
con_id HsRecordBinds GhcPs
binds) = do
    GenLocated SrcSpanAnnN RdrName
con_id' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (ConLikeP GhcPs)
GenLocated SrcSpanAnnN RdrName
con_id
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XRecordCon GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC
    HsRecFields GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
binds' <- HsRecFields GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP
     w m (HsRecFields GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsRecordBinds GhcPs
HsRecFields GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
binds
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XRecordCon GhcPs
-> XRec GhcPs (ConLikeP GhcPs)
-> HsRecordBinds GhcPs
-> HsExpr GhcPs
forall p.
XRecordCon p -> XRec p (ConLikeP p) -> HsRecordBinds p -> HsExpr p
RecordCon XRecordCon GhcPs
EpAnn [AddEpAnn]
an1 XRec GhcPs (ConLikeP GhcPs)
GenLocated SrcSpanAnnN RdrName
con_id' HsRecordBinds GhcPs
HsRecFields GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
binds')
  exact (RecordUpd XRecordUpd GhcPs
an XRec GhcPs (HsExpr GhcPs)
expr Either [LHsRecUpdField GhcPs] [LHsRecUpdProj GhcPs]
fields) = do
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XRecordUpd GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC
    Either
  [GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
        (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
  [GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
        (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
fields' <- Either
  [GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
        (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
  [GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
        (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     (Either
        [GenLocated
           SrcSpanAnnA
           (HsFieldBind
              (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
              (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
        [GenLocated
           SrcSpanAnnA
           (HsFieldBind
              (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
              (GenLocated SrcSpanAnnA (HsExpr GhcPs)))])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Either [LHsRecUpdField GhcPs] [LHsRecUpdProj GhcPs]
Either
  [GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
        (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
  [GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
        (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
fields
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XRecordUpd GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> Either [LHsRecUpdField GhcPs] [LHsRecUpdProj GhcPs]
-> HsExpr GhcPs
forall p.
XRecordUpd p
-> LHsExpr p
-> Either [LHsRecUpdField p] [LHsRecUpdProj p]
-> HsExpr p
RecordUpd XRecordUpd GhcPs
EpAnn [AddEpAnn]
an1 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' Either [LHsRecUpdField GhcPs] [LHsRecUpdProj GhcPs]
Either
  [GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
        (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
  [GenLocated
     SrcSpanAnnA
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
        (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
fields')
  exact (HsGetField XGetField GhcPs
an XRec GhcPs (HsExpr GhcPs)
expr XRec GhcPs (DotFieldOcc GhcPs)
field) = do
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr
    GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)
field' <- GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (DotFieldOcc GhcPs)
GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)
field
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XGetField GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (DotFieldOcc GhcPs)
-> HsExpr GhcPs
forall p.
XGetField p -> LHsExpr p -> XRec p (DotFieldOcc p) -> HsExpr p
HsGetField XGetField GhcPs
an XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' XRec GhcPs (DotFieldOcc GhcPs)
GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)
field')
  exact (HsProjection XProjection GhcPs
an NonEmpty (XRec GhcPs (DotFieldOcc GhcPs))
flds) = do
    EpAnn AnnProjection
an0 <- EpAnn AnnProjection
-> Lens AnnProjection EpaLocation
-> AnnKeywordId
-> EP w m (EpAnn AnnProjection)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwL XProjection GhcPs
EpAnn AnnProjection
an (EpaLocation -> f EpaLocation) -> AnnProjection -> f AnnProjection
Lens AnnProjection EpaLocation
lapOpen AnnKeywordId
AnnOpenP
    NonEmpty (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs))
flds' <- (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)
 -> EP w m (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)))
-> NonEmpty (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (NonEmpty (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> NonEmpty a -> m (NonEmpty b)
mapM GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated NonEmpty (XRec GhcPs (DotFieldOcc GhcPs))
NonEmpty (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs))
flds
    EpAnn AnnProjection
an1 <- EpAnn AnnProjection
-> Lens AnnProjection EpaLocation
-> AnnKeywordId
-> EP w m (EpAnn AnnProjection)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwL EpAnn AnnProjection
an0 (EpaLocation -> f EpaLocation) -> AnnProjection -> f AnnProjection
Lens AnnProjection EpaLocation
lapClose AnnKeywordId
AnnCloseP
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XProjection GhcPs
-> NonEmpty (XRec GhcPs (DotFieldOcc GhcPs)) -> HsExpr GhcPs
forall p.
XProjection p -> NonEmpty (XRec p (DotFieldOcc p)) -> HsExpr p
HsProjection XProjection GhcPs
EpAnn AnnProjection
an1 NonEmpty (XRec GhcPs (DotFieldOcc GhcPs))
NonEmpty (GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs))
flds')
  exact (ExprWithTySig XExprWithTySig GhcPs
an XRec GhcPs (HsExpr GhcPs)
expr LHsSigWcType (NoGhcTc GhcPs)
sig) = do
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XExprWithTySig GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
    HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
sig' <- HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
-> EP
     w
     m
     (HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsSigWcType (NoGhcTc GhcPs)
HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
sig
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XExprWithTySig GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> LHsSigWcType (NoGhcTc GhcPs)
-> HsExpr GhcPs
forall p.
XExprWithTySig p
-> LHsExpr p -> LHsSigWcType (NoGhcTc p) -> HsExpr p
ExprWithTySig XExprWithTySig GhcPs
EpAnn [AddEpAnn]
an0 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' LHsSigWcType (NoGhcTc GhcPs)
HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
sig')
  exact (ArithSeq XArithSeq GhcPs
an Maybe (SyntaxExpr GhcPs)
s ArithSeqInfo GhcPs
seqInfo) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XArithSeq GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenS -- '['
    (EpAnn [AddEpAnn]
an1, ArithSeqInfo GhcPs
seqInfo') <-
      case ArithSeqInfo GhcPs
seqInfo of
        From XRec GhcPs (HsExpr GhcPs)
e -> do
          GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
          EpAnn [AddEpAnn]
an' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDotdot
          (EpAnn [AddEpAnn], ArithSeqInfo GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], ArithSeqInfo GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an', XRec GhcPs (HsExpr GhcPs) -> ArithSeqInfo GhcPs
forall id. LHsExpr id -> ArithSeqInfo id
From XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e')
        FromTo XRec GhcPs (HsExpr GhcPs)
e1 XRec GhcPs (HsExpr GhcPs)
e2 -> do
          GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1
          EpAnn [AddEpAnn]
an' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDotdot
          GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2
          (EpAnn [AddEpAnn], ArithSeqInfo GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], ArithSeqInfo GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an', XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs) -> ArithSeqInfo GhcPs
forall id. LHsExpr id -> LHsExpr id -> ArithSeqInfo id
FromTo XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2')
        FromThen XRec GhcPs (HsExpr GhcPs)
e1 XRec GhcPs (HsExpr GhcPs)
e2 -> do
          GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1
          EpAnn [AddEpAnn]
an' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnComma
          GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2
          EpAnn [AddEpAnn]
an'' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDotdot
          (EpAnn [AddEpAnn], ArithSeqInfo GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], ArithSeqInfo GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an'', XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs) -> ArithSeqInfo GhcPs
forall id. LHsExpr id -> LHsExpr id -> ArithSeqInfo id
FromThen XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2')
        FromThenTo XRec GhcPs (HsExpr GhcPs)
e1 XRec GhcPs (HsExpr GhcPs)
e2 XRec GhcPs (HsExpr GhcPs)
e3 -> do
          GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1
          EpAnn [AddEpAnn]
an' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnComma
          GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2
          EpAnn [AddEpAnn]
an'' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDotdot
          GenLocated SrcSpanAnnA (HsExpr GhcPs)
e3' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e3
          (EpAnn [AddEpAnn], ArithSeqInfo GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], ArithSeqInfo GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an'', XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> ArithSeqInfo GhcPs
forall id.
LHsExpr id -> LHsExpr id -> LHsExpr id -> ArithSeqInfo id
FromThenTo XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e3')
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseS -- ']'
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XArithSeq GhcPs
-> Maybe (SyntaxExpr GhcPs) -> ArithSeqInfo GhcPs -> HsExpr GhcPs
forall p.
XArithSeq p -> Maybe (SyntaxExpr p) -> ArithSeqInfo p -> HsExpr p
ArithSeq XArithSeq GhcPs
EpAnn [AddEpAnn]
an2 Maybe (SyntaxExpr GhcPs)
s ArithSeqInfo GhcPs
seqInfo')


  exact (HsTypedBracket XTypedBracket GhcPs
an XRec GhcPs (HsExpr GhcPs)
e) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS XTypedBracket GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpen (String -> Maybe String
forall a. a -> Maybe a
Just String
"[||")
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenE (String -> Maybe String
forall a. a -> Maybe a
Just String
"[e||")
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"||]")
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XTypedBracket GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsExpr GhcPs
forall p. XTypedBracket p -> LHsExpr p -> HsExpr p
HsTypedBracket XTypedBracket GhcPs
EpAnn [AddEpAnn]
an2 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e')

  exact (HsUntypedBracket XUntypedBracket GhcPs
an (ExpBr XExpBr GhcPs
a XRec GhcPs (HsExpr GhcPs)
e)) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an  ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenEQ -- "[|"
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenE  -- "[e|" -- optional
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseQ -- "|]"
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XUntypedBracket GhcPs -> HsQuote GhcPs -> HsExpr GhcPs
forall p. XUntypedBracket p -> HsQuote p -> HsExpr p
HsUntypedBracket XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an2 (XExpBr GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsQuote GhcPs
forall p. XExpBr p -> LHsExpr p -> HsQuote p
ExpBr XExpBr GhcPs
a XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e'))

  exact (HsUntypedBracket XUntypedBracket GhcPs
an (PatBr XPatBr GhcPs
a LPat GhcPs
e)) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpen (String -> Maybe String
forall a. a -> Maybe a
Just String
"[p|")
    GenLocated SrcSpanAnnA (Pat GhcPs)
e' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
e
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseQ -- "|]"
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XUntypedBracket GhcPs -> HsQuote GhcPs -> HsExpr GhcPs
forall p. XUntypedBracket p -> HsQuote p -> HsExpr p
HsUntypedBracket XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an1 (XPatBr GhcPs -> LPat GhcPs -> HsQuote GhcPs
forall p. XPatBr p -> LPat p -> HsQuote p
PatBr XPatBr GhcPs
a LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
e'))

  exact (HsUntypedBracket XUntypedBracket GhcPs
an (DecBrL XDecBrL GhcPs
a [LHsDecl GhcPs]
e)) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpen (String -> Maybe String
forall a. a -> Maybe a
Just String
"[d|")
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC
    [GenLocated SrcSpanAnnA (HsDecl GhcPs)]
e' <- [GenLocated SrcSpanAnnA (HsDecl GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsDecl GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsDecl GhcPs]
[GenLocated SrcSpanAnnA (HsDecl GhcPs)]
e
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC
    EpAnn [AddEpAnn]
an3 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an2 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseQ -- "|]"
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XUntypedBracket GhcPs -> HsQuote GhcPs -> HsExpr GhcPs
forall p. XUntypedBracket p -> HsQuote p -> HsExpr p
HsUntypedBracket XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an3 (XDecBrL GhcPs -> [LHsDecl GhcPs] -> HsQuote GhcPs
forall p. XDecBrL p -> [LHsDecl p] -> HsQuote p
DecBrL XDecBrL GhcPs
a [LHsDecl GhcPs]
[GenLocated SrcSpanAnnA (HsDecl GhcPs)]
e'))

  exact (HsUntypedBracket XUntypedBracket GhcPs
an (TypBr XTypBr GhcPs
a LHsType GhcPs
e)) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpen (String -> Maybe String
forall a. a -> Maybe a
Just String
"[t|")
    GenLocated SrcSpanAnnA (HsType GhcPs)
e' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
e
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseQ -- "|]"
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XUntypedBracket GhcPs -> HsQuote GhcPs -> HsExpr GhcPs
forall p. XUntypedBracket p -> HsQuote p -> HsExpr p
HsUntypedBracket XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an1 (XTypBr GhcPs -> LHsType GhcPs -> HsQuote GhcPs
forall p. XTypBr p -> LHsType p -> HsQuote p
TypBr XTypBr GhcPs
a LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
e'))

  exact (HsUntypedBracket XUntypedBracket GhcPs
an (VarBr XVarBr GhcPs
a Bool
b LIdP GhcPs
e)) = do
    (EpAnn [AddEpAnn]
an0, GenLocated SrcSpanAnnN RdrName
e') <- if Bool
b
      then do
        EpAnn [AddEpAnn]
an' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnSimpleQuote
        GenLocated SrcSpanAnnN RdrName
e' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
e
        (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an', GenLocated SrcSpanAnnN RdrName
e')
      else do
        EpAnn [AddEpAnn]
an' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnThTyQuote
        GenLocated SrcSpanAnnN RdrName
e' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
e
        (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an', GenLocated SrcSpanAnnN RdrName
e')
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XUntypedBracket GhcPs -> HsQuote GhcPs -> HsExpr GhcPs
forall p. XUntypedBracket p -> HsQuote p -> HsExpr p
HsUntypedBracket XUntypedBracket GhcPs
EpAnn [AddEpAnn]
an0 (XVarBr GhcPs -> Bool -> LIdP GhcPs -> HsQuote GhcPs
forall p. XVarBr p -> Bool -> LIdP p -> HsQuote p
VarBr XVarBr GhcPs
a Bool
b LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
e'))

  exact (HsTypedSplice (EpAnn NoEpAnns
x,EpAnn [AddEpAnn]
an) XRec GhcPs (HsExpr GhcPs)
s)   = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDollarDollar
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
s' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall a (m :: * -> *) w.
(ExactPrint a, Monad m, Monoid w) =>
a -> EP w m a
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
exact XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
s
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XTypedSplice GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsExpr GhcPs
forall p. XTypedSplice p -> LHsExpr p -> HsExpr p
HsTypedSplice (EpAnn NoEpAnns
x,EpAnn [AddEpAnn]
an0) XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
s')
  exact (HsUntypedSplice XUntypedSplice GhcPs
an HsUntypedSplice GhcPs
s) = do
    HsUntypedSplice GhcPs
s' <- HsUntypedSplice GhcPs -> EP w m (HsUntypedSplice GhcPs)
forall a (m :: * -> *) w.
(ExactPrint a, Monad m, Monoid w) =>
a -> EP w m a
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsUntypedSplice GhcPs -> EP w m (HsUntypedSplice GhcPs)
exact HsUntypedSplice GhcPs
s
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XUntypedSplice GhcPs -> HsUntypedSplice GhcPs -> HsExpr GhcPs
forall p. XUntypedSplice p -> HsUntypedSplice p -> HsExpr p
HsUntypedSplice XUntypedSplice GhcPs
an HsUntypedSplice GhcPs
s')

  exact (HsProc XProc GhcPs
an LPat GhcPs
p LHsCmdTop GhcPs
c) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsProc start"
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XProc GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnProc
    GenLocated SrcSpanAnnA (Pat GhcPs)
p' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
p
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnRarrow
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsProc after AnnRarrow"
    GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)
c' <- GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsCmdTop GhcPs
GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)
c
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XProc GhcPs -> LPat GhcPs -> LHsCmdTop GhcPs -> HsExpr GhcPs
forall p. XProc p -> LPat p -> LHsCmdTop p -> HsExpr p
HsProc XProc GhcPs
EpAnn [AddEpAnn]
an1 LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
p' LHsCmdTop GhcPs
GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)
c')

  exact (HsStatic XStatic GhcPs
an XRec GhcPs (HsExpr GhcPs)
e) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XStatic GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnStatic
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XStatic GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsExpr GhcPs
forall p. XStatic p -> LHsExpr p -> HsExpr p
HsStatic XStatic GhcPs
EpAnn [AddEpAnn]
an0 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e')

  exact (HsPragE XPragE GhcPs
a HsPragE GhcPs
prag XRec GhcPs (HsExpr GhcPs)
e) = do
    HsPragE GhcPs
prag' <- HsPragE GhcPs -> EP w m (HsPragE GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsPragE GhcPs
prag
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
    HsExpr GhcPs -> EP w m (HsExpr GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XPragE GhcPs
-> HsPragE GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsExpr GhcPs
forall p. XPragE p -> HsPragE p -> LHsExpr p -> HsExpr p
HsPragE XPragE GhcPs
a HsPragE GhcPs
prag' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e')
  exact HsExpr GhcPs
x = String -> EP w m (HsExpr GhcPs)
forall a. HasCallStack => String -> a
error (String -> EP w m (HsExpr GhcPs))
-> String -> EP w m (HsExpr GhcPs)
forall a b. (a -> b) -> a -> b
$ String
"exact HsExpr for:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ HsExpr GhcPs -> String
forall a. Data a => a -> String
showAst HsExpr GhcPs
x

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

exactDo :: (Monad m, Monoid w, ExactPrint (LocatedAn an a))
        => EpAnn AnnList -> HsDoFlavour -> LocatedAn an a
        -> EP w m (EpAnn AnnList, LocatedAn an a)
exactDo :: forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
EpAnn AnnList
-> HsDoFlavour
-> LocatedAn an a
-> EP w m (EpAnn AnnList, LocatedAn an a)
exactDo EpAnn AnnList
an (DoExpr Maybe ModuleName
m)    LocatedAn an a
stmts = EpAnn AnnList
-> Maybe ModuleName -> AnnKeywordId -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnList
-> Maybe ModuleName -> AnnKeywordId -> EP w m (EpAnn AnnList)
exactMdo EpAnn AnnList
an Maybe ModuleName
m AnnKeywordId
AnnDo          EP w m (EpAnn AnnList)
-> (EpAnn AnnList
    -> RWST
         (EPOptions m w)
         (EPWriter w)
         EPState
         m
         (EpAnn AnnList, LocatedAn an a))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnList, LocatedAn an a)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> (a -> RWST (EPOptions m w) (EPWriter w) EPState m b)
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \EpAnn AnnList
an0 -> EpAnn AnnList
-> LocatedAn an a
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnList, LocatedAn an a)
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
EpAnn AnnList
-> LocatedAn an a -> EP w m (EpAnn AnnList, LocatedAn an a)
markMaybeDodgyStmts EpAnn AnnList
an0 LocatedAn an a
stmts
exactDo EpAnn AnnList
an HsDoFlavour
GhciStmtCtxt  LocatedAn an a
stmts = EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn AnnList
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
AnnDo EP w m (EpAnn AnnList)
-> (EpAnn AnnList
    -> RWST
         (EPOptions m w)
         (EPWriter w)
         EPState
         m
         (EpAnn AnnList, LocatedAn an a))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnList, LocatedAn an a)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> (a -> RWST (EPOptions m w) (EPWriter w) EPState m b)
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \EpAnn AnnList
an0 -> EpAnn AnnList
-> LocatedAn an a
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnList, LocatedAn an a)
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
EpAnn AnnList
-> LocatedAn an a -> EP w m (EpAnn AnnList, LocatedAn an a)
markMaybeDodgyStmts EpAnn AnnList
an0 LocatedAn an a
stmts
exactDo EpAnn AnnList
an (MDoExpr Maybe ModuleName
m)   LocatedAn an a
stmts = EpAnn AnnList
-> Maybe ModuleName -> AnnKeywordId -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnList
-> Maybe ModuleName -> AnnKeywordId -> EP w m (EpAnn AnnList)
exactMdo EpAnn AnnList
an Maybe ModuleName
m AnnKeywordId
AnnMdo         EP w m (EpAnn AnnList)
-> (EpAnn AnnList
    -> RWST
         (EPOptions m w)
         (EPWriter w)
         EPState
         m
         (EpAnn AnnList, LocatedAn an a))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnList, LocatedAn an a)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> (a -> RWST (EPOptions m w) (EPWriter w) EPState m b)
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \EpAnn AnnList
an0 -> EpAnn AnnList
-> LocatedAn an a
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnList, LocatedAn an a)
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
EpAnn AnnList
-> LocatedAn an a -> EP w m (EpAnn AnnList, LocatedAn an a)
markMaybeDodgyStmts EpAnn AnnList
an0 LocatedAn an a
stmts
exactDo EpAnn AnnList
an HsDoFlavour
ListComp      LocatedAn an a
stmts = EpAnn AnnList
-> LocatedAn an a
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnList, LocatedAn an a)
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
EpAnn AnnList
-> LocatedAn an a -> EP w m (EpAnn AnnList, LocatedAn an a)
markMaybeDodgyStmts EpAnn AnnList
an LocatedAn an a
stmts
exactDo EpAnn AnnList
an HsDoFlavour
MonadComp     LocatedAn an a
stmts = EpAnn AnnList
-> LocatedAn an a
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn AnnList, LocatedAn an a)
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
EpAnn AnnList
-> LocatedAn an a -> EP w m (EpAnn AnnList, LocatedAn an a)
markMaybeDodgyStmts EpAnn AnnList
an LocatedAn an a
stmts

exactMdo :: (Monad m, Monoid w)
  => EpAnn AnnList -> Maybe ModuleName -> AnnKeywordId -> EP w m (EpAnn AnnList)
exactMdo :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnList
-> Maybe ModuleName -> AnnKeywordId -> EP w m (EpAnn AnnList)
exactMdo EpAnn AnnList
an Maybe ModuleName
Nothing            AnnKeywordId
kw = EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL   EpAnn AnnList
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
kw
exactMdo EpAnn AnnList
an (Just ModuleName
module_name) AnnKeywordId
kw = EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn AnnList
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
kw (String -> Maybe String
forall a. a -> Maybe a
Just String
n)
    where
      n :: String
n = (ModuleName -> String
moduleNameString ModuleName
module_name) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"." String -> ShowS
forall a. [a] -> [a] -> [a]
++ (AnnKeywordId -> String
keywordToString AnnKeywordId
kw)

markMaybeDodgyStmts :: (Monad m, Monoid w, ExactPrint (LocatedAn an a))
  => EpAnn AnnList -> LocatedAn an a -> EP w m (EpAnn AnnList, LocatedAn an a)
markMaybeDodgyStmts :: forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
EpAnn AnnList
-> LocatedAn an a -> EP w m (EpAnn AnnList, LocatedAn an a)
markMaybeDodgyStmts EpAnn AnnList
an LocatedAn an a
stmts =
  if SrcSpan -> Bool
isGoodSrcSpan (LocatedAn an a -> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA LocatedAn an a
stmts)
    then do
      LocatedAn an a
r <- LocatedAn an a -> EP w m (LocatedAn an a)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotatedWithLayout LocatedAn an a
stmts
      (EpAnn AnnList, LocatedAn an a)
-> EP w m (EpAnn AnnList, LocatedAn an a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnList
an, LocatedAn an a
r)
    else (EpAnn AnnList, LocatedAn an a)
-> EP w m (EpAnn AnnList, LocatedAn an a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn AnnList
an, LocatedAn an a
stmts)

-- ---------------------------------------------------------------------
instance ExactPrint (HsPragE GhcPs) where
  getAnnotationEntry :: HsPragE GhcPs -> Entry
getAnnotationEntry HsPragSCC{}  = Entry
NoEntryVal
  setAnnotationAnchor :: HsPragE GhcPs -> Anchor -> EpAnnComments -> HsPragE GhcPs
setAnnotationAnchor HsPragE GhcPs
a Anchor
_ EpAnnComments
_ = HsPragE GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsPragE GhcPs -> EP w m (HsPragE GhcPs)
exact (HsPragSCC (EpAnn AnnPragma
an,SourceText
st) StringLiteral
sl) = do
    EpAnn AnnPragma
an0 <- EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
st String
"{-# SCC"
    let txt :: String
txt = SourceText -> ShowS
sourceTextToString (StringLiteral -> SourceText
sl_st StringLiteral
sl) (FastString -> String
unpackFS (FastString -> String) -> FastString -> String
forall a b. (a -> b) -> a -> b
$ StringLiteral -> FastString
sl_fs StringLiteral
sl)
    EpAnn AnnPragma
an1 <- EpAnn AnnPragma
-> Lens AnnPragma [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn AnnPragma
an0 ([AddEpAnn] -> f [AddEpAnn]) -> AnnPragma -> f AnnPragma
Lens AnnPragma [AddEpAnn]
lapr_rest AnnKeywordId
AnnVal    (String -> Maybe String
forall a. a -> Maybe a
Just String
txt) -- optional
    EpAnn AnnPragma
an2 <- EpAnn AnnPragma
-> Lens AnnPragma [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn AnnPragma
an1 ([AddEpAnn] -> f [AddEpAnn]) -> AnnPragma -> f AnnPragma
Lens AnnPragma [AddEpAnn]
lapr_rest AnnKeywordId
AnnValStr (String -> Maybe String
forall a. a -> Maybe a
Just String
txt) -- optional
    EpAnn AnnPragma
an3 <- EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an2
    HsPragE GhcPs -> EP w m (HsPragE GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSCC GhcPs -> StringLiteral -> HsPragE GhcPs
forall p. XSCC p -> StringLiteral -> HsPragE p
HsPragSCC (EpAnn AnnPragma
an3,SourceText
st) StringLiteral
sl)


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

instance ExactPrint (HsUntypedSplice GhcPs) where
  getAnnotationEntry :: HsUntypedSplice GhcPs -> Entry
getAnnotationEntry (HsUntypedSpliceExpr XUntypedSpliceExpr GhcPs
an XRec GhcPs (HsExpr GhcPs)
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XUntypedSpliceExpr GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsQuasiQuote XQuasiQuote GhcPs
_ IdP GhcPs
_ XRec GhcPs FastString
_)       = Entry
NoEntryVal

  setAnnotationAnchor :: HsUntypedSplice GhcPs
-> Anchor -> EpAnnComments -> HsUntypedSplice GhcPs
setAnnotationAnchor (HsUntypedSpliceExpr XUntypedSpliceExpr GhcPs
an XRec GhcPs (HsExpr GhcPs)
e) Anchor
anc EpAnnComments
cs = XUntypedSpliceExpr GhcPs
-> XRec GhcPs (HsExpr GhcPs) -> HsUntypedSplice GhcPs
forall id.
XUntypedSpliceExpr id -> LHsExpr id -> HsUntypedSplice id
HsUntypedSpliceExpr (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XUntypedSpliceExpr GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
e
  setAnnotationAnchor a :: HsUntypedSplice GhcPs
a@HsQuasiQuote {}         Anchor
_ EpAnnComments
_ = HsUntypedSplice GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsUntypedSplice GhcPs -> EP w m (HsUntypedSplice GhcPs)
exact (HsUntypedSpliceExpr XUntypedSpliceExpr GhcPs
an XRec GhcPs (HsExpr GhcPs)
e) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XUntypedSpliceExpr GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDollar
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
    HsUntypedSplice GhcPs -> EP w m (HsUntypedSplice GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XUntypedSpliceExpr GhcPs
-> XRec GhcPs (HsExpr GhcPs) -> HsUntypedSplice GhcPs
forall id.
XUntypedSpliceExpr id -> LHsExpr id -> HsUntypedSplice id
HsUntypedSpliceExpr XUntypedSpliceExpr GhcPs
EpAnn [AddEpAnn]
an0 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e')

  exact (HsQuasiQuote XQuasiQuote GhcPs
an IdP GhcPs
q (L SrcAnn NoEpAnns
l FastString
fs)) = do
    -- The quasiquote string does not honour layout offsets. Store
    -- the colOffset for now.
    -- TODO: use local?
    LayoutStartCol
oldOffset <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetP
    EPState{Bool
pMarkLayout :: EPState -> Bool
pMarkLayout :: Bool
pMarkLayout} <- RWST (EPOptions m w) (EPWriter w) EPState m EPState
forall s (m :: * -> *). MonadState s m => m s
get
    Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
pMarkLayout (RWST (EPOptions m w) (EPWriter w) EPState m ()
 -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ LayoutStartCol -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LayoutStartCol -> EP w m ()
setLayoutOffsetP LayoutStartCol
0
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance
            -- Note: Lexer.x does not provide unicode alternative. 2017-02-26
            (String
"[" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (RdrName -> String
forall a. Outputable a => a -> String
showPprUnsafe IdP GhcPs
RdrName
q) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"|" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (FastString -> String
unpackFS FastString
fs) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"|]")
    Bool
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
pMarkLayout (RWST (EPOptions m w) (EPWriter w) EPState m ()
 -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ LayoutStartCol -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LayoutStartCol -> EP w m ()
setLayoutOffsetP LayoutStartCol
oldOffset
    HsUntypedSplice GhcPs -> EP w m (HsUntypedSplice GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XQuasiQuote GhcPs
-> IdP GhcPs -> XRec GhcPs FastString -> HsUntypedSplice GhcPs
forall id.
XQuasiQuote id
-> IdP id -> XRec id FastString -> HsUntypedSplice id
HsQuasiQuote XQuasiQuote GhcPs
an IdP GhcPs
q (SrcAnn NoEpAnns
-> FastString -> GenLocated (SrcAnn NoEpAnns) FastString
forall l e. l -> e -> GenLocated l e
L SrcAnn NoEpAnns
l FastString
fs))

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

-- TODO:AZ: combine these instances
instance ExactPrint (MatchGroup GhcPs (LocatedA (HsExpr GhcPs))) where
  getAnnotationEntry :: MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)) -> Entry
getAnnotationEntry = Entry
-> MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> Anchor
-> EpAnnComments
-> MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
setAnnotationAnchor MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
a Anchor
_ EpAnnComments
_ = MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP
     w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
exact (MG XMG GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
x XRec GhcPs [LMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
matches) = do
    -- TODO:AZ use SortKey, in MG ann.
    GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
matches' <- if SrcSpan -> Bool
isGoodSrcSpan (GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA XRec GhcPs [LMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
matches)
      then GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL
        [GenLocated
           SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs [LMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
matches
      else GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL
        [GenLocated
           SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XRec GhcPs [LMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
matches
    MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> EP
     w m (MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XMG GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> XRec
     GhcPs [LMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
-> MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall p body.
XMG p body -> XRec p [LMatch p body] -> MatchGroup p body
MG XMG GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
x XRec GhcPs [LMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
matches')

instance ExactPrint (MatchGroup GhcPs (LocatedA (HsCmd GhcPs))) where
  getAnnotationEntry :: MatchGroup GhcPs (LocatedA (HsCmd GhcPs)) -> Entry
getAnnotationEntry = Entry -> MatchGroup GhcPs (LocatedA (HsCmd GhcPs)) -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
-> Anchor
-> EpAnnComments
-> MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
setAnnotationAnchor MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
a Anchor
_ EpAnnComments
_ = MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (MatchGroup GhcPs (LocatedA (HsCmd GhcPs)))
exact (MG XMG GhcPs (LocatedA (HsCmd GhcPs))
x XRec GhcPs [LMatch GhcPs (LocatedA (HsCmd GhcPs))]
matches) = do
    -- TODO:AZ use SortKey, in MG ann.
    GenLocated
  SrcSpanAnnL
  [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsCmd GhcPs)))]
matches' <- if SrcSpan -> Bool
isGoodSrcSpan (GenLocated
  SrcSpanAnnL
  [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsCmd GhcPs)))]
-> SrcSpan
forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA XRec GhcPs [LMatch GhcPs (LocatedA (HsCmd GhcPs))]
GenLocated
  SrcSpanAnnL
  [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsCmd GhcPs)))]
matches)
      then GenLocated
  SrcSpanAnnL
  [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsCmd GhcPs)))]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL
        [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsCmd GhcPs)))])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs [LMatch GhcPs (LocatedA (HsCmd GhcPs))]
GenLocated
  SrcSpanAnnL
  [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsCmd GhcPs)))]
matches
      else GenLocated
  SrcSpanAnnL
  [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsCmd GhcPs)))]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL
        [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsCmd GhcPs)))])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XRec GhcPs [LMatch GhcPs (LocatedA (HsCmd GhcPs))]
GenLocated
  SrcSpanAnnL
  [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsCmd GhcPs)))]
matches
    MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (MatchGroup GhcPs (LocatedA (HsCmd GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XMG GhcPs (LocatedA (HsCmd GhcPs))
-> XRec GhcPs [LMatch GhcPs (LocatedA (HsCmd GhcPs))]
-> MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
forall p body.
XMG p body -> XRec p [LMatch p body] -> MatchGroup p body
MG XMG GhcPs (LocatedA (HsCmd GhcPs))
x XRec GhcPs [LMatch GhcPs (LocatedA (HsCmd GhcPs))]
GenLocated
  SrcSpanAnnL
  [GenLocated SrcSpanAnnA (Match GhcPs (LocatedA (HsCmd GhcPs)))]
matches')

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

instance (ExactPrint body) => ExactPrint (HsRecFields GhcPs body) where
  getAnnotationEntry :: HsRecFields GhcPs body -> Entry
getAnnotationEntry = Entry -> HsRecFields GhcPs body -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: HsRecFields GhcPs body
-> Anchor -> EpAnnComments -> HsRecFields GhcPs body
setAnnotationAnchor HsRecFields GhcPs body
a Anchor
_ EpAnnComments
_ = HsRecFields GhcPs body
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsRecFields GhcPs body -> EP w m (HsRecFields GhcPs body)
exact (HsRecFields [LHsRecField GhcPs body]
fields Maybe (XRec GhcPs RecFieldsDotDot)
mdot) = do
    [GenLocated
   SrcSpanAnnA
   (HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body)]
fields' <- [GenLocated
   SrcSpanAnnA
   (HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body)]
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA
        (HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsRecField GhcPs body]
[GenLocated
   SrcSpanAnnA
   (HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body)]
fields
    case Maybe (XRec GhcPs RecFieldsDotDot)
mdot of
      Maybe (XRec GhcPs RecFieldsDotDot)
Nothing -> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      Just (L SrcSpan
ss RecFieldsDotDot
_) ->
        SrcSpan -> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SrcSpan -> String -> EP w m ()
printStringAtSs SrcSpan
ss String
".." RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      -- Note: mdot contains the SrcSpan where the ".." appears, if present
    HsRecFields GhcPs body -> EP w m (HsRecFields GhcPs body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([LHsRecField GhcPs body]
-> Maybe (XRec GhcPs RecFieldsDotDot) -> HsRecFields GhcPs body
forall p arg.
[LHsRecField p arg]
-> Maybe (XRec p RecFieldsDotDot) -> HsRecFields p arg
HsRecFields [LHsRecField GhcPs body]
[GenLocated
   SrcSpanAnnA
   (HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body)]
fields' Maybe (XRec GhcPs RecFieldsDotDot)
mdot)

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

instance (ExactPrint body)
    => ExactPrint (HsFieldBind (LocatedAn NoEpAnns (FieldOcc GhcPs)) body) where
  getAnnotationEntry :: HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body
-> Entry
getAnnotationEntry HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body
x = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn (HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body
-> XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
forall lhs rhs. HsFieldBind lhs rhs -> XHsFieldBind lhs
hfbAnn HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body
x)
  setAnnotationAnchor :: HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body
-> Anchor
-> EpAnnComments
-> HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body
setAnnotationAnchor (HsFieldBind XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
an GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
f body
arg Bool
isPun) Anchor
anc EpAnnComments
cs = (XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
-> GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
-> body
-> Bool
-> HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body
forall lhs rhs.
XHsFieldBind lhs -> lhs -> rhs -> Bool -> HsFieldBind lhs rhs
HsFieldBind (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
f body
arg Bool
isPun)
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body
-> EP
     w
     m
     (HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body)
exact (HsFieldBind XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
an GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
f body
arg Bool
isPun) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsFieldBind"
    GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
f' <- GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
f
    (EpAnn [AddEpAnn]
an0, body
arg') <- if Bool
isPun then (EpAnn [AddEpAnn], body)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn], body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
EpAnn [AddEpAnn]
an, body
arg)
             else do
      EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnEqual
      body
arg' <- body -> EP w m body
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated body
arg
      (EpAnn [AddEpAnn], body)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn], body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, body
arg')
    HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body
-> EP
     w
     m
     (HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
-> GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
-> body
-> Bool
-> HsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)) body
forall lhs rhs.
XHsFieldBind lhs -> lhs -> rhs -> Bool -> HsFieldBind lhs rhs
HsFieldBind XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
EpAnn [AddEpAnn]
an0 GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
f' body
arg' Bool
isPun)

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

instance (ExactPrint body)
    => ExactPrint (HsFieldBind (LocatedAn NoEpAnns (FieldLabelStrings GhcPs)) body) where
  getAnnotationEntry :: HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body
-> Entry
getAnnotationEntry HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body
x = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn (HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body
-> XHsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
forall lhs rhs. HsFieldBind lhs rhs -> XHsFieldBind lhs
hfbAnn HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body
x)
  setAnnotationAnchor :: HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body
-> Anchor
-> EpAnnComments
-> HsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body
setAnnotationAnchor (HsFieldBind XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
an GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)
f body
arg Bool
isPun) Anchor
anc EpAnnComments
cs = (XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
-> GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)
-> body
-> Bool
-> HsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body
forall lhs rhs.
XHsFieldBind lhs -> lhs -> rhs -> Bool -> HsFieldBind lhs rhs
HsFieldBind (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)
f body
arg Bool
isPun)

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body
-> EP
     w
     m
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body)
exact (HsFieldBind XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
an GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)
f body
arg Bool
isPun) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsFieldBind FieldLabelStrings"
    GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)
f' <- GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)
f
    (EpAnn [AddEpAnn]
an0, body
arg') <- if Bool
isPun then (EpAnn [AddEpAnn], body)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn], body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
EpAnn [AddEpAnn]
an, body
arg)
             else do
      EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnEqual
      body
arg' <- body -> EP w m body
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated body
arg
      (EpAnn [AddEpAnn], body)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn], body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, body
arg')
    HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body
-> EP
     w
     m
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
-> GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)
-> body
-> Bool
-> HsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)) body
forall lhs rhs.
XHsFieldBind lhs -> lhs -> rhs -> Bool -> HsFieldBind lhs rhs
HsFieldBind XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs))
EpAnn [AddEpAnn]
an0 GenLocated (SrcAnn NoEpAnns) (FieldLabelStrings GhcPs)
f' body
arg' Bool
isPun)

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

instance (ExactPrint (LocatedA body))
    => ExactPrint (HsFieldBind (LocatedAn NoEpAnns (AmbiguousFieldOcc GhcPs)) (LocatedA body)) where
  getAnnotationEntry :: HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
  (LocatedA body)
-> Entry
getAnnotationEntry HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
  (LocatedA body)
x = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn (HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
  (LocatedA body)
-> XHsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
forall lhs rhs. HsFieldBind lhs rhs -> XHsFieldBind lhs
hfbAnn HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
  (LocatedA body)
x)
  setAnnotationAnchor :: HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
  (LocatedA body)
-> Anchor
-> EpAnnComments
-> HsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
     (LocatedA body)
setAnnotationAnchor (HsFieldBind XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
an GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs)
f LocatedA body
arg Bool
isPun) Anchor
anc EpAnnComments
cs = (XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
-> GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs)
-> LocatedA body
-> Bool
-> HsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
     (LocatedA body)
forall lhs rhs.
XHsFieldBind lhs -> lhs -> rhs -> Bool -> HsFieldBind lhs rhs
HsFieldBind (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs)
f LocatedA body
arg Bool
isPun)
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
  (LocatedA body)
-> EP
     w
     m
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
        (LocatedA body))
exact (HsFieldBind XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
an GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs)
f LocatedA body
arg Bool
isPun) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsRecUpdField"
    GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs)
f' <- GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs)
f
    EpAnn [AddEpAnn]
an0 <- if Bool
isPun then EpAnn [AddEpAnn]
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
EpAnn [AddEpAnn]
an
             else EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnEqual
    LocatedA body
arg' <- if ((SrcSpanAnnA -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA (SrcSpanAnnA -> SrcSpan) -> SrcSpanAnnA -> SrcSpan
forall a b. (a -> b) -> a -> b
$ LocatedA body -> SrcSpanAnnA
forall l e. GenLocated l e -> l
getLoc LocatedA body
arg) SrcSpan -> SrcSpan -> Bool
forall a. Eq a => a -> a -> Bool
== SrcSpan
noSrcSpan )
              then LocatedA body
-> RWST (EPOptions m w) (EPWriter w) EPState m (LocatedA body)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return LocatedA body
arg
              else LocatedA body
-> RWST (EPOptions m w) (EPWriter w) EPState m (LocatedA body)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LocatedA body
arg
    HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
  (LocatedA body)
-> EP
     w
     m
     (HsFieldBind
        (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
        (LocatedA body))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
-> GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs)
-> LocatedA body
-> Bool
-> HsFieldBind
     (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
     (LocatedA body)
forall lhs rhs.
XHsFieldBind lhs -> lhs -> rhs -> Bool -> HsFieldBind lhs rhs
HsFieldBind XHsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs))
EpAnn [AddEpAnn]
an0 GenLocated (SrcAnn NoEpAnns) (AmbiguousFieldOcc GhcPs)
f' LocatedA body
arg' Bool
isPun)

-- ---------------------------------------------------------------------
instance
    (ExactPrint (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body),
     ExactPrint (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body))
    => ExactPrint
         (Either [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
                 [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]) where
  getAnnotationEntry :: Either
  [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
  [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
-> Entry
getAnnotationEntry = Entry
-> Either
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
-> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: Either
  [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
  [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
-> Anchor
-> EpAnnComments
-> Either
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
setAnnotationAnchor Either
  [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
  [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
a Anchor
_ EpAnnComments
_ = Either
  [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
  [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Either
  [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
  [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
-> EP
     w
     m
     (Either
        [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
        [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)])
exact (Left [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
rbinds) = [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
-> Either
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
forall a b. a -> Either a b
Left ([LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
 -> Either
      [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
      [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Either
        [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
        [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
rbinds
  exact (Right [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
pbinds) = [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
-> Either
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
forall a b. b -> Either a b
Right ([LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
 -> Either
      [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
      [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Either
        [LocatedA (HsFieldBind (LocatedAn NoEpAnns (a GhcPs)) body)]
        [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LocatedA (HsFieldBind (LocatedAn NoEpAnns (b GhcPs)) body)]
pbinds

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

instance ExactPrint (FieldLabelStrings GhcPs) where
  getAnnotationEntry :: FieldLabelStrings GhcPs -> Entry
getAnnotationEntry = Entry -> FieldLabelStrings GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: FieldLabelStrings GhcPs
-> Anchor -> EpAnnComments -> FieldLabelStrings GhcPs
setAnnotationAnchor FieldLabelStrings GhcPs
a Anchor
_ EpAnnComments
_ = FieldLabelStrings GhcPs
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
FieldLabelStrings GhcPs -> EP w m (FieldLabelStrings GhcPs)
exact (FieldLabelStrings [XRec GhcPs (DotFieldOcc GhcPs)]
fs) = [XRec GhcPs (DotFieldOcc GhcPs)] -> FieldLabelStrings GhcPs
[GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)]
-> FieldLabelStrings GhcPs
forall p. [XRec p (DotFieldOcc p)] -> FieldLabelStrings p
FieldLabelStrings ([GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)]
 -> FieldLabelStrings GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)]
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (FieldLabelStrings GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [XRec GhcPs (DotFieldOcc GhcPs)]
[GenLocated (SrcAnn NoEpAnns) (DotFieldOcc GhcPs)]
fs

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

instance ExactPrint (DotFieldOcc GhcPs) where
  getAnnotationEntry :: DotFieldOcc GhcPs -> Entry
getAnnotationEntry (DotFieldOcc XCDotFieldOcc GhcPs
an XRec GhcPs FieldLabelString
_) = EpAnn AnnFieldLabel -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCDotFieldOcc GhcPs
EpAnn AnnFieldLabel
an

  setAnnotationAnchor :: DotFieldOcc GhcPs -> Anchor -> EpAnnComments -> DotFieldOcc GhcPs
setAnnotationAnchor (DotFieldOcc XCDotFieldOcc GhcPs
an XRec GhcPs FieldLabelString
a) Anchor
anc EpAnnComments
cs = XCDotFieldOcc GhcPs
-> XRec GhcPs FieldLabelString -> DotFieldOcc GhcPs
forall p.
XCDotFieldOcc p -> XRec p FieldLabelString -> DotFieldOcc p
DotFieldOcc (EpAnn AnnFieldLabel
-> Anchor -> EpAnnComments -> EpAnn AnnFieldLabel
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCDotFieldOcc GhcPs
EpAnn AnnFieldLabel
an Anchor
anc EpAnnComments
cs) XRec GhcPs FieldLabelString
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DotFieldOcc GhcPs -> EP w m (DotFieldOcc GhcPs)
exact (DotFieldOcc XCDotFieldOcc GhcPs
an (L SrcSpanAnnN
loc (FieldLabelString FastString
fs))) = do
    EpAnn AnnFieldLabel
an0 <- EpAnn AnnFieldLabel
-> Lens AnnFieldLabel (Maybe EpaLocation)
-> AnnKeywordId
-> EP w m (EpAnn AnnFieldLabel)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a (Maybe EpaLocation) -> AnnKeywordId -> EP w m (EpAnn a)
markLensKwM XCDotFieldOcc GhcPs
EpAnn AnnFieldLabel
an (Maybe EpaLocation -> f (Maybe EpaLocation))
-> AnnFieldLabel -> f AnnFieldLabel
Lens AnnFieldLabel (Maybe EpaLocation)
lafDot  AnnKeywordId
AnnDot
    -- The field name has a SrcSpanAnnN, print it as a
    -- LocatedN RdrName
    L SrcSpanAnnN
loc' RdrName
_ <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated (SrcSpanAnnN -> RdrName -> GenLocated SrcSpanAnnN RdrName
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
loc (FastString -> RdrName
mkVarUnqual FastString
fs))
    DotFieldOcc GhcPs -> EP w m (DotFieldOcc GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCDotFieldOcc GhcPs
-> XRec GhcPs FieldLabelString -> DotFieldOcc GhcPs
forall p.
XCDotFieldOcc p -> XRec p FieldLabelString -> DotFieldOcc p
DotFieldOcc XCDotFieldOcc GhcPs
EpAnn AnnFieldLabel
an0 (SrcSpanAnnN
-> FieldLabelString -> GenLocated SrcSpanAnnN FieldLabelString
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
loc' (FastString -> FieldLabelString
FieldLabelString FastString
fs)))

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

instance ExactPrint (HsTupArg GhcPs) where
  getAnnotationEntry :: HsTupArg GhcPs -> Entry
getAnnotationEntry (Present XPresent GhcPs
an XRec GhcPs (HsExpr GhcPs)
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XPresent GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (Missing XMissing GhcPs
an)   = EpAnn EpaLocation -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XMissing GhcPs
EpAnn EpaLocation
an

  setAnnotationAnchor :: HsTupArg GhcPs -> Anchor -> EpAnnComments -> HsTupArg GhcPs
setAnnotationAnchor (Present XPresent GhcPs
an XRec GhcPs (HsExpr GhcPs)
a) Anchor
anc EpAnnComments
cs = XPresent GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsTupArg GhcPs
forall id. XPresent id -> LHsExpr id -> HsTupArg id
Present (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XPresent GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a
  setAnnotationAnchor (Missing XMissing GhcPs
an)   Anchor
anc EpAnnComments
cs = XMissing GhcPs -> HsTupArg GhcPs
forall id. XMissing id -> HsTupArg id
Missing (EpAnn EpaLocation -> Anchor -> EpAnnComments -> EpAnn EpaLocation
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XMissing GhcPs
EpAnn EpaLocation
an Anchor
anc EpAnnComments
cs)

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsTupArg GhcPs -> EP w m (HsTupArg GhcPs)
exact (Present XPresent GhcPs
a XRec GhcPs (HsExpr GhcPs)
e) = XPresent GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsTupArg GhcPs
forall id. XPresent id -> LHsExpr id -> HsTupArg id
Present XPresent GhcPs
a (GenLocated SrcSpanAnnA (HsExpr GhcPs) -> HsTupArg GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsTupArg GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e

  exact a :: HsTupArg GhcPs
a@(Missing XMissing GhcPs
EpAnn EpaLocation
EpAnnNotUsed) = HsTupArg GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsTupArg GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsTupArg GhcPs
a
  exact a :: HsTupArg GhcPs
a@(Missing XMissing GhcPs
_) = String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance String
"," EP w m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsTupArg GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsTupArg GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HsTupArg GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsTupArg GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsTupArg GhcPs
a

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

instance ExactPrint (HsCmdTop GhcPs) where
  getAnnotationEntry :: HsCmdTop GhcPs -> Entry
getAnnotationEntry = Entry -> HsCmdTop GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: HsCmdTop GhcPs -> Anchor -> EpAnnComments -> HsCmdTop GhcPs
setAnnotationAnchor HsCmdTop GhcPs
a Anchor
_ EpAnnComments
_ = HsCmdTop GhcPs
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsCmdTop GhcPs -> EP w m (HsCmdTop GhcPs)
exact (HsCmdTop XCmdTop GhcPs
a LHsCmd GhcPs
cmd) = XCmdTop GhcPs -> LHsCmd GhcPs -> HsCmdTop GhcPs
forall p. XCmdTop p -> LHsCmd p -> HsCmdTop p
HsCmdTop XCmdTop GhcPs
a (LocatedA (HsCmd GhcPs) -> HsCmdTop GhcPs)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (LocatedA (HsCmd GhcPs))
-> RWST (EPOptions m w) (EPWriter w) EPState m (HsCmdTop GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LocatedA (HsCmd GhcPs)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (LocatedA (HsCmd GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
cmd

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

instance ExactPrint (HsCmd GhcPs) where
  getAnnotationEntry :: HsCmd GhcPs -> Entry
getAnnotationEntry (HsCmdArrApp XCmdArrApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ XRec GhcPs (HsExpr GhcPs)
_ HsArrAppType
_ Bool
_)   = EpAnn AddEpAnn -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCmdArrApp GhcPs
EpAnn AddEpAnn
an
  getAnnotationEntry (HsCmdArrForm XCmdArrForm GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ LexicalFixity
_ Maybe Fixity
_ [LHsCmdTop GhcPs]
_ ) = EpAnn AnnList -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCmdArrForm GhcPs
EpAnn AnnList
an
  getAnnotationEntry (HsCmdApp XCmdApp GhcPs
an LHsCmd GhcPs
_ XRec GhcPs (HsExpr GhcPs)
_ )         = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCmdApp GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsCmdLam {})              = Entry
NoEntryVal
  getAnnotationEntry (HsCmdPar XCmdPar GhcPs
an LHsToken "(" GhcPs
_ LHsCmd GhcPs
_ LHsToken ")" GhcPs
_)        = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCmdPar GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsCmdCase XCmdCase GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ MatchGroup GhcPs (LHsCmd GhcPs)
_)         = EpAnn EpAnnHsCase -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCmdCase GhcPs
EpAnn EpAnnHsCase
an
  getAnnotationEntry (HsCmdLamCase XCmdLamCase GhcPs
an LamCaseVariant
_ MatchGroup GhcPs (LHsCmd GhcPs)
_)      = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCmdLamCase GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsCmdIf XCmdIf GhcPs
an SyntaxExpr GhcPs
_ XRec GhcPs (HsExpr GhcPs)
_ LHsCmd GhcPs
_ LHsCmd GhcPs
_)       = EpAnn AnnsIf -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCmdIf GhcPs
EpAnn AnnsIf
an
  getAnnotationEntry (HsCmdLet XCmdLet GhcPs
an LHsToken "let" GhcPs
_ HsLocalBinds GhcPs
_ LHsToken "in" GhcPs
_ LHsCmd GhcPs
_)      = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCmdLet GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsCmdDo XCmdDo GhcPs
an XRec GhcPs [CmdLStmt GhcPs]
_)             = EpAnn AnnList -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCmdDo GhcPs
EpAnn AnnList
an

  setAnnotationAnchor :: HsCmd GhcPs -> Anchor -> EpAnnComments -> HsCmd GhcPs
setAnnotationAnchor (HsCmdArrApp XCmdArrApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b HsArrAppType
c Bool
d)   Anchor
anc EpAnnComments
cs = (XCmdArrApp GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsArrAppType
-> Bool
-> HsCmd GhcPs
forall id.
XCmdArrApp id
-> LHsExpr id -> LHsExpr id -> HsArrAppType -> Bool -> HsCmd id
HsCmdArrApp (EpAnn AddEpAnn -> Anchor -> EpAnnComments -> EpAnn AddEpAnn
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCmdArrApp GhcPs
EpAnn AddEpAnn
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a XRec GhcPs (HsExpr GhcPs)
b HsArrAppType
c Bool
d)
  setAnnotationAnchor (HsCmdArrForm XCmdArrForm GhcPs
an XRec GhcPs (HsExpr GhcPs)
a LexicalFixity
b Maybe Fixity
c [LHsCmdTop GhcPs]
d ) Anchor
anc EpAnnComments
cs = (XCmdArrForm GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> LexicalFixity
-> Maybe Fixity
-> [LHsCmdTop GhcPs]
-> HsCmd GhcPs
forall id.
XCmdArrForm id
-> LHsExpr id
-> LexicalFixity
-> Maybe Fixity
-> [LHsCmdTop id]
-> HsCmd id
HsCmdArrForm (EpAnn AnnList -> Anchor -> EpAnnComments -> EpAnn AnnList
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCmdArrForm GhcPs
EpAnn AnnList
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a LexicalFixity
b Maybe Fixity
c [LHsCmdTop GhcPs]
d )
  setAnnotationAnchor (HsCmdApp XCmdApp GhcPs
an LHsCmd GhcPs
a XRec GhcPs (HsExpr GhcPs)
b )         Anchor
anc EpAnnComments
cs = (XCmdApp GhcPs
-> LHsCmd GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsCmd GhcPs
forall id. XCmdApp id -> LHsCmd id -> LHsExpr id -> HsCmd id
HsCmdApp (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCmdApp GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) LHsCmd GhcPs
a XRec GhcPs (HsExpr GhcPs)
b )
  setAnnotationAnchor a :: HsCmd GhcPs
a@(HsCmdLam {})              Anchor
_ EpAnnComments
_s = HsCmd GhcPs
a
  setAnnotationAnchor (HsCmdPar XCmdPar GhcPs
an LHsToken "(" GhcPs
a LHsCmd GhcPs
b LHsToken ")" GhcPs
c)        Anchor
anc EpAnnComments
cs = (XCmdPar GhcPs
-> LHsToken "(" GhcPs
-> LHsCmd GhcPs
-> LHsToken ")" GhcPs
-> HsCmd GhcPs
forall id.
XCmdPar id
-> LHsToken "(" id -> LHsCmd id -> LHsToken ")" id -> HsCmd id
HsCmdPar (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCmdPar GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) LHsToken "(" GhcPs
a LHsCmd GhcPs
b LHsToken ")" GhcPs
c)
  setAnnotationAnchor (HsCmdCase XCmdCase GhcPs
an XRec GhcPs (HsExpr GhcPs)
a MatchGroup GhcPs (LHsCmd GhcPs)
b)         Anchor
anc EpAnnComments
cs = (XCmdCase GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> MatchGroup GhcPs (LHsCmd GhcPs)
-> HsCmd GhcPs
forall id.
XCmdCase id -> LHsExpr id -> MatchGroup id (LHsCmd id) -> HsCmd id
HsCmdCase (EpAnn EpAnnHsCase -> Anchor -> EpAnnComments -> EpAnn EpAnnHsCase
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCmdCase GhcPs
EpAnn EpAnnHsCase
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a MatchGroup GhcPs (LHsCmd GhcPs)
b)
  setAnnotationAnchor (HsCmdLamCase XCmdLamCase GhcPs
an LamCaseVariant
a MatchGroup GhcPs (LHsCmd GhcPs)
b)      Anchor
anc EpAnnComments
cs = (XCmdLamCase GhcPs
-> LamCaseVariant -> MatchGroup GhcPs (LHsCmd GhcPs) -> HsCmd GhcPs
forall id.
XCmdLamCase id
-> LamCaseVariant -> MatchGroup id (LHsCmd id) -> HsCmd id
HsCmdLamCase (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCmdLamCase GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LamCaseVariant
a MatchGroup GhcPs (LHsCmd GhcPs)
b)
  setAnnotationAnchor (HsCmdIf XCmdIf GhcPs
an SyntaxExpr GhcPs
a XRec GhcPs (HsExpr GhcPs)
b LHsCmd GhcPs
c LHsCmd GhcPs
d)       Anchor
anc EpAnnComments
cs = (XCmdIf GhcPs
-> SyntaxExpr GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> LHsCmd GhcPs
-> LHsCmd GhcPs
-> HsCmd GhcPs
forall id.
XCmdIf id
-> SyntaxExpr id
-> LHsExpr id
-> LHsCmd id
-> LHsCmd id
-> HsCmd id
HsCmdIf (EpAnn AnnsIf -> Anchor -> EpAnnComments -> EpAnn AnnsIf
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCmdIf GhcPs
EpAnn AnnsIf
an Anchor
anc EpAnnComments
cs) SyntaxExpr GhcPs
a XRec GhcPs (HsExpr GhcPs)
b LHsCmd GhcPs
c LHsCmd GhcPs
d)
  setAnnotationAnchor (HsCmdLet XCmdLet GhcPs
an LHsToken "let" GhcPs
a HsLocalBinds GhcPs
b LHsToken "in" GhcPs
c LHsCmd GhcPs
d)      Anchor
anc EpAnnComments
cs = (XCmdLet GhcPs
-> LHsToken "let" GhcPs
-> HsLocalBinds GhcPs
-> LHsToken "in" GhcPs
-> LHsCmd GhcPs
-> HsCmd GhcPs
forall id.
XCmdLet id
-> LHsToken "let" id
-> HsLocalBinds id
-> LHsToken "in" id
-> LHsCmd id
-> HsCmd id
HsCmdLet (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCmdLet GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) LHsToken "let" GhcPs
a HsLocalBinds GhcPs
b LHsToken "in" GhcPs
c LHsCmd GhcPs
d)
  setAnnotationAnchor (HsCmdDo XCmdDo GhcPs
an XRec GhcPs [CmdLStmt GhcPs]
a)             Anchor
anc EpAnnComments
cs = (XCmdDo GhcPs -> XRec GhcPs [CmdLStmt GhcPs] -> HsCmd GhcPs
forall id. XCmdDo id -> XRec id [CmdLStmt id] -> HsCmd id
HsCmdDo (EpAnn AnnList -> Anchor -> EpAnnComments -> EpAnn AnnList
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCmdDo GhcPs
EpAnn AnnList
an Anchor
anc EpAnnComments
cs) XRec GhcPs [CmdLStmt GhcPs]
a)

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsCmd GhcPs -> EP w m (HsCmd GhcPs)
exact (HsCmdArrApp XCmdArrApp GhcPs
an XRec GhcPs (HsExpr GhcPs)
arr XRec GhcPs (HsExpr GhcPs)
arg HsArrAppType
o Bool
isRightToLeft) = do
    if Bool
isRightToLeft
      then do
        GenLocated SrcSpanAnnA (HsExpr GhcPs)
arr' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
arr
        AddEpAnn
an0 <- AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
markKw (EpAnn AddEpAnn -> AddEpAnn
forall ann. EpAnn ann -> ann
anns XCmdArrApp GhcPs
EpAnn AddEpAnn
an)
        GenLocated SrcSpanAnnA (HsExpr GhcPs)
arg' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
arg
        let an1 :: EpAnn AddEpAnn
an1 = XCmdArrApp GhcPs
an{anns = an0}
        HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdArrApp GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsArrAppType
-> Bool
-> HsCmd GhcPs
forall id.
XCmdArrApp id
-> LHsExpr id -> LHsExpr id -> HsArrAppType -> Bool -> HsCmd id
HsCmdArrApp XCmdArrApp GhcPs
EpAnn AddEpAnn
an1 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
arr' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
arg' HsArrAppType
o Bool
isRightToLeft)
      else do
        GenLocated SrcSpanAnnA (HsExpr GhcPs)
arg' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
arg
        AddEpAnn
an0 <- AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AddEpAnn -> EP w m AddEpAnn
markKw (EpAnn AddEpAnn -> AddEpAnn
forall ann. EpAnn ann -> ann
anns XCmdArrApp GhcPs
EpAnn AddEpAnn
an)
        GenLocated SrcSpanAnnA (HsExpr GhcPs)
arr' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
arr
        let an1 :: EpAnn AddEpAnn
an1 = XCmdArrApp GhcPs
an {anns = an0}
        HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdArrApp GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> XRec GhcPs (HsExpr GhcPs)
-> HsArrAppType
-> Bool
-> HsCmd GhcPs
forall id.
XCmdArrApp id
-> LHsExpr id -> LHsExpr id -> HsArrAppType -> Bool -> HsCmd id
HsCmdArrApp XCmdArrApp GhcPs
EpAnn AddEpAnn
an1 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
arr' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
arg' HsArrAppType
o Bool
isRightToLeft)

  exact (HsCmdArrForm XCmdArrForm GhcPs
an XRec GhcPs (HsExpr GhcPs)
e LexicalFixity
fixity Maybe Fixity
mf [LHsCmdTop GhcPs]
cs) = do
    EpAnn AnnList
an0 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA XCmdArrForm GhcPs
EpAnn AnnList
an (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_open
    (GenLocated SrcSpanAnnA (HsExpr GhcPs)
e',[GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
cs') <- case (LexicalFixity
fixity, [LHsCmdTop GhcPs]
[GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
cs) of
      (LexicalFixity
Infix, (GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)
arg1:[GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
argrest)) -> do
        GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)
arg1' <- GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)
arg1
        GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
        [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
argrest' <- [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
-> EP w m [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
argrest
        (GenLocated SrcSpanAnnA (HsExpr GhcPs),
 [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (HsExpr GhcPs),
      [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnA (HsExpr GhcPs)
e', GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)
arg1'GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)
-> [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
-> [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
forall a. a -> [a] -> [a]
:[GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
argrest')
      (LexicalFixity
Prefix, [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
_) -> do
        GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
        [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
cs' <- [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
-> EP w m [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsCmdTop GhcPs]
[GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
cs
        (GenLocated SrcSpanAnnA (HsExpr GhcPs),
 [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (HsExpr GhcPs),
      [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnA (HsExpr GhcPs)
e', [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
cs')
      (LexicalFixity
Infix, []) -> String
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (HsExpr GhcPs),
      [GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)])
forall a. HasCallStack => String -> a
error String
"Not possible"
    EpAnn AnnList
an1 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn AnnList
an0 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_close
    HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdArrForm GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> LexicalFixity
-> Maybe Fixity
-> [LHsCmdTop GhcPs]
-> HsCmd GhcPs
forall id.
XCmdArrForm id
-> LHsExpr id
-> LexicalFixity
-> Maybe Fixity
-> [LHsCmdTop id]
-> HsCmd id
HsCmdArrForm XCmdArrForm GhcPs
EpAnn AnnList
an1 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' LexicalFixity
fixity Maybe Fixity
mf [LHsCmdTop GhcPs]
[GenLocated (SrcAnn NoEpAnns) (HsCmdTop GhcPs)]
cs')

  exact (HsCmdApp XCmdApp GhcPs
an LHsCmd GhcPs
e1 XRec GhcPs (HsExpr GhcPs)
e2) = do
    LocatedA (HsCmd GhcPs)
e1' <- LocatedA (HsCmd GhcPs) -> EP w m (LocatedA (HsCmd GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
e1
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2
    HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdApp GhcPs
-> LHsCmd GhcPs -> XRec GhcPs (HsExpr GhcPs) -> HsCmd GhcPs
forall id. XCmdApp id -> LHsCmd id -> LHsExpr id -> HsCmd id
HsCmdApp XCmdApp GhcPs
an LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
e1' XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e2')

  exact (HsCmdLam XCmdLam GhcPs
a MatchGroup GhcPs (LHsCmd GhcPs)
match) = do
    MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
match' <- MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (MatchGroup GhcPs (LocatedA (HsCmd GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated MatchGroup GhcPs (LHsCmd GhcPs)
MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
match
    HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdLam GhcPs -> MatchGroup GhcPs (LHsCmd GhcPs) -> HsCmd GhcPs
forall id. XCmdLam id -> MatchGroup id (LHsCmd id) -> HsCmd id
HsCmdLam XCmdLam GhcPs
a MatchGroup GhcPs (LHsCmd GhcPs)
MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
match')

  exact (HsCmdPar XCmdPar GhcPs
an LHsToken "(" GhcPs
lpar LHsCmd GhcPs
e LHsToken ")" GhcPs
rpar) = do
    GenLocated TokenLocation (HsToken "(")
lpar' <- LHsToken "(" GhcPs -> EP w m (LHsToken "(" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "(" GhcPs
lpar
    LocatedA (HsCmd GhcPs)
e' <- LocatedA (HsCmd GhcPs) -> EP w m (LocatedA (HsCmd GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
e
    GenLocated TokenLocation (HsToken ")")
rpar' <- LHsToken ")" GhcPs -> EP w m (LHsToken ")" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken ")" GhcPs
rpar
    HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdPar GhcPs
-> LHsToken "(" GhcPs
-> LHsCmd GhcPs
-> LHsToken ")" GhcPs
-> HsCmd GhcPs
forall id.
XCmdPar id
-> LHsToken "(" id -> LHsCmd id -> LHsToken ")" id -> HsCmd id
HsCmdPar XCmdPar GhcPs
an LHsToken "(" GhcPs
GenLocated TokenLocation (HsToken "(")
lpar' LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
e' LHsToken ")" GhcPs
GenLocated TokenLocation (HsToken ")")
rpar')

  exact (HsCmdCase XCmdCase GhcPs
an XRec GhcPs (HsExpr GhcPs)
e MatchGroup GhcPs (LHsCmd GhcPs)
alts) = do
    EpAnn EpAnnHsCase
an0 <- EpAnn EpAnnHsCase
-> Lens EpAnnHsCase EpaLocation
-> AnnKeywordId
-> EP w m (EpAnn EpAnnHsCase)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw XCmdCase GhcPs
EpAnn EpAnnHsCase
an (EpaLocation -> f EpaLocation) -> EpAnnHsCase -> f EpAnnHsCase
Lens EpAnnHsCase EpaLocation
lhsCaseAnnCase AnnKeywordId
AnnCase
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e
    EpAnn EpAnnHsCase
an1 <- EpAnn EpAnnHsCase
-> Lens EpAnnHsCase EpaLocation
-> AnnKeywordId
-> EP w m (EpAnn EpAnnHsCase)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw EpAnn EpAnnHsCase
an0 (EpaLocation -> f EpaLocation) -> EpAnnHsCase -> f EpAnnHsCase
Lens EpAnnHsCase EpaLocation
lhsCaseAnnOf AnnKeywordId
AnnOf
    EpAnn EpAnnHsCase
an2 <- EpAnn EpAnnHsCase
-> Lens EpAnnHsCase [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn EpAnnHsCase)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn EpAnnHsCase
an1 ([AddEpAnn] -> f [AddEpAnn]) -> EpAnnHsCase -> f EpAnnHsCase
Lens EpAnnHsCase [AddEpAnn]
lhsCaseAnnsRest AnnKeywordId
AnnOpenC
    EpAnn EpAnnHsCase
an3 <- EpAnn EpAnnHsCase
-> Lens EpAnnHsCase [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn EpAnnHsCase)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn EpAnnHsCase
an2 ([AddEpAnn] -> f [AddEpAnn]) -> EpAnnHsCase -> f EpAnnHsCase
Lens EpAnnHsCase [AddEpAnn]
lhsCaseAnnsRest AnnKeywordId
AnnSemi
    MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
alts' <- MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (MatchGroup GhcPs (LocatedA (HsCmd GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated MatchGroup GhcPs (LHsCmd GhcPs)
MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
alts
    EpAnn EpAnnHsCase
an4 <- EpAnn EpAnnHsCase
-> Lens EpAnnHsCase [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn EpAnnHsCase)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn EpAnnHsCase
an3 ([AddEpAnn] -> f [AddEpAnn]) -> EpAnnHsCase -> f EpAnnHsCase
Lens EpAnnHsCase [AddEpAnn]
lhsCaseAnnsRest AnnKeywordId
AnnCloseC
    HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdCase GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> MatchGroup GhcPs (LHsCmd GhcPs)
-> HsCmd GhcPs
forall id.
XCmdCase id -> LHsExpr id -> MatchGroup id (LHsCmd id) -> HsCmd id
HsCmdCase XCmdCase GhcPs
EpAnn EpAnnHsCase
an4 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e' MatchGroup GhcPs (LHsCmd GhcPs)
MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
alts')

  exact (HsCmdLamCase XCmdLamCase GhcPs
an LamCaseVariant
lc_variant MatchGroup GhcPs (LHsCmd GhcPs)
matches) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCmdLamCase GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnLam
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl (case LamCaseVariant
lc_variant of LamCaseVariant
LamCase -> AnnKeywordId
AnnCase
                                                   LamCaseVariant
LamCases -> AnnKeywordId
AnnCases)
    MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
matches' <- MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
-> EP w m (MatchGroup GhcPs (LocatedA (HsCmd GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated MatchGroup GhcPs (LHsCmd GhcPs)
MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
matches
    HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdLamCase GhcPs
-> LamCaseVariant -> MatchGroup GhcPs (LHsCmd GhcPs) -> HsCmd GhcPs
forall id.
XCmdLamCase id
-> LamCaseVariant -> MatchGroup id (LHsCmd id) -> HsCmd id
HsCmdLamCase XCmdLamCase GhcPs
EpAnn [AddEpAnn]
an1 LamCaseVariant
lc_variant MatchGroup GhcPs (LHsCmd GhcPs)
MatchGroup GhcPs (LocatedA (HsCmd GhcPs))
matches')

  exact (HsCmdIf XCmdIf GhcPs
an SyntaxExpr GhcPs
a XRec GhcPs (HsExpr GhcPs)
e1 LHsCmd GhcPs
e2 LHsCmd GhcPs
e3) = do
    EpAnn AnnsIf
an0 <- EpAnn AnnsIf
-> Lens AnnsIf EpaLocation -> AnnKeywordId -> EP w m (EpAnn AnnsIf)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw XCmdIf GhcPs
EpAnn AnnsIf
an (EpaLocation -> f EpaLocation) -> AnnsIf -> f AnnsIf
Lens AnnsIf EpaLocation
laiIf AnnKeywordId
AnnIf
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1
    EpAnn AnnsIf
an1 <- EpAnn AnnsIf
-> Lens AnnsIf (Maybe EpaLocation)
-> AnnKeywordId
-> EP w m (EpAnn AnnsIf)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a (Maybe EpaLocation) -> AnnKeywordId -> EP w m (EpAnn a)
markLensKwM EpAnn AnnsIf
an0 (Maybe EpaLocation -> f (Maybe EpaLocation)) -> AnnsIf -> f AnnsIf
Lens AnnsIf (Maybe EpaLocation)
laiThenSemi AnnKeywordId
AnnSemi
    EpAnn AnnsIf
an2 <- EpAnn AnnsIf
-> Lens AnnsIf EpaLocation -> AnnKeywordId -> EP w m (EpAnn AnnsIf)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw EpAnn AnnsIf
an1 (EpaLocation -> f EpaLocation) -> AnnsIf -> f AnnsIf
Lens AnnsIf EpaLocation
laiThen AnnKeywordId
AnnThen
    LocatedA (HsCmd GhcPs)
e2' <- LocatedA (HsCmd GhcPs) -> EP w m (LocatedA (HsCmd GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
e2
    EpAnn AnnsIf
an3 <- EpAnn AnnsIf
-> Lens AnnsIf (Maybe EpaLocation)
-> AnnKeywordId
-> EP w m (EpAnn AnnsIf)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a (Maybe EpaLocation) -> AnnKeywordId -> EP w m (EpAnn a)
markLensKwM EpAnn AnnsIf
an2 (Maybe EpaLocation -> f (Maybe EpaLocation)) -> AnnsIf -> f AnnsIf
Lens AnnsIf (Maybe EpaLocation)
laiElseSemi AnnKeywordId
AnnSemi
    EpAnn AnnsIf
an4 <- EpAnn AnnsIf
-> Lens AnnsIf EpaLocation -> AnnKeywordId -> EP w m (EpAnn AnnsIf)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> AnnKeywordId -> EP w m (EpAnn a)
markLensKw EpAnn AnnsIf
an3 (EpaLocation -> f EpaLocation) -> AnnsIf -> f AnnsIf
Lens AnnsIf EpaLocation
laiElse AnnKeywordId
AnnElse
    LocatedA (HsCmd GhcPs)
e3' <- LocatedA (HsCmd GhcPs) -> EP w m (LocatedA (HsCmd GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
e3
    HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdIf GhcPs
-> SyntaxExpr GhcPs
-> XRec GhcPs (HsExpr GhcPs)
-> LHsCmd GhcPs
-> LHsCmd GhcPs
-> HsCmd GhcPs
forall id.
XCmdIf id
-> SyntaxExpr id
-> LHsExpr id
-> LHsCmd id
-> LHsCmd id
-> HsCmd id
HsCmdIf XCmdIf GhcPs
EpAnn AnnsIf
an4 SyntaxExpr GhcPs
a XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
e1' LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
e2' LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
e3')

  exact (HsCmdLet XCmdLet GhcPs
an LHsToken "let" GhcPs
tkLet HsLocalBinds GhcPs
binds LHsToken "in" GhcPs
tkIn LHsCmd GhcPs
e) = do
    EP w m (HsCmd GhcPs) -> EP w m (HsCmd GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutBoth (EP w m (HsCmd GhcPs) -> EP w m (HsCmd GhcPs))
-> EP w m (HsCmd GhcPs) -> EP w m (HsCmd GhcPs)
forall a b. (a -> b) -> a -> b
$ do -- Make sure the 'in' gets indented too
      GenLocated TokenLocation (HsToken "let")
tkLet' <- LHsToken "let" GhcPs -> EP w m (LHsToken "let" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "let" GhcPs
tkLet
      HsLocalBinds GhcPs
binds' <- EP w m (HsLocalBinds GhcPs) -> EP w m (HsLocalBinds GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutBoth (EP w m (HsLocalBinds GhcPs) -> EP w m (HsLocalBinds GhcPs))
-> EP w m (HsLocalBinds GhcPs) -> EP w m (HsLocalBinds GhcPs)
forall a b. (a -> b) -> a -> b
$ HsLocalBinds GhcPs -> EP w m (HsLocalBinds GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsLocalBinds GhcPs
binds
      GenLocated TokenLocation (HsToken "in")
tkIn' <- LHsToken "in" GhcPs -> EP w m (LHsToken "in" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "in" GhcPs
tkIn
      LocatedA (HsCmd GhcPs)
e' <- LocatedA (HsCmd GhcPs) -> EP w m (LocatedA (HsCmd GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
e
      HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdLet GhcPs
-> LHsToken "let" GhcPs
-> HsLocalBinds GhcPs
-> LHsToken "in" GhcPs
-> LHsCmd GhcPs
-> HsCmd GhcPs
forall id.
XCmdLet id
-> LHsToken "let" id
-> HsLocalBinds id
-> LHsToken "in" id
-> LHsCmd id
-> HsCmd id
HsCmdLet XCmdLet GhcPs
an LHsToken "let" GhcPs
GenLocated TokenLocation (HsToken "let")
tkLet' HsLocalBinds GhcPs
binds' LHsToken "in" GhcPs
GenLocated TokenLocation (HsToken "in")
tkIn' LHsCmd GhcPs
LocatedA (HsCmd GhcPs)
e')

  exact (HsCmdDo XCmdDo GhcPs
an XRec GhcPs [CmdLStmt GhcPs]
es) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"HsCmdDo"
    EpAnn AnnList
an0 <- EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCmdDo GhcPs
EpAnn AnnList
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
AnnDo
    GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
es' <- GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL
        [GenLocated
           SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs [CmdLStmt GhcPs]
GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
es
    HsCmd GhcPs -> EP w m (HsCmd GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCmdDo GhcPs -> XRec GhcPs [CmdLStmt GhcPs] -> HsCmd GhcPs
forall id. XCmdDo id -> XRec id [CmdLStmt id] -> HsCmd id
HsCmdDo XCmdDo GhcPs
EpAnn AnnList
an0 XRec GhcPs [CmdLStmt GhcPs]
GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
es')

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

instance (
  ExactPrint (LocatedA (body GhcPs)),
                 Anno (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ~ SrcSpanAnnA,
           Anno [GenLocated SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))] ~ SrcSpanAnnL,
           (ExactPrint (LocatedL [LocatedA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))])))
   => ExactPrint (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) where
  getAnnotationEntry :: StmtLR GhcPs GhcPs (LocatedA (body GhcPs)) -> Entry
getAnnotationEntry (LastStmt XLastStmt GhcPs GhcPs (LocatedA (body GhcPs))
_ LocatedA (body GhcPs)
_ Maybe Bool
_ SyntaxExpr GhcPs
_)             = Entry
NoEntryVal
  getAnnotationEntry (BindStmt XBindStmt GhcPs GhcPs (LocatedA (body GhcPs))
an LPat GhcPs
_ LocatedA (body GhcPs)
_)              = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XBindStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an
  getAnnotationEntry (ApplicativeStmt XApplicativeStmt GhcPs GhcPs (LocatedA (body GhcPs))
_ [(SyntaxExpr GhcPs, ApplicativeArg GhcPs)]
_ Maybe (SyntaxExpr GhcPs)
_)        = Entry
NoEntryVal
  getAnnotationEntry (BodyStmt XBodyStmt GhcPs GhcPs (LocatedA (body GhcPs))
_ LocatedA (body GhcPs)
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_)             = Entry
NoEntryVal
  getAnnotationEntry (LetStmt XLetStmt GhcPs GhcPs (LocatedA (body GhcPs))
an HsLocalBinds GhcPs
_)                 = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XLetStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an
  getAnnotationEntry (ParStmt XParStmt GhcPs GhcPs (LocatedA (body GhcPs))
_ [ParStmtBlock GhcPs GhcPs]
_ HsExpr GhcPs
_ SyntaxExpr GhcPs
_)              = Entry
NoEntryVal
  getAnnotationEntry (TransStmt XTransStmt GhcPs GhcPs (LocatedA (body GhcPs))
an TransForm
_ [GuardLStmt GhcPs]
_ [(IdP GhcPs, IdP GhcPs)]
_ XRec GhcPs (HsExpr GhcPs)
_ Maybe (XRec GhcPs (HsExpr GhcPs))
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_ HsExpr GhcPs
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XTransStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an
  getAnnotationEntry (RecStmt XRecStmt GhcPs GhcPs (LocatedA (body GhcPs))
an XRec GhcPs [LStmtLR GhcPs GhcPs (LocatedA (body GhcPs))]
_ [IdP GhcPs]
_ [IdP GhcPs]
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_)       = EpAnn AnnList -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XRecStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn AnnList
an

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

  setAnnotationAnchor :: StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
-> Anchor
-> EpAnnComments
-> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
setAnnotationAnchor a :: StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
a@(LastStmt XLastStmt GhcPs GhcPs (LocatedA (body GhcPs))
_ LocatedA (body GhcPs)
_ Maybe Bool
_ SyntaxExpr GhcPs
_)             Anchor
_ EpAnnComments
_s = StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
a
  setAnnotationAnchor (BindStmt XBindStmt GhcPs GhcPs (LocatedA (body GhcPs))
an LPat GhcPs
a LocatedA (body GhcPs)
b)              Anchor
anc EpAnnComments
cs = (XBindStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> LPat GhcPs
-> LocatedA (body GhcPs)
-> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XBindStmt idL idR body -> LPat idL -> body -> StmtLR idL idR body
BindStmt (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XBindStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LPat GhcPs
a LocatedA (body GhcPs)
b)
  setAnnotationAnchor a :: StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
a@(ApplicativeStmt XApplicativeStmt GhcPs GhcPs (LocatedA (body GhcPs))
_ [(SyntaxExpr GhcPs, ApplicativeArg GhcPs)]
_ Maybe (SyntaxExpr GhcPs)
_)        Anchor
_ EpAnnComments
_s = StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
a
  setAnnotationAnchor a :: StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
a@(BodyStmt XBodyStmt GhcPs GhcPs (LocatedA (body GhcPs))
_ LocatedA (body GhcPs)
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_)             Anchor
_ EpAnnComments
_s = StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
a
  setAnnotationAnchor (LetStmt XLetStmt GhcPs GhcPs (LocatedA (body GhcPs))
an HsLocalBinds GhcPs
a)                 Anchor
anc EpAnnComments
cs = (XLetStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> HsLocalBinds GhcPs -> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XLetStmt idL idR body
-> HsLocalBindsLR idL idR -> StmtLR idL idR body
LetStmt (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XLetStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) HsLocalBinds GhcPs
a)
  setAnnotationAnchor a :: StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
a@(ParStmt XParStmt GhcPs GhcPs (LocatedA (body GhcPs))
_ [ParStmtBlock GhcPs GhcPs]
_ HsExpr GhcPs
_ SyntaxExpr GhcPs
_)              Anchor
_ EpAnnComments
_s = StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
a
  setAnnotationAnchor (TransStmt XTransStmt GhcPs GhcPs (LocatedA (body GhcPs))
an TransForm
a [GuardLStmt GhcPs]
b [(IdP GhcPs, IdP GhcPs)]
c XRec GhcPs (HsExpr GhcPs)
d Maybe (XRec GhcPs (HsExpr GhcPs))
e SyntaxExpr GhcPs
f SyntaxExpr GhcPs
g HsExpr GhcPs
h) Anchor
anc EpAnnComments
cs = (XTransStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> TransForm
-> [GuardLStmt GhcPs]
-> [(IdP GhcPs, IdP GhcPs)]
-> XRec GhcPs (HsExpr GhcPs)
-> Maybe (XRec GhcPs (HsExpr GhcPs))
-> SyntaxExpr GhcPs
-> SyntaxExpr GhcPs
-> HsExpr GhcPs
-> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XTransStmt idL idR body
-> TransForm
-> [ExprLStmt idL]
-> [(IdP idR, IdP idR)]
-> LHsExpr idR
-> Maybe (LHsExpr idR)
-> SyntaxExpr idR
-> SyntaxExpr idR
-> HsExpr idR
-> StmtLR idL idR body
TransStmt (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XTransStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) TransForm
a [GuardLStmt GhcPs]
b [(IdP GhcPs, IdP GhcPs)]
c XRec GhcPs (HsExpr GhcPs)
d Maybe (XRec GhcPs (HsExpr GhcPs))
e SyntaxExpr GhcPs
f SyntaxExpr GhcPs
g HsExpr GhcPs
h)
  setAnnotationAnchor (RecStmt XRecStmt GhcPs GhcPs (LocatedA (body GhcPs))
an XRec GhcPs [LStmtLR GhcPs GhcPs (LocatedA (body GhcPs))]
a [IdP GhcPs]
b [IdP GhcPs]
c SyntaxExpr GhcPs
d SyntaxExpr GhcPs
e SyntaxExpr GhcPs
f)       Anchor
anc EpAnnComments
cs = (XRecStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> XRec GhcPs [LStmtLR GhcPs GhcPs (LocatedA (body GhcPs))]
-> [IdP GhcPs]
-> [IdP GhcPs]
-> SyntaxExpr GhcPs
-> SyntaxExpr GhcPs
-> SyntaxExpr GhcPs
-> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XRecStmt idL idR body
-> XRec idR [LStmtLR idL idR body]
-> [IdP idR]
-> [IdP idR]
-> SyntaxExpr idR
-> SyntaxExpr idR
-> SyntaxExpr idR
-> StmtLR idL idR body
RecStmt (EpAnn AnnList -> Anchor -> EpAnnComments -> EpAnn AnnList
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XRecStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn AnnList
an Anchor
anc EpAnnComments
cs) XRec GhcPs [LStmtLR GhcPs GhcPs (LocatedA (body GhcPs))]
a [IdP GhcPs]
b [IdP GhcPs]
c SyntaxExpr GhcPs
d SyntaxExpr GhcPs
e SyntaxExpr GhcPs
f)

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

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
-> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))
exact (LastStmt XLastStmt GhcPs GhcPs (LocatedA (body GhcPs))
a LocatedA (body GhcPs)
body Maybe Bool
b SyntaxExpr GhcPs
c) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LastStmt"
    LocatedA (body GhcPs)
body' <- LocatedA (body GhcPs) -> EP w m (LocatedA (body GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LocatedA (body GhcPs)
body
    StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
-> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XLastStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> LocatedA (body GhcPs)
-> Maybe Bool
-> SyntaxExpr GhcPs
-> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XLastStmt idL idR body
-> body -> Maybe Bool -> SyntaxExpr idR -> StmtLR idL idR body
LastStmt XLastStmt GhcPs GhcPs (LocatedA (body GhcPs))
a LocatedA (body GhcPs)
body' Maybe Bool
b SyntaxExpr GhcPs
c)

  exact (BindStmt XBindStmt GhcPs GhcPs (LocatedA (body GhcPs))
an LPat GhcPs
pat LocatedA (body GhcPs)
body) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"BindStmt"
    GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XBindStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnLarrow
    LocatedA (body GhcPs)
body' <- LocatedA (body GhcPs) -> EP w m (LocatedA (body GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LocatedA (body GhcPs)
body
    StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
-> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XBindStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> LPat GhcPs
-> LocatedA (body GhcPs)
-> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XBindStmt idL idR body -> LPat idL -> body -> StmtLR idL idR body
BindStmt XBindStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an0 LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat' LocatedA (body GhcPs)
body')

  exact (ApplicativeStmt XApplicativeStmt GhcPs GhcPs (LocatedA (body GhcPs))
_ [(SyntaxExpr GhcPs, ApplicativeArg GhcPs)]
_body Maybe (SyntaxExpr GhcPs)
_) = do
    String -> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))
forall a. HasCallStack => String -> a
error (String -> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))))
-> String -> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))
forall a b. (a -> b) -> a -> b
$ String
"ApplicativeStmt is introduced in the renamer"

  exact (BodyStmt XBodyStmt GhcPs GhcPs (LocatedA (body GhcPs))
a LocatedA (body GhcPs)
body SyntaxExpr GhcPs
b SyntaxExpr GhcPs
c) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"BodyStmt"
    LocatedA (body GhcPs)
body' <- LocatedA (body GhcPs) -> EP w m (LocatedA (body GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LocatedA (body GhcPs)
body
    StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
-> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XBodyStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> LocatedA (body GhcPs)
-> SyntaxExpr GhcPs
-> SyntaxExpr GhcPs
-> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XBodyStmt idL idR body
-> body -> SyntaxExpr idR -> SyntaxExpr idR -> StmtLR idL idR body
BodyStmt XBodyStmt GhcPs GhcPs (LocatedA (body GhcPs))
a LocatedA (body GhcPs)
body' SyntaxExpr GhcPs
b SyntaxExpr GhcPs
c)

  exact (LetStmt XLetStmt GhcPs GhcPs (LocatedA (body GhcPs))
an HsLocalBinds GhcPs
binds) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LetStmt"
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XLetStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnLet
    HsLocalBinds GhcPs
binds' <- HsLocalBinds GhcPs -> EP w m (HsLocalBinds GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsLocalBinds GhcPs
binds
    StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
-> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XLetStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> HsLocalBinds GhcPs -> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XLetStmt idL idR body
-> HsLocalBindsLR idL idR -> StmtLR idL idR body
LetStmt XLetStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an0 HsLocalBinds GhcPs
binds')

  exact (ParStmt XParStmt GhcPs GhcPs (LocatedA (body GhcPs))
a [ParStmtBlock GhcPs GhcPs]
pbs HsExpr GhcPs
b SyntaxExpr GhcPs
c) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"ParStmt"
    [ParStmtBlock GhcPs GhcPs]
pbs' <- [ParStmtBlock GhcPs GhcPs] -> EP w m [ParStmtBlock GhcPs GhcPs]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [ParStmtBlock GhcPs GhcPs]
pbs
    StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
-> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XParStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> [ParStmtBlock GhcPs GhcPs]
-> HsExpr GhcPs
-> SyntaxExpr GhcPs
-> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XParStmt idL idR body
-> [ParStmtBlock idL idR]
-> HsExpr idR
-> SyntaxExpr idR
-> StmtLR idL idR body
ParStmt XParStmt GhcPs GhcPs (LocatedA (body GhcPs))
a [ParStmtBlock GhcPs GhcPs]
pbs' HsExpr GhcPs
b SyntaxExpr GhcPs
c)

  exact (TransStmt XTransStmt GhcPs GhcPs (LocatedA (body GhcPs))
an TransForm
form [GuardLStmt GhcPs]
stmts [(IdP GhcPs, IdP GhcPs)]
b XRec GhcPs (HsExpr GhcPs)
using Maybe (XRec GhcPs (HsExpr GhcPs))
by SyntaxExpr GhcPs
c SyntaxExpr GhcPs
d HsExpr GhcPs
e) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"TransStmt"
    [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts' <- [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GuardLStmt GhcPs]
[GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts
    (EpAnn [AddEpAnn]
an', Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs))
by', GenLocated SrcSpanAnnA (HsExpr GhcPs)
using') <- EpAnn [AddEpAnn]
-> Maybe (XRec GhcPs (HsExpr GhcPs))
-> XRec GhcPs (HsExpr GhcPs)
-> TransForm
-> EP
     w
     m
     (EpAnn [AddEpAnn], Maybe (XRec GhcPs (HsExpr GhcPs)),
      XRec GhcPs (HsExpr GhcPs))
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> Maybe (XRec GhcPs (HsExpr GhcPs))
-> XRec GhcPs (HsExpr GhcPs)
-> TransForm
-> EP
     w
     m
     (EpAnn [AddEpAnn], Maybe (XRec GhcPs (HsExpr GhcPs)),
      XRec GhcPs (HsExpr GhcPs))
exactTransStmt XTransStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an Maybe (XRec GhcPs (HsExpr GhcPs))
by XRec GhcPs (HsExpr GhcPs)
using TransForm
form
    StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
-> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XTransStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> TransForm
-> [GuardLStmt GhcPs]
-> [(IdP GhcPs, IdP GhcPs)]
-> XRec GhcPs (HsExpr GhcPs)
-> Maybe (XRec GhcPs (HsExpr GhcPs))
-> SyntaxExpr GhcPs
-> SyntaxExpr GhcPs
-> HsExpr GhcPs
-> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XTransStmt idL idR body
-> TransForm
-> [ExprLStmt idL]
-> [(IdP idR, IdP idR)]
-> LHsExpr idR
-> Maybe (LHsExpr idR)
-> SyntaxExpr idR
-> SyntaxExpr idR
-> HsExpr idR
-> StmtLR idL idR body
TransStmt XTransStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn [AddEpAnn]
an' TransForm
form [GuardLStmt GhcPs]
[GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts' [(IdP GhcPs, IdP GhcPs)]
b XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
using' Maybe (XRec GhcPs (HsExpr GhcPs))
Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs))
by' SyntaxExpr GhcPs
c SyntaxExpr GhcPs
d HsExpr GhcPs
e)

  exact (RecStmt XRecStmt GhcPs GhcPs (LocatedA (body GhcPs))
an XRec GhcPs [LStmtLR GhcPs GhcPs (LocatedA (body GhcPs))]
stmts [IdP GhcPs]
a [IdP GhcPs]
b SyntaxExpr GhcPs
c SyntaxExpr GhcPs
d SyntaxExpr GhcPs
e) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"RecStmt"
    EpAnn AnnList
an0 <- EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XRecStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn AnnList
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
AnnRec
    (EpAnn AnnList
an1, LocatedL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))]
stmts') <- Bool
-> EpAnn AnnList
-> EP
     w
     m
     (LocatedL
        [GenLocated
           SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))])
-> EP
     w
     m
     (EpAnn AnnList,
      LocatedL
        [GenLocated
           SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList Bool
True EpAnn AnnList
an0 (LocatedL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))]
-> EP
     w
     m
     (LocatedL
        [GenLocated
           SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs [LStmtLR GhcPs GhcPs (LocatedA (body GhcPs))]
LocatedL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))]
stmts)
    StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
-> EP w m (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XRecStmt GhcPs GhcPs (LocatedA (body GhcPs))
-> XRec GhcPs [LStmtLR GhcPs GhcPs (LocatedA (body GhcPs))]
-> [IdP GhcPs]
-> [IdP GhcPs]
-> SyntaxExpr GhcPs
-> SyntaxExpr GhcPs
-> SyntaxExpr GhcPs
-> StmtLR GhcPs GhcPs (LocatedA (body GhcPs))
forall idL idR body.
XRecStmt idL idR body
-> XRec idR [LStmtLR idL idR body]
-> [IdP idR]
-> [IdP idR]
-> SyntaxExpr idR
-> SyntaxExpr idR
-> SyntaxExpr idR
-> StmtLR idL idR body
RecStmt XRecStmt GhcPs GhcPs (LocatedA (body GhcPs))
EpAnn AnnList
an1 XRec GhcPs [LStmtLR GhcPs GhcPs (LocatedA (body GhcPs))]
LocatedL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))]
stmts' [IdP GhcPs]
a [IdP GhcPs]
b SyntaxExpr GhcPs
c SyntaxExpr GhcPs
d SyntaxExpr GhcPs
e)

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

instance ExactPrint (ParStmtBlock GhcPs GhcPs) where
  getAnnotationEntry :: ParStmtBlock GhcPs GhcPs -> Entry
getAnnotationEntry = Entry -> ParStmtBlock GhcPs GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: ParStmtBlock GhcPs GhcPs
-> Anchor -> EpAnnComments -> ParStmtBlock GhcPs GhcPs
setAnnotationAnchor ParStmtBlock GhcPs GhcPs
a Anchor
_ EpAnnComments
_ = ParStmtBlock GhcPs GhcPs
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
ParStmtBlock GhcPs GhcPs -> EP w m (ParStmtBlock GhcPs GhcPs)
exact (ParStmtBlock XParStmtBlock GhcPs GhcPs
a [GuardLStmt GhcPs]
stmts [IdP GhcPs]
b SyntaxExpr GhcPs
c) = do
    [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts' <- [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GuardLStmt GhcPs]
[GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts
    ParStmtBlock GhcPs GhcPs -> EP w m (ParStmtBlock GhcPs GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XParStmtBlock GhcPs GhcPs
-> [GuardLStmt GhcPs]
-> [IdP GhcPs]
-> SyntaxExpr GhcPs
-> ParStmtBlock GhcPs GhcPs
forall idL idR.
XParStmtBlock idL idR
-> [ExprLStmt idL]
-> [IdP idR]
-> SyntaxExpr idR
-> ParStmtBlock idL idR
ParStmtBlock XParStmtBlock GhcPs GhcPs
a [GuardLStmt GhcPs]
[GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts' [IdP GhcPs]
b SyntaxExpr GhcPs
c)

exactTransStmt :: (Monad m, Monoid w)
  => EpAnn [AddEpAnn] -> Maybe (LHsExpr GhcPs) -> (LHsExpr GhcPs) -> TransForm
  -> EP w m (EpAnn [AddEpAnn], Maybe (LHsExpr GhcPs), (LHsExpr GhcPs))
exactTransStmt :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> Maybe (XRec GhcPs (HsExpr GhcPs))
-> XRec GhcPs (HsExpr GhcPs)
-> TransForm
-> EP
     w
     m
     (EpAnn [AddEpAnn], Maybe (XRec GhcPs (HsExpr GhcPs)),
      XRec GhcPs (HsExpr GhcPs))
exactTransStmt EpAnn [AddEpAnn]
an Maybe (XRec GhcPs (HsExpr GhcPs))
by XRec GhcPs (HsExpr GhcPs)
using TransForm
ThenForm = do
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"exactTransStmt:ThenForm"
  EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnThen
  GenLocated SrcSpanAnnA (HsExpr GhcPs)
using' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
using
  case Maybe (XRec GhcPs (HsExpr GhcPs))
by of
    Maybe (XRec GhcPs (HsExpr GhcPs))
Nothing -> (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs)),
 GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs)),
      GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, Maybe (XRec GhcPs (HsExpr GhcPs))
Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs))
by, GenLocated SrcSpanAnnA (HsExpr GhcPs)
using')
    Just XRec GhcPs (HsExpr GhcPs)
b -> do
      EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnBy
      GenLocated SrcSpanAnnA (HsExpr GhcPs)
b' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
b
      (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs)),
 GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs)),
      GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall a. a -> Maybe a
Just GenLocated SrcSpanAnnA (HsExpr GhcPs)
b', GenLocated SrcSpanAnnA (HsExpr GhcPs)
using')
exactTransStmt EpAnn [AddEpAnn]
an Maybe (XRec GhcPs (HsExpr GhcPs))
by XRec GhcPs (HsExpr GhcPs)
using TransForm
GroupForm = do
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"exactTransStmt:GroupForm"
  EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnThen
  EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnGroup
  (EpAnn [AddEpAnn]
an2, Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs))
by') <- case Maybe (XRec GhcPs (HsExpr GhcPs))
by of
    Maybe (XRec GhcPs (HsExpr GhcPs))
Nothing -> (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, Maybe (XRec GhcPs (HsExpr GhcPs))
Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs))
by)
    Just XRec GhcPs (HsExpr GhcPs)
b -> do
      EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnBy
      GenLocated SrcSpanAnnA (HsExpr GhcPs)
b' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
b
      (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an2, GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall a. a -> Maybe a
Just GenLocated SrcSpanAnnA (HsExpr GhcPs)
b')
  EpAnn [AddEpAnn]
an3 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an2 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnUsing
  GenLocated SrcSpanAnnA (HsExpr GhcPs)
using' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
using
  (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs)),
 GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs)),
      GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an3, Maybe (GenLocated SrcSpanAnnA (HsExpr GhcPs))
by', GenLocated SrcSpanAnnA (HsExpr GhcPs)
using')

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

instance ExactPrint (TyClDecl GhcPs) where
  getAnnotationEntry :: TyClDecl GhcPs -> Entry
getAnnotationEntry (FamDecl   { })                   = Entry
NoEntryVal
  getAnnotationEntry (SynDecl   { tcdSExt :: forall pass. TyClDecl pass -> XSynDecl pass
tcdSExt = XSynDecl GhcPs
an })      = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XSynDecl GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (DataDecl  { tcdDExt :: forall pass. TyClDecl pass -> XDataDecl pass
tcdDExt = XDataDecl GhcPs
an })      = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XDataDecl GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (ClassDecl { tcdCExt :: forall pass. TyClDecl pass -> XClassDecl pass
tcdCExt = (EpAnn [AddEpAnn]
an, AnnSortKey
_) }) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn [AddEpAnn]
an

  setAnnotationAnchor :: TyClDecl GhcPs -> Anchor -> EpAnnComments -> TyClDecl GhcPs
setAnnotationAnchor a :: TyClDecl GhcPs
a@FamDecl{}     Anchor
_ EpAnnComments
_s = TyClDecl GhcPs
a
  setAnnotationAnchor x :: TyClDecl GhcPs
x@SynDecl{}   Anchor
anc EpAnnComments
cs = TyClDecl GhcPs
x { tcdSExt = setAnchorEpa (tcdSExt x) anc cs }
  setAnnotationAnchor x :: TyClDecl GhcPs
x@DataDecl{}  Anchor
anc EpAnnComments
cs = TyClDecl GhcPs
x { tcdDExt = setAnchorEpa (tcdDExt x) anc cs }
  setAnnotationAnchor x :: TyClDecl GhcPs
x@ClassDecl{} Anchor
anc EpAnnComments
cs = TyClDecl GhcPs
x { tcdCExt = (setAnchorEpa an anc cs, a) }
    where
      (EpAnn [AddEpAnn]
an,AnnSortKey
a) = TyClDecl GhcPs -> XClassDecl GhcPs
forall pass. TyClDecl pass -> XClassDecl pass
tcdCExt TyClDecl GhcPs
x

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
TyClDecl GhcPs -> EP w m (TyClDecl GhcPs)
exact (FamDecl XFamDecl GhcPs
a FamilyDecl GhcPs
decl) = do
    FamilyDecl GhcPs
decl' <- FamilyDecl GhcPs -> EP w m (FamilyDecl GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated FamilyDecl GhcPs
decl
    TyClDecl GhcPs -> EP w m (TyClDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XFamDecl GhcPs -> FamilyDecl GhcPs -> TyClDecl GhcPs
forall pass. XFamDecl pass -> FamilyDecl pass -> TyClDecl pass
FamDecl XFamDecl GhcPs
a FamilyDecl GhcPs
decl')

  exact (SynDecl { tcdSExt :: forall pass. TyClDecl pass -> XSynDecl pass
tcdSExt = XSynDecl GhcPs
an
                 , tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP GhcPs
ltycon, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcPs
tyvars, tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdFixity = LexicalFixity
fixity
                 , tcdRhs :: forall pass. TyClDecl pass -> LHsType pass
tcdRhs = LHsType GhcPs
rhs }) = do
    -- There may be arbitrary parens around parts of the constructor
    -- that are infix.  Turn these into comments so that they feed
    -- into the right place automatically
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> [AnnKeywordId]
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> [AnnKeywordId] -> EP w m (EpAnn a)
annotationsToComments XSynDecl GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl [AnnKeywordId
AnnOpenP,AnnKeywordId
AnnCloseP]
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnType

    (EpAnn [AddEpAnn]
_anx, GenLocated SrcSpanAnnN RdrName
ltycon', LHsQTyVars GhcPs
tyvars',()
_,Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
_) <- GenLocated SrcSpanAnnN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      LHsQTyVars GhcPs, (), Maybe (LHsContext GhcPs))
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated SrcSpanAnnN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      LHsQTyVars GhcPs, (), Maybe (LHsContext GhcPs))
exactVanillaDeclHead LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ltycon LHsQTyVars GhcPs
tyvars LexicalFixity
fixity Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall a. Maybe a
Nothing
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnEqual
    GenLocated SrcSpanAnnA (HsType GhcPs)
rhs' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
rhs
    TyClDecl GhcPs -> EP w m (TyClDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SynDecl { tcdSExt :: XSynDecl GhcPs
tcdSExt = XSynDecl GhcPs
EpAnn [AddEpAnn]
an2
                    , tcdLName :: LIdP GhcPs
tcdLName = LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ltycon', tcdTyVars :: LHsQTyVars GhcPs
tcdTyVars = LHsQTyVars GhcPs
tyvars', tcdFixity :: LexicalFixity
tcdFixity = LexicalFixity
fixity
                    , tcdRhs :: LHsType GhcPs
tcdRhs = LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
rhs' })

  -- TODO: add a workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/20452
  exact (DataDecl { tcdDExt :: forall pass. TyClDecl pass -> XDataDecl pass
tcdDExt = XDataDecl GhcPs
an, tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP GhcPs
ltycon, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcPs
tyvars
                  , tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdFixity = LexicalFixity
fixity, tcdDataDefn :: forall pass. TyClDecl pass -> HsDataDefn pass
tcdDataDefn = HsDataDefn GhcPs
defn }) = do
    (EpAnn [AddEpAnn]
_, EpAnn [AddEpAnn]
an', GenLocated SrcSpanAnnN RdrName
ltycon', LHsQTyVars GhcPs
tyvars', ()
_, Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
_mctxt', HsDataDefn GhcPs
defn') <-
      EpAnn [AddEpAnn]
-> (Maybe (LHsContext GhcPs)
    -> EP
         w
         m
         (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
          LHsQTyVars GhcPs, (), Maybe (LHsContext GhcPs)))
-> HsDataDefn GhcPs
-> EP
     w
     m
     (EpAnn [AddEpAnn], EpAnn [AddEpAnn],
      GenLocated SrcSpanAnnN RdrName, LHsQTyVars GhcPs, (),
      Maybe (LHsContext GhcPs), HsDataDefn GhcPs)
forall (m :: * -> *) w a b.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> (Maybe (LHsContext GhcPs)
    -> EP
         w
         m
         (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName, a, b,
          Maybe (LHsContext GhcPs)))
-> HsDataDefn GhcPs
-> EP
     w
     m
     (EpAnn [AddEpAnn], EpAnn [AddEpAnn],
      GenLocated SrcSpanAnnN RdrName, a, b, Maybe (LHsContext GhcPs),
      HsDataDefn GhcPs)
exactDataDefn XDataDecl GhcPs
EpAnn [AddEpAnn]
an (GenLocated SrcSpanAnnN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      LHsQTyVars GhcPs, (), Maybe (LHsContext GhcPs))
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated SrcSpanAnnN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      LHsQTyVars GhcPs, (), Maybe (LHsContext GhcPs))
exactVanillaDeclHead LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ltycon LHsQTyVars GhcPs
tyvars LexicalFixity
fixity) HsDataDefn GhcPs
defn
    TyClDecl GhcPs -> EP w m (TyClDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (DataDecl { tcdDExt :: XDataDecl GhcPs
tcdDExt = XDataDecl GhcPs
EpAnn [AddEpAnn]
an', tcdLName :: LIdP GhcPs
tcdLName = LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ltycon', tcdTyVars :: LHsQTyVars GhcPs
tcdTyVars = LHsQTyVars GhcPs
tyvars'
                     , tcdFixity :: LexicalFixity
tcdFixity = LexicalFixity
fixity, tcdDataDefn :: HsDataDefn GhcPs
tcdDataDefn = HsDataDefn GhcPs
defn' })

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

  exact (ClassDecl {tcdCExt :: forall pass. TyClDecl pass -> XClassDecl pass
tcdCExt = (EpAnn [AddEpAnn]
an, AnnSortKey
sortKey),
                    tcdLayout :: forall pass. TyClDecl pass -> LayoutInfo pass
tcdLayout = LayoutInfo GhcPs
lo,
                    tcdCtxt :: forall pass. TyClDecl pass -> Maybe (LHsContext pass)
tcdCtxt = Maybe (LHsContext GhcPs)
context, tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdLName = LIdP GhcPs
lclas, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcPs
tyvars,
                    tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdFixity = LexicalFixity
fixity,
                    tcdFDs :: forall pass. TyClDecl pass -> [LHsFunDep pass]
tcdFDs  = [LHsFunDep GhcPs]
fds,
                    tcdSigs :: forall pass. TyClDecl pass -> [LSig pass]
tcdSigs = [LSig GhcPs]
sigs, tcdMeths :: forall pass. TyClDecl pass -> LHsBinds pass
tcdMeths = LHsBinds GhcPs
methods,
                    tcdATs :: forall pass. TyClDecl pass -> [LFamilyDecl pass]
tcdATs = [LFamilyDecl GhcPs]
ats, tcdATDefs :: forall pass. TyClDecl pass -> [LTyFamDefltDecl pass]
tcdATDefs = [LTyFamInstDecl GhcPs]
at_defs,
                    tcdDocs :: forall pass. TyClDecl pass -> [LDocDecl pass]
tcdDocs = [LDocDecl GhcPs]
_docs})
      -- TODO: add a test that demonstrates tcdDocs
      | [LocatedAn AnnListItem (Sig GhcPs)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LSig GhcPs]
[LocatedAn AnnListItem (Sig GhcPs)]
sigs Bool -> Bool -> Bool
&& Bag (LocatedAn AnnListItem (HsBind GhcPs)) -> Bool
forall a. Bag a -> Bool
isEmptyBag LHsBinds GhcPs
Bag (LocatedAn AnnListItem (HsBind GhcPs))
methods Bool -> Bool -> Bool
&& [LocatedAn AnnListItem (FamilyDecl GhcPs)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LFamilyDecl GhcPs]
[LocatedAn AnnListItem (FamilyDecl GhcPs)]
ats Bool -> Bool -> Bool
&& [LocatedAn AnnListItem (TyFamInstDecl GhcPs)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LTyFamInstDecl GhcPs]
[LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
at_defs -- No "where" part
      = do
          (EpAnn [AddEpAnn]
an0, [GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds', GenLocated SrcSpanAnnN RdrName
lclas', LHsQTyVars GhcPs
tyvars',Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
context') <- RWST
  (EPOptions m w)
  (EPWriter w)
  EPState
  m
  (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (FunDep GhcPs)],
   GenLocated SrcSpanAnnN RdrName, LHsQTyVars GhcPs,
   Maybe
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
top_matter
          EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC
          EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC
          TyClDecl GhcPs -> EP w m (TyClDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassDecl {tcdCExt :: XClassDecl GhcPs
tcdCExt = (EpAnn [AddEpAnn]
an2, AnnSortKey
sortKey),
                             tcdLayout :: LayoutInfo GhcPs
tcdLayout = LayoutInfo GhcPs
lo,
                             tcdCtxt :: Maybe (LHsContext GhcPs)
tcdCtxt = Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
context', tcdLName :: LIdP GhcPs
tcdLName = LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
lclas', tcdTyVars :: LHsQTyVars GhcPs
tcdTyVars = LHsQTyVars GhcPs
tyvars',
                             tcdFixity :: LexicalFixity
tcdFixity = LexicalFixity
fixity,
                             tcdFDs :: [LHsFunDep GhcPs]
tcdFDs  = [LHsFunDep GhcPs]
[GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds',
                             tcdSigs :: [LSig GhcPs]
tcdSigs = [LSig GhcPs]
sigs, tcdMeths :: LHsBinds GhcPs
tcdMeths = LHsBinds GhcPs
methods,
                             tcdATs :: [LFamilyDecl GhcPs]
tcdATs = [LFamilyDecl GhcPs]
ats, tcdATDefs :: [LTyFamInstDecl GhcPs]
tcdATDefs = [LTyFamInstDecl GhcPs]
at_defs,
                             tcdDocs :: [LDocDecl GhcPs]
tcdDocs = [LDocDecl GhcPs]
_docs})

      | Bool
otherwise       -- Laid out
      = do
          (EpAnn [AddEpAnn]
an0, [GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds', GenLocated SrcSpanAnnN RdrName
lclas', LHsQTyVars GhcPs
tyvars',Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
context') <- RWST
  (EPOptions m w)
  (EPWriter w)
  EPState
  m
  (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (FunDep GhcPs)],
   GenLocated SrcSpanAnnN RdrName, LHsQTyVars GhcPs,
   Maybe
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
top_matter
          EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL    EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC
          EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnSemi
          [Dynamic]
ds <- AnnSortKey -> [(RealSrcSpan, EP w m Dynamic)] -> EP w m [Dynamic]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnSortKey -> [(RealSrcSpan, EP w m Dynamic)] -> EP w m [Dynamic]
withSortKey AnnSortKey
sortKey
                               ([LocatedAn AnnListItem (Sig GhcPs)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
[LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationA [LSig GhcPs]
[LocatedAn AnnListItem (Sig GhcPs)]
sigs
                             [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall a. [a] -> [a] -> [a]
++ [LocatedAn AnnListItem (HsBind GhcPs)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
[LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationA (Bag (LocatedAn AnnListItem (HsBind GhcPs))
-> [LocatedAn AnnListItem (HsBind GhcPs)]
forall a. Bag a -> [a]
bagToList LHsBinds GhcPs
Bag (LocatedAn AnnListItem (HsBind GhcPs))
methods)
                             [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall a. [a] -> [a] -> [a]
++ [LocatedAn AnnListItem (FamilyDecl GhcPs)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
[LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationA [LFamilyDecl GhcPs]
[LocatedAn AnnListItem (FamilyDecl GhcPs)]
ats
                             [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall a. [a] -> [a] -> [a]
++ [LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
-> [(RealSrcSpan, EP w m Dynamic)]
forall (m :: * -> *) w an a.
(Monad m, Monoid w, ExactPrint (LocatedAn an a)) =>
[LocatedAn an a] -> [(RealSrcSpan, EP w m Dynamic)]
prepareListAnnotationA [LTyFamInstDecl GhcPs]
[LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
at_defs
                             -- ++ prepareListAnnotation docs
                               )
          EpAnn [AddEpAnn]
an3 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an2 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC
          let
            sigs' :: [LocatedAn AnnListItem (Sig GhcPs)]
sigs'    = [Dynamic] -> [LocatedAn AnnListItem (Sig GhcPs)]
forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds
            methods' :: Bag (LocatedAn AnnListItem (HsBind GhcPs))
methods' = [LocatedAn AnnListItem (HsBind GhcPs)]
-> Bag (LocatedAn AnnListItem (HsBind GhcPs))
forall a. [a] -> Bag a
listToBag ([LocatedAn AnnListItem (HsBind GhcPs)]
 -> Bag (LocatedAn AnnListItem (HsBind GhcPs)))
-> [LocatedAn AnnListItem (HsBind GhcPs)]
-> Bag (LocatedAn AnnListItem (HsBind GhcPs))
forall a b. (a -> b) -> a -> b
$ [Dynamic] -> [LocatedAn AnnListItem (HsBind GhcPs)]
forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds
            ats' :: [LocatedAn AnnListItem (FamilyDecl GhcPs)]
ats'     = [Dynamic] -> [LocatedAn AnnListItem (FamilyDecl GhcPs)]
forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds
            at_defs' :: [LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
at_defs' = [Dynamic] -> [LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
forall a. Typeable a => [Dynamic] -> [a]
undynamic [Dynamic]
ds
          TyClDecl GhcPs -> EP w m (TyClDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassDecl {tcdCExt :: XClassDecl GhcPs
tcdCExt = (EpAnn [AddEpAnn]
an3, AnnSortKey
sortKey),
                             tcdLayout :: LayoutInfo GhcPs
tcdLayout = LayoutInfo GhcPs
lo,
                             tcdCtxt :: Maybe (LHsContext GhcPs)
tcdCtxt = Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
context', tcdLName :: LIdP GhcPs
tcdLName = LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
lclas', tcdTyVars :: LHsQTyVars GhcPs
tcdTyVars = LHsQTyVars GhcPs
tyvars',
                             tcdFixity :: LexicalFixity
tcdFixity = LexicalFixity
fixity,
                             tcdFDs :: [LHsFunDep GhcPs]
tcdFDs  = [LHsFunDep GhcPs]
[GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds',
                             tcdSigs :: [LSig GhcPs]
tcdSigs = [LSig GhcPs]
[LocatedAn AnnListItem (Sig GhcPs)]
sigs', tcdMeths :: LHsBinds GhcPs
tcdMeths = LHsBinds GhcPs
Bag (LocatedAn AnnListItem (HsBind GhcPs))
methods',
                             tcdATs :: [LFamilyDecl GhcPs]
tcdATs = [LFamilyDecl GhcPs]
[LocatedAn AnnListItem (FamilyDecl GhcPs)]
ats', tcdATDefs :: [LTyFamInstDecl GhcPs]
tcdATDefs = [LTyFamInstDecl GhcPs]
[LocatedAn AnnListItem (TyFamInstDecl GhcPs)]
at_defs',
                             tcdDocs :: [LDocDecl GhcPs]
tcdDocs = [LDocDecl GhcPs]
_docs})
      where
        top_matter :: RWST
  (EPOptions m w)
  (EPWriter w)
  EPState
  m
  (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (FunDep GhcPs)],
   GenLocated SrcSpanAnnN RdrName, LHsQTyVars GhcPs,
   Maybe
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
top_matter = do
          EpAnn [AddEpAnn]
an' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> [AnnKeywordId]
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> [AnnKeywordId] -> EP w m (EpAnn a)
annotationsToComments EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl  [AnnKeywordId
AnnOpenP, AnnKeywordId
AnnCloseP]
          EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClass
          (EpAnn [AddEpAnn]
_, GenLocated SrcSpanAnnN RdrName
lclas', LHsQTyVars GhcPs
tyvars',()
_,Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
context') <-  GenLocated SrcSpanAnnN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      LHsQTyVars GhcPs, (), Maybe (LHsContext GhcPs))
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated SrcSpanAnnN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      LHsQTyVars GhcPs, (), Maybe (LHsContext GhcPs))
exactVanillaDeclHead LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
lclas LHsQTyVars GhcPs
tyvars LexicalFixity
fixity Maybe (LHsContext GhcPs)
context
          (EpAnn [AddEpAnn]
an1, [GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds') <- if ([GenLocated SrcSpanAnnA (FunDep GhcPs)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LHsFunDep GhcPs]
[GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds)
            then (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (FunDep GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (FunDep GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, [LHsFunDep GhcPs]
[GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds)
            else do
              EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnVbar
              [GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds' <- [GenLocated SrcSpanAnnA (FunDep GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (FunDep GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsFunDep GhcPs]
[GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds
              (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (FunDep GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (FunDep GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, [GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds')
          EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnWhere
          (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (FunDep GhcPs)],
 GenLocated SrcSpanAnnN RdrName, LHsQTyVars GhcPs,
 Maybe
   (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (FunDep GhcPs)],
      GenLocated SrcSpanAnnN RdrName, LHsQTyVars GhcPs,
      Maybe
        (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an2, [GenLocated SrcSpanAnnA (FunDep GhcPs)]
fds', GenLocated SrcSpanAnnN RdrName
lclas', LHsQTyVars GhcPs
tyvars',Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
context')


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

instance ExactPrint (FunDep GhcPs) where
  getAnnotationEntry :: FunDep GhcPs -> Entry
getAnnotationEntry (FunDep XCFunDep GhcPs
an [LIdP GhcPs]
_ [LIdP GhcPs]
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCFunDep GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: FunDep GhcPs -> Anchor -> EpAnnComments -> FunDep GhcPs
setAnnotationAnchor (FunDep XCFunDep GhcPs
an [LIdP GhcPs]
a [LIdP GhcPs]
b) Anchor
anc EpAnnComments
cs = XCFunDep GhcPs -> [LIdP GhcPs] -> [LIdP GhcPs] -> FunDep GhcPs
forall pass.
XCFunDep pass -> [LIdP pass] -> [LIdP pass] -> FunDep pass
FunDep (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCFunDep GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) [LIdP GhcPs]
a [LIdP GhcPs]
b

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
FunDep GhcPs -> EP w m (FunDep GhcPs)
exact (FunDep XCFunDep GhcPs
an [LIdP GhcPs]
ls [LIdP GhcPs]
rs') = do
    [GenLocated SrcSpanAnnN RdrName]
ls' <- [GenLocated SrcSpanAnnN RdrName]
-> EP w m [GenLocated SrcSpanAnnN RdrName]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
ls
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCFunDep GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnRarrow
    [GenLocated SrcSpanAnnN RdrName]
rs'' <- [GenLocated SrcSpanAnnN RdrName]
-> EP w m [GenLocated SrcSpanAnnN RdrName]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
rs'
    FunDep GhcPs -> EP w m (FunDep GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCFunDep GhcPs -> [LIdP GhcPs] -> [LIdP GhcPs] -> FunDep GhcPs
forall pass.
XCFunDep pass -> [LIdP pass] -> [LIdP pass] -> FunDep pass
FunDep XCFunDep GhcPs
EpAnn [AddEpAnn]
an0 [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
ls' [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
rs'')

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

instance ExactPrint (FamilyDecl GhcPs) where
  getAnnotationEntry :: FamilyDecl GhcPs -> Entry
getAnnotationEntry (FamilyDecl { fdExt :: forall pass. FamilyDecl pass -> XCFamilyDecl pass
fdExt = XCFamilyDecl GhcPs
an }) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCFamilyDecl GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: FamilyDecl GhcPs -> Anchor -> EpAnnComments -> FamilyDecl GhcPs
setAnnotationAnchor FamilyDecl GhcPs
x Anchor
anc EpAnnComments
cs = FamilyDecl GhcPs
x { fdExt = setAnchorEpa (fdExt x) anc cs}

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
FamilyDecl GhcPs -> EP w m (FamilyDecl GhcPs)
exact (FamilyDecl { fdExt :: forall pass. FamilyDecl pass -> XCFamilyDecl pass
fdExt = XCFamilyDecl GhcPs
an
                    , fdInfo :: forall pass. FamilyDecl pass -> FamilyInfo pass
fdInfo = FamilyInfo GhcPs
info
                    , fdTopLevel :: forall pass. FamilyDecl pass -> TopLevelFlag
fdTopLevel = TopLevelFlag
top_level
                    , fdLName :: forall pass. FamilyDecl pass -> LIdP pass
fdLName = LIdP GhcPs
ltycon
                    , fdTyVars :: forall pass. FamilyDecl pass -> LHsQTyVars pass
fdTyVars = LHsQTyVars GhcPs
tyvars
                    , fdFixity :: forall pass. FamilyDecl pass -> LexicalFixity
fdFixity = LexicalFixity
fixity
                    , fdResultSig :: forall pass. FamilyDecl pass -> LFamilyResultSig pass
fdResultSig = L SrcAnn NoEpAnns
lr FamilyResultSig GhcPs
result
                    , fdInjectivityAnn :: forall pass. FamilyDecl pass -> Maybe (LInjectivityAnn pass)
fdInjectivityAnn = Maybe (LInjectivityAnn GhcPs)
mb_inj }) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn] -> FamilyInfo GhcPs -> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn] -> FamilyInfo GhcPs -> EP w m (EpAnn [AddEpAnn])
exactFlavour XCFamilyDecl GhcPs
EpAnn [AddEpAnn]
an FamilyInfo GhcPs
info
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
exact_top_level EpAnn [AddEpAnn]
an0
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> [AnnKeywordId]
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> [AnnKeywordId] -> EP w m (EpAnn a)
annotationsToComments EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl [AnnKeywordId
AnnOpenP,AnnKeywordId
AnnCloseP]
    (EpAnn [AddEpAnn]
_, GenLocated SrcSpanAnnN RdrName
ltycon', LHsQTyVars GhcPs
tyvars',()
_,Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
_) <- GenLocated SrcSpanAnnN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      LHsQTyVars GhcPs, (), Maybe (LHsContext GhcPs))
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated SrcSpanAnnN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      LHsQTyVars GhcPs, (), Maybe (LHsContext GhcPs))
exactVanillaDeclHead LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ltycon LHsQTyVars GhcPs
tyvars LexicalFixity
fixity Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall a. Maybe a
Nothing
    (EpAnn [AddEpAnn]
an3, FamilyResultSig GhcPs
result') <- EpAnn [AddEpAnn]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], FamilyResultSig GhcPs)
exact_kind EpAnn [AddEpAnn]
an2
    (EpAnn [AddEpAnn]
an4, Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs))
mb_inj') <-
      case Maybe (LInjectivityAnn GhcPs)
mb_inj of
        Maybe (LInjectivityAnn GhcPs)
Nothing -> (EpAnn [AddEpAnn],
 Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs)))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn],
      Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an3, Maybe (LInjectivityAnn GhcPs)
Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs))
mb_inj)
        Just LInjectivityAnn GhcPs
inj -> do
          EpAnn [AddEpAnn]
an4 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an3 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnVbar
          GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs)
inj' <- GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LInjectivityAnn GhcPs
GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs)
inj
          (EpAnn [AddEpAnn],
 Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs)))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn],
      Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an4, GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs)
-> Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs))
forall a. a -> Maybe a
Just GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs)
inj')
    (EpAnn [AddEpAnn]
an5, FamilyInfo GhcPs
info') <-
             case FamilyInfo GhcPs
info of
               ClosedTypeFamily Maybe [LTyFamInstEqn GhcPs]
mb_eqns -> do
                 EpAnn [AddEpAnn]
an5 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an4 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnWhere
                 EpAnn [AddEpAnn]
an6 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an5 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC
                 (EpAnn [AddEpAnn]
an7, Maybe
  [GenLocated
     SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
mb_eqns') <-
                   case Maybe [LTyFamInstEqn GhcPs]
mb_eqns of
                     Maybe [LTyFamInstEqn GhcPs]
Nothing -> do
                       EpAnn [AddEpAnn]
an7 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an6 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDotdot
                       (EpAnn [AddEpAnn],
 Maybe
   [GenLocated
      SrcSpanAnnA
      (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn],
      Maybe
        [GenLocated
           SrcSpanAnnA
           (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an7, Maybe [LTyFamInstEqn GhcPs]
Maybe
  [GenLocated
     SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
mb_eqns)
                     Just [LTyFamInstEqn GhcPs]
eqns -> do
                       [GenLocated
   SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
eqns' <- [GenLocated
   SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LTyFamInstEqn GhcPs]
[GenLocated
   SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
eqns
                       (EpAnn [AddEpAnn],
 Maybe
   [GenLocated
      SrcSpanAnnA
      (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn],
      Maybe
        [GenLocated
           SrcSpanAnnA
           (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an6, [GenLocated
   SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
-> Maybe
     [GenLocated
        SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
forall a. a -> Maybe a
Just [GenLocated
   SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
eqns')
                 EpAnn [AddEpAnn]
an8 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an7 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC
                 (EpAnn [AddEpAnn], FamilyInfo GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], FamilyInfo GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an8, Maybe [LTyFamInstEqn GhcPs] -> FamilyInfo GhcPs
forall pass. Maybe [LTyFamInstEqn pass] -> FamilyInfo pass
ClosedTypeFamily Maybe [LTyFamInstEqn GhcPs]
Maybe
  [GenLocated
     SrcSpanAnnA (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))]
mb_eqns')
               FamilyInfo GhcPs
_ -> (EpAnn [AddEpAnn], FamilyInfo GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], FamilyInfo GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an4, FamilyInfo GhcPs
info)
    FamilyDecl GhcPs -> EP w m (FamilyDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (FamilyDecl { fdExt :: XCFamilyDecl GhcPs
fdExt = XCFamilyDecl GhcPs
EpAnn [AddEpAnn]
an5
                       , fdInfo :: FamilyInfo GhcPs
fdInfo = FamilyInfo GhcPs
info'
                       , fdTopLevel :: TopLevelFlag
fdTopLevel = TopLevelFlag
top_level
                       , fdLName :: LIdP GhcPs
fdLName = LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
ltycon'
                       , fdTyVars :: LHsQTyVars GhcPs
fdTyVars = LHsQTyVars GhcPs
tyvars'
                       , fdFixity :: LexicalFixity
fdFixity = LexicalFixity
fixity
                       , fdResultSig :: LFamilyResultSig GhcPs
fdResultSig = SrcAnn NoEpAnns
-> FamilyResultSig GhcPs
-> GenLocated (SrcAnn NoEpAnns) (FamilyResultSig GhcPs)
forall l e. l -> e -> GenLocated l e
L SrcAnn NoEpAnns
lr FamilyResultSig GhcPs
result'
                       , fdInjectivityAnn :: Maybe (LInjectivityAnn GhcPs)
fdInjectivityAnn = Maybe (LInjectivityAnn GhcPs)
Maybe (GenLocated (SrcAnn NoEpAnns) (InjectivityAnn GhcPs))
mb_inj' })
    where
      exact_top_level :: EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
exact_top_level EpAnn [AddEpAnn]
an' =
        case TopLevelFlag
top_level of
          TopLevelFlag
TopLevel    -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnFamily
          TopLevelFlag
NotTopLevel -> do
            -- It seems that in some kind of legacy
            -- mode the 'family' keyword is still
            -- accepted.
            EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnFamily

      exact_kind :: EpAnn [AddEpAnn]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], FamilyResultSig GhcPs)
exact_kind EpAnn [AddEpAnn]
an' =
        case FamilyResultSig GhcPs
result of
          NoSig    XNoSig GhcPs
_         -> (EpAnn [AddEpAnn], FamilyResultSig GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], FamilyResultSig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an', FamilyResultSig GhcPs
result)
          KindSig  XCKindSig GhcPs
x LHsType GhcPs
kind    -> do
            EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
            GenLocated SrcSpanAnnA (HsType GhcPs)
kind' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
kind
            (EpAnn [AddEpAnn], FamilyResultSig GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], FamilyResultSig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, XCKindSig GhcPs -> LHsType GhcPs -> FamilyResultSig GhcPs
forall pass. XCKindSig pass -> LHsKind pass -> FamilyResultSig pass
KindSig  XCKindSig GhcPs
x LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
kind')
          TyVarSig XTyVarSig GhcPs
x LHsTyVarBndr () GhcPs
tv_bndr -> do
            EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnEqual
            GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
tv_bndr' <- GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsTyVarBndr () GhcPs
GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
tv_bndr
            (EpAnn [AddEpAnn], FamilyResultSig GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], FamilyResultSig GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, XTyVarSig GhcPs -> LHsTyVarBndr () GhcPs -> FamilyResultSig GhcPs
forall pass.
XTyVarSig pass -> LHsTyVarBndr () pass -> FamilyResultSig pass
TyVarSig XTyVarSig GhcPs
x LHsTyVarBndr () GhcPs
GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
tv_bndr')


exactFlavour :: (Monad m, Monoid w) => EpAnn [AddEpAnn] -> FamilyInfo GhcPs -> EP w m (EpAnn [AddEpAnn])
exactFlavour :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn] -> FamilyInfo GhcPs -> EP w m (EpAnn [AddEpAnn])
exactFlavour EpAnn [AddEpAnn]
an FamilyInfo GhcPs
DataFamily            = EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnData
exactFlavour EpAnn [AddEpAnn]
an FamilyInfo GhcPs
OpenTypeFamily        = EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnType
exactFlavour EpAnn [AddEpAnn]
an (ClosedTypeFamily {}) = EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnType

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

exactDataDefn
  :: (Monad m, Monoid w)
  => EpAnn [AddEpAnn]
  -> (Maybe (LHsContext GhcPs) -> EP w m (EpAnn [AddEpAnn]
                                         , LocatedN RdrName
                                         , a
                                         , b
                                         , Maybe (LHsContext GhcPs))) -- Printing the header
  -> HsDataDefn GhcPs
  -> EP w m ( EpAnn [AddEpAnn] -- ^ from exactHdr
            , EpAnn [AddEpAnn] -- ^ updated one passed in
            , LocatedN RdrName, a, b, Maybe (LHsContext GhcPs), HsDataDefn GhcPs)
exactDataDefn :: forall (m :: * -> *) w a b.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> (Maybe (LHsContext GhcPs)
    -> EP
         w
         m
         (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName, a, b,
          Maybe (LHsContext GhcPs)))
-> HsDataDefn GhcPs
-> EP
     w
     m
     (EpAnn [AddEpAnn], EpAnn [AddEpAnn],
      GenLocated SrcSpanAnnN RdrName, a, b, Maybe (LHsContext GhcPs),
      HsDataDefn GhcPs)
exactDataDefn EpAnn [AddEpAnn]
an Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName, a, b,
      Maybe (LHsContext GhcPs))
exactHdr
                 (HsDataDefn { dd_ext :: forall pass. HsDataDefn pass -> XCHsDataDefn pass
dd_ext = XCHsDataDefn GhcPs
x, dd_ctxt :: forall pass. HsDataDefn pass -> Maybe (LHsContext pass)
dd_ctxt = Maybe (LHsContext GhcPs)
context
                             , dd_cType :: forall pass. HsDataDefn pass -> Maybe (XRec pass CType)
dd_cType = Maybe (XRec GhcPs CType)
mb_ct
                             , dd_kindSig :: forall pass. HsDataDefn pass -> Maybe (LHsKind pass)
dd_kindSig = Maybe (LHsType GhcPs)
mb_sig
                             , dd_cons :: forall pass. HsDataDefn pass -> DataDefnCons (LConDecl pass)
dd_cons = DataDefnCons (LConDecl GhcPs)
condecls, dd_derivs :: forall pass. HsDataDefn pass -> HsDeriving pass
dd_derivs = HsDeriving GhcPs
derivings }) = do

  EpAnn [AddEpAnn]
an' <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> [AnnKeywordId]
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> [AnnKeywordId] -> EP w m (EpAnn a)
annotationsToComments EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl [AnnKeywordId
AnnOpenP, AnnKeywordId
AnnCloseP]

  EpAnn [AddEpAnn]
an00 <- if DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs)) -> Bool
forall a. DataDefnCons a -> Bool
isTypeDataDefnCons DataDefnCons (LConDecl GhcPs)
DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
condecls
           then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an' ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnType
           else EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn [AddEpAnn]
an'

  EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an00 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl (AnnKeywordId -> EP w m (EpAnn [AddEpAnn]))
-> AnnKeywordId -> EP w m (EpAnn [AddEpAnn])
forall a b. (a -> b) -> a -> b
$ case DataDefnCons (LConDecl GhcPs)
condecls of
    DataTypeCons Bool
_ [LConDecl GhcPs]
_ -> AnnKeywordId
AnnData
    NewTypeCon   LConDecl GhcPs
_ -> AnnKeywordId
AnnNewtype

  EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnInstance -- optional
  Maybe (GenLocated SrcSpanAnnP CType)
mb_ct' <- (GenLocated SrcSpanAnnP CType
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnP CType))
-> Maybe (GenLocated SrcSpanAnnP CType)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (GenLocated SrcSpanAnnP CType))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM GenLocated SrcSpanAnnP CType
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnP CType)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (XRec GhcPs CType)
Maybe (GenLocated SrcSpanAnnP CType)
mb_ct
  (EpAnn [AddEpAnn]
anx, GenLocated SrcSpanAnnN RdrName
ln', a
tvs', b
b, Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mctxt') <- Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName, a, b,
      Maybe (LHsContext GhcPs))
exactHdr Maybe (LHsContext GhcPs)
context
  (EpAnn [AddEpAnn]
an2, Maybe (GenLocated SrcSpanAnnA (HsType GhcPs))
mb_sig') <- case Maybe (LHsType GhcPs)
mb_sig of
    Maybe (LHsType GhcPs)
Nothing -> (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsType GhcPs)))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, Maybe (GenLocated SrcSpanAnnA (HsType GhcPs))
forall a. Maybe a
Nothing)
    Just LHsType GhcPs
kind -> do
      EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
      GenLocated SrcSpanAnnA (HsType GhcPs)
kind' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
kind
      (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsType GhcPs)))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], Maybe (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an2, GenLocated SrcSpanAnnA (HsType GhcPs)
-> Maybe (GenLocated SrcSpanAnnA (HsType GhcPs))
forall a. a -> Maybe a
Just GenLocated SrcSpanAnnA (HsType GhcPs)
kind')
  EpAnn [AddEpAnn]
an3 <- if (DataDefnCons (LConDecl GhcPs) -> Bool
forall (p :: Pass). DataDefnCons (LConDecl (GhcPass p)) -> Bool
needsWhere DataDefnCons (LConDecl GhcPs)
condecls)
    then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an2 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnWhere
    else EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn [AddEpAnn]
an2
  EpAnn [AddEpAnn]
an4 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an3 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC
  (EpAnn [AddEpAnn]
an5, [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
condecls') <- EpAnn [AddEpAnn]
-> [LConDecl GhcPs] -> EP w m (EpAnn [AddEpAnn], [LConDecl GhcPs])
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> [LConDecl GhcPs] -> EP w m (EpAnn [AddEpAnn], [LConDecl GhcPs])
exact_condecls EpAnn [AddEpAnn]
an4 (DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
-> [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
forall a. DataDefnCons a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList DataDefnCons (LConDecl GhcPs)
DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
condecls)
  let condecls'' :: DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
condecls'' = case DataDefnCons (LConDecl GhcPs)
condecls of
        DataTypeCons Bool
d [LConDecl GhcPs]
_ -> Bool
-> [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
-> DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall a. Bool -> [a] -> DataDefnCons a
DataTypeCons Bool
d [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
condecls'
        NewTypeCon LConDecl GhcPs
_     -> case [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
condecls' of
          [GenLocated SrcSpanAnnA (ConDecl GhcPs)
decl] -> GenLocated SrcSpanAnnA (ConDecl GhcPs)
-> DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall a. a -> DataDefnCons a
NewTypeCon GenLocated SrcSpanAnnA (ConDecl GhcPs)
decl
          [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
_ -> String -> DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall a. HasCallStack => String -> a
panic String
"exacprint NewTypeCon"
  EpAnn [AddEpAnn]
an6 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an5 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC
  [GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcPs)]
derivings' <- (GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcPs)
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcPs)))
-> [GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcPs)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsDeriving GhcPs
[GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcPs)]
derivings
  (EpAnn [AddEpAnn], EpAnn [AddEpAnn],
 GenLocated SrcSpanAnnN RdrName, a, b,
 Maybe
   (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]),
 HsDataDefn GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], EpAnn [AddEpAnn],
      GenLocated SrcSpanAnnN RdrName, a, b,
      Maybe
        (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]),
      HsDataDefn GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
anx, EpAnn [AddEpAnn]
an6, GenLocated SrcSpanAnnN RdrName
ln', a
tvs', b
b, Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mctxt',
                 (HsDataDefn { dd_ext :: XCHsDataDefn GhcPs
dd_ext = XCHsDataDefn GhcPs
x, dd_ctxt :: Maybe (LHsContext GhcPs)
dd_ctxt = Maybe (LHsContext GhcPs)
context
                             , dd_cType :: Maybe (XRec GhcPs CType)
dd_cType = Maybe (XRec GhcPs CType)
Maybe (GenLocated SrcSpanAnnP CType)
mb_ct'
                             , dd_kindSig :: Maybe (LHsType GhcPs)
dd_kindSig = Maybe (LHsType GhcPs)
Maybe (GenLocated SrcSpanAnnA (HsType GhcPs))
mb_sig'
                             , dd_cons :: DataDefnCons (LConDecl GhcPs)
dd_cons = DataDefnCons (LConDecl GhcPs)
DataDefnCons (GenLocated SrcSpanAnnA (ConDecl GhcPs))
condecls'', dd_derivs :: HsDeriving GhcPs
dd_derivs = HsDeriving GhcPs
[GenLocated (SrcAnn NoEpAnns) (HsDerivingClause GhcPs)]
derivings' }))


exactVanillaDeclHead :: (Monad m, Monoid w)
                     => LocatedN RdrName
                     -> LHsQTyVars GhcPs
                     -> LexicalFixity
                     -> Maybe (LHsContext GhcPs)
                     -> EP w m ( EpAnn [AddEpAnn]
                               , LocatedN RdrName
                               , LHsQTyVars GhcPs
                               , (), Maybe (LHsContext GhcPs))
exactVanillaDeclHead :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated SrcSpanAnnN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> Maybe (LHsContext GhcPs)
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      LHsQTyVars GhcPs, (), Maybe (LHsContext GhcPs))
exactVanillaDeclHead GenLocated SrcSpanAnnN RdrName
thing tvs :: LHsQTyVars GhcPs
tvs@(HsQTvs { hsq_explicit :: forall pass. LHsQTyVars pass -> [LHsTyVarBndr () pass]
hsq_explicit = [LHsTyVarBndr () GhcPs]
tyvars }) LexicalFixity
fixity Maybe (LHsContext GhcPs)
context = do
  let
    exact_tyvars :: [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
exact_tyvars (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
varl:[GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
varsr)
      | LexicalFixity
fixity LexicalFixity -> LexicalFixity -> Bool
forall a. Eq a => a -> a -> Bool
== LexicalFixity
Infix Bool -> Bool -> Bool
&& [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
varsr Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1 = do
          GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
varl' <- GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
varl
          GenLocated SrcSpanAnnN RdrName
thing' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated SrcSpanAnnN RdrName
thing
          GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
hvarsr <- GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ([GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
forall a. HasCallStack => [a] -> a
head [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
varsr)
          [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
tvarsr <- [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated ([GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall a. HasCallStack => [a] -> [a]
tail [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
varsr)
          (GenLocated SrcSpanAnnN RdrName,
 [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnN RdrName
thing', GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
varl'GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall a. a -> [a] -> [a]
:GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
hvarsrGenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall a. a -> [a] -> [a]
:[GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
tvarsr)
      | LexicalFixity
fixity LexicalFixity -> LexicalFixity -> Bool
forall a. Eq a => a -> a -> Bool
== LexicalFixity
Infix = do
          GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
varl' <- GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
varl
          GenLocated SrcSpanAnnN RdrName
thing' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated SrcSpanAnnN RdrName
thing
          [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
varsr' <- [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
varsr
          (GenLocated SrcSpanAnnN RdrName,
 [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnN RdrName
thing', GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
varl'GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall a. a -> [a] -> [a]
:[GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
varsr')
      | Bool
otherwise = do
          GenLocated SrcSpanAnnN RdrName
thing' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated SrcSpanAnnN RdrName
thing
          [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
vs <- (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
 -> EP w m (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)))
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated (GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
varlGenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall a. a -> [a] -> [a]
:[GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
varsr)
          (GenLocated SrcSpanAnnN RdrName,
 [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnN RdrName
thing', [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
vs)
    exact_tyvars [] = do
      GenLocated SrcSpanAnnN RdrName
thing' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated SrcSpanAnnN RdrName
thing
      (GenLocated SrcSpanAnnN RdrName,
 [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnN RdrName
thing', [])
  Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
context' <- (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
-> Maybe
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe
        (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
context
  (GenLocated SrcSpanAnnN RdrName
thing', [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
tyvars') <- [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)])
exact_tyvars [LHsTyVarBndr () GhcPs]
[GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
tyvars
  (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
 LHsQTyVars GhcPs, (),
 Maybe
   (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      LHsQTyVars GhcPs, (),
      Maybe
        (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
forall ann. EpAnn ann
EpAnnNotUsed, GenLocated SrcSpanAnnN RdrName
thing', LHsQTyVars GhcPs
tvs { hsq_explicit = tyvars' }, (), Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
context')

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

instance ExactPrint (InjectivityAnn GhcPs) where
  getAnnotationEntry :: InjectivityAnn GhcPs -> Entry
getAnnotationEntry (InjectivityAnn XCInjectivityAnn GhcPs
an LIdP GhcPs
_ [LIdP GhcPs]
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XCInjectivityAnn GhcPs
EpAnn [AddEpAnn]
an
  setAnnotationAnchor :: InjectivityAnn GhcPs
-> Anchor -> EpAnnComments -> InjectivityAnn GhcPs
setAnnotationAnchor (InjectivityAnn XCInjectivityAnn GhcPs
an LIdP GhcPs
a [LIdP GhcPs]
b) Anchor
anc EpAnnComments
cs = XCInjectivityAnn GhcPs
-> LIdP GhcPs -> [LIdP GhcPs] -> InjectivityAnn GhcPs
forall pass.
XCInjectivityAnn pass
-> LIdP pass -> [LIdP pass] -> InjectivityAnn pass
InjectivityAnn (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XCInjectivityAnn GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LIdP GhcPs
a [LIdP GhcPs]
b
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
InjectivityAnn GhcPs -> EP w m (InjectivityAnn GhcPs)
exact (InjectivityAnn XCInjectivityAnn GhcPs
an LIdP GhcPs
lhs [LIdP GhcPs]
rhs) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCInjectivityAnn GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnVbar
    GenLocated SrcSpanAnnN RdrName
lhs' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
lhs
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnRarrow
    [GenLocated SrcSpanAnnN RdrName]
rhs' <- (GenLocated SrcSpanAnnN RdrName
 -> EP w m (GenLocated SrcSpanAnnN RdrName))
-> [GenLocated SrcSpanAnnN RdrName]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated SrcSpanAnnN RdrName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
rhs
    InjectivityAnn GhcPs -> EP w m (InjectivityAnn GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XCInjectivityAnn GhcPs
-> LIdP GhcPs -> [LIdP GhcPs] -> InjectivityAnn GhcPs
forall pass.
XCInjectivityAnn pass
-> LIdP pass -> [LIdP pass] -> InjectivityAnn pass
InjectivityAnn XCInjectivityAnn GhcPs
EpAnn [AddEpAnn]
an1 LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
lhs' [LIdP GhcPs]
[GenLocated SrcSpanAnnN RdrName]
rhs')

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

class Typeable flag => ExactPrintTVFlag flag where
  exactTVDelimiters :: (Monad m, Monoid w)
    => EpAnn [AddEpAnn] -> flag -> EP w m (HsTyVarBndr flag GhcPs)
    -> EP w m (EpAnn [AddEpAnn], (HsTyVarBndr flag GhcPs))

instance ExactPrintTVFlag () where
  exactTVDelimiters :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> ()
-> EP w m (HsTyVarBndr () GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr () GhcPs)
exactTVDelimiters EpAnn [AddEpAnn]
an ()
_ EP w m (HsTyVarBndr () GhcPs)
thing_inside = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
AnnOpenP
    HsTyVarBndr () GhcPs
r <- EP w m (HsTyVarBndr () GhcPs)
thing_inside
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
AnnCloseP
    (EpAnn [AddEpAnn], HsTyVarBndr () GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr () GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, HsTyVarBndr () GhcPs
r)

instance ExactPrintTVFlag Specificity where
  exactTVDelimiters :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> Specificity
-> EP w m (HsTyVarBndr Specificity GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr Specificity GhcPs)
exactTVDelimiters EpAnn [AddEpAnn]
an Specificity
s EP w m (HsTyVarBndr Specificity GhcPs)
thing_inside = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
open
    HsTyVarBndr Specificity GhcPs
r <- EP w m (HsTyVarBndr Specificity GhcPs)
thing_inside
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
close
    (EpAnn [AddEpAnn], HsTyVarBndr Specificity GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr Specificity GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, HsTyVarBndr Specificity GhcPs
r)
    where
      (AnnKeywordId
open, AnnKeywordId
close) = case Specificity
s of
        Specificity
SpecifiedSpec -> (AnnKeywordId
AnnOpenP, AnnKeywordId
AnnCloseP)
        Specificity
InferredSpec  -> (AnnKeywordId
AnnOpenC, AnnKeywordId
AnnCloseC)

instance ExactPrintTVFlag flag => ExactPrint (HsTyVarBndr flag GhcPs) where
  getAnnotationEntry :: HsTyVarBndr flag GhcPs -> Entry
getAnnotationEntry (UserTyVar XUserTyVar GhcPs
an flag
_ LIdP GhcPs
_)     = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XUserTyVar GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (KindedTyVar XKindedTyVar GhcPs
an flag
_ LIdP GhcPs
_ LHsType GhcPs
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XKindedTyVar GhcPs
EpAnn [AddEpAnn]
an

  setAnnotationAnchor :: HsTyVarBndr flag GhcPs
-> Anchor -> EpAnnComments -> HsTyVarBndr flag GhcPs
setAnnotationAnchor (UserTyVar XUserTyVar GhcPs
an flag
a LIdP GhcPs
b)     Anchor
anc EpAnnComments
cs = XUserTyVar GhcPs -> flag -> LIdP GhcPs -> HsTyVarBndr flag GhcPs
forall flag pass.
XUserTyVar pass -> flag -> LIdP pass -> HsTyVarBndr flag pass
UserTyVar (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XUserTyVar GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) flag
a LIdP GhcPs
b
  setAnnotationAnchor (KindedTyVar XKindedTyVar GhcPs
an flag
a LIdP GhcPs
b LHsType GhcPs
c) Anchor
anc EpAnnComments
cs = XKindedTyVar GhcPs
-> flag -> LIdP GhcPs -> LHsType GhcPs -> HsTyVarBndr flag GhcPs
forall flag pass.
XKindedTyVar pass
-> flag -> LIdP pass -> LHsKind pass -> HsTyVarBndr flag pass
KindedTyVar (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XKindedTyVar GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) flag
a LIdP GhcPs
b LHsType GhcPs
c

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsTyVarBndr flag GhcPs -> EP w m (HsTyVarBndr flag GhcPs)
exact (UserTyVar XUserTyVar GhcPs
an flag
flag LIdP GhcPs
n) = do
    (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
r <- EpAnn [AddEpAnn]
-> flag
-> EP w m (HsTyVarBndr flag GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
forall flag (m :: * -> *) w.
(ExactPrintTVFlag flag, Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> flag
-> EP w m (HsTyVarBndr flag GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> flag
-> EP w m (HsTyVarBndr flag GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
exactTVDelimiters XUserTyVar GhcPs
EpAnn [AddEpAnn]
an flag
flag (EP w m (HsTyVarBndr flag GhcPs)
 -> EP w m (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs))
-> EP w m (HsTyVarBndr flag GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
forall a b. (a -> b) -> a -> b
$ do
           GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
           HsTyVarBndr flag GhcPs -> EP w m (HsTyVarBndr flag GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XUserTyVar GhcPs -> flag -> LIdP GhcPs -> HsTyVarBndr flag GhcPs
forall flag pass.
XUserTyVar pass -> flag -> LIdP pass -> HsTyVarBndr flag pass
UserTyVar XUserTyVar GhcPs
an flag
flag LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n')
    case (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
r of
      (EpAnn [AddEpAnn]
an', UserTyVar XUserTyVar GhcPs
_ flag
flag'' LIdP GhcPs
n'') -> HsTyVarBndr flag GhcPs -> EP w m (HsTyVarBndr flag GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XUserTyVar GhcPs -> flag -> LIdP GhcPs -> HsTyVarBndr flag GhcPs
forall flag pass.
XUserTyVar pass -> flag -> LIdP pass -> HsTyVarBndr flag pass
UserTyVar XUserTyVar GhcPs
EpAnn [AddEpAnn]
an' flag
flag'' LIdP GhcPs
n'')
      (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
_ -> String -> EP w m (HsTyVarBndr flag GhcPs)
forall a. HasCallStack => String -> a
error String
"KindedTyVar should never happen here"
  exact (KindedTyVar XKindedTyVar GhcPs
an flag
flag LIdP GhcPs
n LHsType GhcPs
k) = do
    (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
r <- EpAnn [AddEpAnn]
-> flag
-> EP w m (HsTyVarBndr flag GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
forall flag (m :: * -> *) w.
(ExactPrintTVFlag flag, Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> flag
-> EP w m (HsTyVarBndr flag GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> flag
-> EP w m (HsTyVarBndr flag GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
exactTVDelimiters XKindedTyVar GhcPs
EpAnn [AddEpAnn]
an flag
flag (EP w m (HsTyVarBndr flag GhcPs)
 -> EP w m (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs))
-> EP w m (HsTyVarBndr flag GhcPs)
-> EP w m (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
forall a b. (a -> b) -> a -> b
$ do
          GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
          EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XKindedTyVar GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
          GenLocated SrcSpanAnnA (HsType GhcPs)
k' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
k
          HsTyVarBndr flag GhcPs -> EP w m (HsTyVarBndr flag GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XKindedTyVar GhcPs
-> flag -> LIdP GhcPs -> LHsType GhcPs -> HsTyVarBndr flag GhcPs
forall flag pass.
XKindedTyVar pass
-> flag -> LIdP pass -> LHsKind pass -> HsTyVarBndr flag pass
KindedTyVar XKindedTyVar GhcPs
EpAnn [AddEpAnn]
an0 flag
flag LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
k')
    case (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
r of
      (EpAnn [AddEpAnn]
an',KindedTyVar XKindedTyVar GhcPs
_ flag
flag'' LIdP GhcPs
n'' LHsType GhcPs
k'') -> HsTyVarBndr flag GhcPs -> EP w m (HsTyVarBndr flag GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XKindedTyVar GhcPs
-> flag -> LIdP GhcPs -> LHsType GhcPs -> HsTyVarBndr flag GhcPs
forall flag pass.
XKindedTyVar pass
-> flag -> LIdP pass -> LHsKind pass -> HsTyVarBndr flag pass
KindedTyVar XKindedTyVar GhcPs
EpAnn [AddEpAnn]
an' flag
flag'' LIdP GhcPs
n'' LHsType GhcPs
k'')
      (EpAnn [AddEpAnn], HsTyVarBndr flag GhcPs)
_ -> String -> EP w m (HsTyVarBndr flag GhcPs)
forall a. HasCallStack => String -> a
error String
"UserTyVar should never happen here"

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

instance ExactPrint (HsType GhcPs) where
  getAnnotationEntry :: HsType GhcPs -> Entry
getAnnotationEntry (HsForAllTy XForAllTy GhcPs
_ HsForAllTelescope GhcPs
_ LHsType GhcPs
_)        = Entry
NoEntryVal
  getAnnotationEntry (HsQualTy XQualTy GhcPs
_ LHsContext GhcPs
_ LHsType GhcPs
_)          = Entry
NoEntryVal
  getAnnotationEntry (HsTyVar XTyVar GhcPs
an PromotionFlag
_ LIdP GhcPs
_)          = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XTyVar GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsAppTy XAppTy GhcPs
_ LHsType GhcPs
_ LHsType GhcPs
_)           = Entry
NoEntryVal
  getAnnotationEntry (HsAppKindTy XAppKindTy GhcPs
_ LHsType GhcPs
_ LHsType GhcPs
_)       = Entry
NoEntryVal
  getAnnotationEntry (HsFunTy XFunTy GhcPs
an HsArrow GhcPs
_ LHsType GhcPs
_ LHsType GhcPs
_)        = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XFunTy GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (HsListTy XListTy GhcPs
an LHsType GhcPs
_)           = EpAnn AnnParen -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XListTy GhcPs
EpAnn AnnParen
an
  getAnnotationEntry (HsTupleTy XTupleTy GhcPs
an HsTupleSort
_ [LHsType GhcPs]
_)        = EpAnn AnnParen -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XTupleTy GhcPs
EpAnn AnnParen
an
  getAnnotationEntry (HsSumTy XSumTy GhcPs
an [LHsType GhcPs]
_)            = EpAnn AnnParen -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XSumTy GhcPs
EpAnn AnnParen
an
  getAnnotationEntry (HsOpTy XOpTy GhcPs
an PromotionFlag
_ LHsType GhcPs
_ LIdP GhcPs
_ LHsType GhcPs
_)       = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XOpTy GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsParTy XParTy GhcPs
an LHsType GhcPs
_)            = EpAnn AnnParen -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XParTy GhcPs
EpAnn AnnParen
an
  getAnnotationEntry (HsIParamTy XIParamTy GhcPs
an XRec GhcPs HsIPName
_ LHsType GhcPs
_)       = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XIParamTy GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsStarTy XStarTy GhcPs
_ Bool
_)            = Entry
NoEntryVal
  getAnnotationEntry (HsKindSig XKindSig GhcPs
an LHsType GhcPs
_ LHsType GhcPs
_)        = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XKindSig GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsSpliceTy XSpliceTy GhcPs
_ HsUntypedSplice GhcPs
_)          = Entry
NoEntryVal
  getAnnotationEntry (HsDocTy XDocTy GhcPs
an LHsType GhcPs
_ LHsDoc GhcPs
_)          = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XDocTy GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsBangTy XBangTy GhcPs
an HsSrcBang
_ LHsType GhcPs
_)         = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XBangTy GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsRecTy XRecTy GhcPs
an [LConDeclField GhcPs]
_)            = EpAnn AnnList -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XRecTy GhcPs
EpAnn AnnList
an
  getAnnotationEntry (HsExplicitListTy XExplicitListTy GhcPs
an PromotionFlag
_ [LHsType GhcPs]
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XExplicitListTy GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsExplicitTupleTy XExplicitTupleTy GhcPs
an [LHsType GhcPs]
_)  = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XExplicitTupleTy GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (HsTyLit XTyLit GhcPs
_ HsTyLit GhcPs
_)             = Entry
NoEntryVal
  getAnnotationEntry (HsWildCardTy XWildCardTy GhcPs
_)          = Entry
NoEntryVal
  getAnnotationEntry (XHsType XXType GhcPs
_)               = Entry
NoEntryVal

  setAnnotationAnchor :: HsType GhcPs -> Anchor -> EpAnnComments -> HsType GhcPs
setAnnotationAnchor a :: HsType GhcPs
a@(HsForAllTy XForAllTy GhcPs
_ HsForAllTelescope GhcPs
_ LHsType GhcPs
_)        Anchor
_ EpAnnComments
_s = HsType GhcPs
a
  setAnnotationAnchor a :: HsType GhcPs
a@(HsQualTy XQualTy GhcPs
_ LHsContext GhcPs
_ LHsType GhcPs
_)          Anchor
_ EpAnnComments
_s = HsType GhcPs
a
  setAnnotationAnchor (HsTyVar XTyVar GhcPs
an PromotionFlag
a LIdP GhcPs
b)          Anchor
anc EpAnnComments
cs = (XTyVar GhcPs -> PromotionFlag -> LIdP GhcPs -> HsType GhcPs
forall pass.
XTyVar pass -> PromotionFlag -> LIdP pass -> HsType pass
HsTyVar (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XTyVar GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) PromotionFlag
a LIdP GhcPs
b)
  setAnnotationAnchor a :: HsType GhcPs
a@(HsAppTy XAppTy GhcPs
_ LHsType GhcPs
_ LHsType GhcPs
_)           Anchor
_ EpAnnComments
_s = HsType GhcPs
a
  setAnnotationAnchor a :: HsType GhcPs
a@(HsAppKindTy XAppKindTy GhcPs
_ LHsType GhcPs
_ LHsType GhcPs
_)       Anchor
_ EpAnnComments
_s = HsType GhcPs
a
  setAnnotationAnchor (HsFunTy XFunTy GhcPs
an HsArrow GhcPs
a LHsType GhcPs
b LHsType GhcPs
c)        Anchor
anc EpAnnComments
cs = (XFunTy GhcPs
-> HsArrow GhcPs -> LHsType GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass.
XFunTy pass
-> HsArrow pass -> LHsType pass -> LHsType pass -> HsType pass
HsFunTy (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XFunTy GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) HsArrow GhcPs
a LHsType GhcPs
b LHsType GhcPs
c)
  setAnnotationAnchor (HsListTy XListTy GhcPs
an LHsType GhcPs
a)           Anchor
anc EpAnnComments
cs = (XListTy GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass. XListTy pass -> LHsType pass -> HsType pass
HsListTy (EpAnn AnnParen -> Anchor -> EpAnnComments -> EpAnn AnnParen
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XListTy GhcPs
EpAnn AnnParen
an Anchor
anc EpAnnComments
cs) LHsType GhcPs
a)
  setAnnotationAnchor (HsTupleTy XTupleTy GhcPs
an HsTupleSort
a [LHsType GhcPs]
b)        Anchor
anc EpAnnComments
cs = (XTupleTy GhcPs -> HsTupleSort -> [LHsType GhcPs] -> HsType GhcPs
forall pass.
XTupleTy pass -> HsTupleSort -> [LHsType pass] -> HsType pass
HsTupleTy (EpAnn AnnParen -> Anchor -> EpAnnComments -> EpAnn AnnParen
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XTupleTy GhcPs
EpAnn AnnParen
an Anchor
anc EpAnnComments
cs) HsTupleSort
a [LHsType GhcPs]
b)
  setAnnotationAnchor (HsSumTy XSumTy GhcPs
an [LHsType GhcPs]
a)            Anchor
anc EpAnnComments
cs = (XSumTy GhcPs -> [LHsType GhcPs] -> HsType GhcPs
forall pass. XSumTy pass -> [LHsType pass] -> HsType pass
HsSumTy (EpAnn AnnParen -> Anchor -> EpAnnComments -> EpAnn AnnParen
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XSumTy GhcPs
EpAnn AnnParen
an Anchor
anc EpAnnComments
cs) [LHsType GhcPs]
a)
  setAnnotationAnchor a :: HsType GhcPs
a@(HsOpTy XOpTy GhcPs
_ PromotionFlag
_ LHsType GhcPs
_ LIdP GhcPs
_ LHsType GhcPs
_)        Anchor
_ EpAnnComments
_s = HsType GhcPs
a
  setAnnotationAnchor (HsParTy XParTy GhcPs
an LHsType GhcPs
a)            Anchor
anc EpAnnComments
cs = (XParTy GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass. XParTy pass -> LHsType pass -> HsType pass
HsParTy (EpAnn AnnParen -> Anchor -> EpAnnComments -> EpAnn AnnParen
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XParTy GhcPs
EpAnn AnnParen
an Anchor
anc EpAnnComments
cs) LHsType GhcPs
a)
  setAnnotationAnchor (HsIParamTy XIParamTy GhcPs
an XRec GhcPs HsIPName
a LHsType GhcPs
b)       Anchor
anc EpAnnComments
cs = (XIParamTy GhcPs
-> XRec GhcPs HsIPName -> LHsType GhcPs -> HsType GhcPs
forall pass.
XIParamTy pass -> XRec pass HsIPName -> LHsType pass -> HsType pass
HsIParamTy (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XIParamTy GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs HsIPName
a LHsType GhcPs
b)
  setAnnotationAnchor a :: HsType GhcPs
a@(HsStarTy XStarTy GhcPs
_ Bool
_)            Anchor
_ EpAnnComments
_s = HsType GhcPs
a
  setAnnotationAnchor (HsKindSig XKindSig GhcPs
an LHsType GhcPs
a LHsType GhcPs
b)        Anchor
anc EpAnnComments
cs = (XKindSig GhcPs -> LHsType GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass.
XKindSig pass -> LHsType pass -> LHsType pass -> HsType pass
HsKindSig (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XKindSig GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LHsType GhcPs
a LHsType GhcPs
b)
  setAnnotationAnchor a :: HsType GhcPs
a@(HsSpliceTy XSpliceTy GhcPs
_ HsUntypedSplice GhcPs
_)          Anchor
_ EpAnnComments
_s = HsType GhcPs
a
  setAnnotationAnchor (HsDocTy XDocTy GhcPs
an LHsType GhcPs
a LHsDoc GhcPs
b)          Anchor
anc EpAnnComments
cs = (XDocTy GhcPs -> LHsType GhcPs -> LHsDoc GhcPs -> HsType GhcPs
forall pass.
XDocTy pass -> LHsType pass -> LHsDoc pass -> HsType pass
HsDocTy (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XDocTy GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LHsType GhcPs
a LHsDoc GhcPs
b)
  setAnnotationAnchor (HsBangTy XBangTy GhcPs
an HsSrcBang
a LHsType GhcPs
b)         Anchor
anc EpAnnComments
cs = (XBangTy GhcPs -> HsSrcBang -> LHsType GhcPs -> HsType GhcPs
forall pass.
XBangTy pass -> HsSrcBang -> LHsType pass -> HsType pass
HsBangTy (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XBangTy GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) HsSrcBang
a LHsType GhcPs
b)
  setAnnotationAnchor (HsRecTy XRecTy GhcPs
an [LConDeclField GhcPs]
a)            Anchor
anc EpAnnComments
cs = (XRecTy GhcPs -> [LConDeclField GhcPs] -> HsType GhcPs
forall pass. XRecTy pass -> [LConDeclField pass] -> HsType pass
HsRecTy (EpAnn AnnList -> Anchor -> EpAnnComments -> EpAnn AnnList
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XRecTy GhcPs
EpAnn AnnList
an Anchor
anc EpAnnComments
cs) [LConDeclField GhcPs]
a)
  setAnnotationAnchor (HsExplicitListTy XExplicitListTy GhcPs
an PromotionFlag
a [LHsType GhcPs]
b) Anchor
anc EpAnnComments
cs = (XExplicitListTy GhcPs
-> PromotionFlag -> [LHsType GhcPs] -> HsType GhcPs
forall pass.
XExplicitListTy pass
-> PromotionFlag -> [LHsType pass] -> HsType pass
HsExplicitListTy (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XExplicitListTy GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) PromotionFlag
a [LHsType GhcPs]
b)
  setAnnotationAnchor (HsExplicitTupleTy XExplicitTupleTy GhcPs
an [LHsType GhcPs]
a)  Anchor
anc EpAnnComments
cs = (XExplicitTupleTy GhcPs -> [LHsType GhcPs] -> HsType GhcPs
forall pass. XExplicitTupleTy pass -> [LHsType pass] -> HsType pass
HsExplicitTupleTy (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XExplicitTupleTy GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) [LHsType GhcPs]
a)
  setAnnotationAnchor a :: HsType GhcPs
a@(HsTyLit XTyLit GhcPs
_ HsTyLit GhcPs
_)             Anchor
_ EpAnnComments
_s = HsType GhcPs
a
  setAnnotationAnchor a :: HsType GhcPs
a@(HsWildCardTy XWildCardTy GhcPs
_)          Anchor
_ EpAnnComments
_s = HsType GhcPs
a
  setAnnotationAnchor a :: HsType GhcPs
a@(XHsType XXType GhcPs
_)               Anchor
_ EpAnnComments
_s = HsType GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsType GhcPs -> EP w m (HsType GhcPs)
exact (HsForAllTy { hst_xforall :: forall pass. HsType pass -> XForAllTy pass
hst_xforall = XForAllTy GhcPs
an
                    , hst_tele :: forall pass. HsType pass -> HsForAllTelescope pass
hst_tele = HsForAllTelescope GhcPs
tele, hst_body :: forall pass. HsType pass -> LHsType pass
hst_body = LHsType GhcPs
ty }) = do
    HsForAllTelescope GhcPs
tele' <- HsForAllTelescope GhcPs -> EP w m (HsForAllTelescope GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsForAllTelescope GhcPs
tele
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsForAllTy { hst_xforall :: XForAllTy GhcPs
hst_xforall = XForAllTy GhcPs
an
                       , hst_tele :: HsForAllTelescope GhcPs
hst_tele = HsForAllTelescope GhcPs
tele', hst_body :: LHsType GhcPs
hst_body = LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty' })

  exact (HsQualTy XQualTy GhcPs
an LHsContext GhcPs
ctxt LHsType GhcPs
ty) = do
    GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
ctxt' <- GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> EP
     w
     m
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsContext GhcPs
GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
ctxt
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XQualTy GhcPs -> LHsContext GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass.
XQualTy pass -> LHsContext pass -> LHsType pass -> HsType pass
HsQualTy XQualTy GhcPs
an LHsContext GhcPs
GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
ctxt' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty')
  exact (HsTyVar XTyVar GhcPs
an PromotionFlag
promoted LIdP GhcPs
name) = do
    EpAnn [AddEpAnn]
an0 <- if (PromotionFlag
promoted PromotionFlag -> PromotionFlag -> Bool
forall a. Eq a => a -> a -> Bool
== PromotionFlag
IsPromoted)
             then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XTyVar GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnSimpleQuote
             else EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XTyVar GhcPs
EpAnn [AddEpAnn]
an
    GenLocated SrcSpanAnnN RdrName
name' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
name
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XTyVar GhcPs -> PromotionFlag -> LIdP GhcPs -> HsType GhcPs
forall pass.
XTyVar pass -> PromotionFlag -> LIdP pass -> HsType pass
HsTyVar XTyVar GhcPs
EpAnn [AddEpAnn]
an0 PromotionFlag
promoted LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
name')
  exact (HsAppTy XAppTy GhcPs
an LHsType GhcPs
t1 LHsType GhcPs
t2) = do
    GenLocated SrcSpanAnnA (HsType GhcPs)
t1' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t1
    GenLocated SrcSpanAnnA (HsType GhcPs)
t2' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t2
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XAppTy GhcPs -> LHsType GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass.
XAppTy pass -> LHsType pass -> LHsType pass -> HsType pass
HsAppTy XAppTy GhcPs
an LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t1' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t2')
  exact (HsAppKindTy XAppKindTy GhcPs
ss LHsType GhcPs
ty LHsType GhcPs
ki) = do
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty
    SrcSpan -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SrcSpan -> String -> EP w m ()
printStringAtSs XAppKindTy GhcPs
SrcSpan
ss String
"@"
    GenLocated SrcSpanAnnA (HsType GhcPs)
ki' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ki
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XAppKindTy GhcPs -> LHsType GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass.
XAppKindTy pass -> LHsType pass -> LHsType pass -> HsType pass
HsAppKindTy XAppKindTy GhcPs
ss LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ki')
  exact (HsFunTy XFunTy GhcPs
an HsArrow GhcPs
mult LHsType GhcPs
ty1 LHsType GhcPs
ty2) = do
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty1' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty1
    HsArrow GhcPs
mult' <- HsArrow GhcPs -> EP w m (HsArrow GhcPs)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsArrow GhcPs -> EP w m (HsArrow GhcPs)
markArrow HsArrow GhcPs
mult
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty2' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty2
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XFunTy GhcPs
-> HsArrow GhcPs -> LHsType GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass.
XFunTy pass
-> HsArrow pass -> LHsType pass -> LHsType pass -> HsType pass
HsFunTy XFunTy GhcPs
an HsArrow GhcPs
mult' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty1' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty2')
  exact (HsListTy XListTy GhcPs
an LHsType GhcPs
tys) = do
    EpAnn AnnParen
an0 <- EpAnn AnnParen -> EP w m (EpAnn AnnParen)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markOpeningParen XListTy GhcPs
EpAnn AnnParen
an
    GenLocated SrcSpanAnnA (HsType GhcPs)
tys' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
tys
    EpAnn AnnParen
an1 <- EpAnn AnnParen -> EP w m (EpAnn AnnParen)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markClosingParen EpAnn AnnParen
an0
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XListTy GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass. XListTy pass -> LHsType pass -> HsType pass
HsListTy XListTy GhcPs
EpAnn AnnParen
an1 LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
tys')
  exact (HsTupleTy XTupleTy GhcPs
an HsTupleSort
con [LHsType GhcPs]
tys) = do
    EpAnn AnnParen
an0 <- EpAnn AnnParen -> EP w m (EpAnn AnnParen)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markOpeningParen XTupleTy GhcPs
EpAnn AnnParen
an
    [GenLocated SrcSpanAnnA (HsType GhcPs)]
tys' <- [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsType GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsType GhcPs]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
tys
    EpAnn AnnParen
an1 <- EpAnn AnnParen -> EP w m (EpAnn AnnParen)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markClosingParen EpAnn AnnParen
an0
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XTupleTy GhcPs -> HsTupleSort -> [LHsType GhcPs] -> HsType GhcPs
forall pass.
XTupleTy pass -> HsTupleSort -> [LHsType pass] -> HsType pass
HsTupleTy XTupleTy GhcPs
EpAnn AnnParen
an1 HsTupleSort
con [LHsType GhcPs]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
tys')
  exact (HsSumTy XSumTy GhcPs
an [LHsType GhcPs]
tys) = do
    EpAnn AnnParen
an0 <- EpAnn AnnParen -> EP w m (EpAnn AnnParen)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markOpeningParen XSumTy GhcPs
EpAnn AnnParen
an
    [GenLocated SrcSpanAnnA (HsType GhcPs)]
tys' <- [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsType GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsType GhcPs]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
tys
    EpAnn AnnParen
an1 <- EpAnn AnnParen -> EP w m (EpAnn AnnParen)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markClosingParen EpAnn AnnParen
an0
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSumTy GhcPs -> [LHsType GhcPs] -> HsType GhcPs
forall pass. XSumTy pass -> [LHsType pass] -> HsType pass
HsSumTy XSumTy GhcPs
EpAnn AnnParen
an1 [LHsType GhcPs]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
tys')
  exact (HsOpTy XOpTy GhcPs
an PromotionFlag
promoted LHsType GhcPs
t1 LIdP GhcPs
lo LHsType GhcPs
t2) = do
    EpAnn [AddEpAnn]
an0 <- if (PromotionFlag -> Bool
isPromoted PromotionFlag
promoted)
        then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XOpTy GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnSimpleQuote
        else EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XOpTy GhcPs
EpAnn [AddEpAnn]
an
    GenLocated SrcSpanAnnA (HsType GhcPs)
t1' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t1
    GenLocated SrcSpanAnnN RdrName
lo' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
lo
    GenLocated SrcSpanAnnA (HsType GhcPs)
t2' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t2
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XOpTy GhcPs
-> PromotionFlag
-> LHsType GhcPs
-> LIdP GhcPs
-> LHsType GhcPs
-> HsType GhcPs
forall pass.
XOpTy pass
-> PromotionFlag
-> LHsType pass
-> LIdP pass
-> LHsType pass
-> HsType pass
HsOpTy XOpTy GhcPs
EpAnn [AddEpAnn]
an0 PromotionFlag
promoted LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t1' LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
lo' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t2')
  exact (HsParTy XParTy GhcPs
an LHsType GhcPs
ty) = do
    EpAnn AnnParen
an0 <- EpAnn AnnParen -> EP w m (EpAnn AnnParen)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markOpeningParen XParTy GhcPs
EpAnn AnnParen
an
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty
    EpAnn AnnParen
an1 <- EpAnn AnnParen -> EP w m (EpAnn AnnParen)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnParen -> EP w m (EpAnn AnnParen)
markClosingParen EpAnn AnnParen
an0
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XParTy GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass. XParTy pass -> LHsType pass -> HsType pass
HsParTy XParTy GhcPs
EpAnn AnnParen
an1 LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty')
  exact (HsIParamTy XIParamTy GhcPs
an XRec GhcPs HsIPName
n LHsType GhcPs
t) = do
    GenLocated (SrcAnn NoEpAnns) HsIPName
n' <- GenLocated (SrcAnn NoEpAnns) HsIPName
-> EP w m (GenLocated (SrcAnn NoEpAnns) HsIPName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs HsIPName
GenLocated (SrcAnn NoEpAnns) HsIPName
n
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XIParamTy GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
    GenLocated SrcSpanAnnA (HsType GhcPs)
t' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIParamTy GhcPs
-> XRec GhcPs HsIPName -> LHsType GhcPs -> HsType GhcPs
forall pass.
XIParamTy pass -> XRec pass HsIPName -> LHsType pass -> HsType pass
HsIParamTy XIParamTy GhcPs
EpAnn [AddEpAnn]
an0 XRec GhcPs HsIPName
GenLocated (SrcAnn NoEpAnns) HsIPName
n' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
t')
  exact (HsStarTy XStarTy GhcPs
an Bool
isUnicode) = do
    if Bool
isUnicode
        then String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance String
"\x2605" -- Unicode star
        else String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance String
"*"
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XStarTy GhcPs -> Bool -> HsType GhcPs
forall pass. XStarTy pass -> Bool -> HsType pass
HsStarTy XStarTy GhcPs
an Bool
isUnicode)
  exact (HsKindSig XKindSig GhcPs
an LHsType GhcPs
ty LHsType GhcPs
k) = do
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XKindSig GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
    GenLocated SrcSpanAnnA (HsType GhcPs)
k' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
k
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XKindSig GhcPs -> LHsType GhcPs -> LHsType GhcPs -> HsType GhcPs
forall pass.
XKindSig pass -> LHsType pass -> LHsType pass -> HsType pass
HsKindSig XKindSig GhcPs
EpAnn [AddEpAnn]
an0 LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
k')
  exact (HsSpliceTy XSpliceTy GhcPs
a HsUntypedSplice GhcPs
splice) = do
    HsUntypedSplice GhcPs
splice' <- HsUntypedSplice GhcPs -> EP w m (HsUntypedSplice GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsUntypedSplice GhcPs
splice
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSpliceTy GhcPs -> HsUntypedSplice GhcPs -> HsType GhcPs
forall pass. XSpliceTy pass -> HsUntypedSplice pass -> HsType pass
HsSpliceTy XSpliceTy GhcPs
a HsUntypedSplice GhcPs
splice')
  exact (HsDocTy XDocTy GhcPs
an LHsType GhcPs
ty LHsDoc GhcPs
doc) = do
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty
    -- doc' <- markAnnotated doc
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XDocTy GhcPs -> LHsType GhcPs -> LHsDoc GhcPs -> HsType GhcPs
forall pass.
XDocTy pass -> LHsType pass -> LHsDoc pass -> HsType pass
HsDocTy XDocTy GhcPs
an LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty' LHsDoc GhcPs
doc)
  exact (HsBangTy XBangTy GhcPs
an (HsSrcBang SourceText
mt SrcUnpackedness
up SrcStrictness
str) LHsType GhcPs
ty) = do
    EpAnn [AddEpAnn]
an0 <-
      case SourceText
mt of
        SourceText
NoSourceText -> EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XBangTy GhcPs
EpAnn [AddEpAnn]
an
        SourceText String
src -> do
          String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"HsBangTy: src=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Data a => a -> String
showAst String
src
          EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS XBangTy GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
AnnOpen  (String -> Maybe String
forall a. a -> Maybe a
Just String
src)
          EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
AnnClose (String -> Maybe String
forall a. a -> Maybe a
Just String
"#-}")
          String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"HsBangTy: done unpackedness"
          EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn [AddEpAnn]
an1
    EpAnn [AddEpAnn]
an1 <-
      case SrcStrictness
str of
        SrcStrictness
SrcLazy     -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnTilde
        SrcStrictness
SrcStrict   -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnBang
        SrcStrictness
NoSrcStrict -> EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn [AddEpAnn]
an0
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XBangTy GhcPs -> HsSrcBang -> LHsType GhcPs -> HsType GhcPs
forall pass.
XBangTy pass -> HsSrcBang -> LHsType pass -> HsType pass
HsBangTy XBangTy GhcPs
EpAnn [AddEpAnn]
an1 (SourceText -> SrcUnpackedness -> SrcStrictness -> HsSrcBang
HsSrcBang SourceText
mt SrcUnpackedness
up SrcStrictness
str) LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty')
  exact (HsExplicitListTy XExplicitListTy GhcPs
an PromotionFlag
prom [LHsType GhcPs]
tys) = do
    EpAnn [AddEpAnn]
an0 <- if (PromotionFlag -> Bool
isPromoted PromotionFlag
prom)
             then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XExplicitListTy GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnSimpleQuote
             else EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XExplicitListTy GhcPs
EpAnn [AddEpAnn]
an
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenS
    [GenLocated SrcSpanAnnA (HsType GhcPs)]
tys' <- [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsType GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsType GhcPs]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
tys
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseS
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XExplicitListTy GhcPs
-> PromotionFlag -> [LHsType GhcPs] -> HsType GhcPs
forall pass.
XExplicitListTy pass
-> PromotionFlag -> [LHsType pass] -> HsType pass
HsExplicitListTy XExplicitListTy GhcPs
EpAnn [AddEpAnn]
an2 PromotionFlag
prom [LHsType GhcPs]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
tys')
  exact (HsExplicitTupleTy XExplicitTupleTy GhcPs
an [LHsType GhcPs]
tys) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XExplicitTupleTy GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnSimpleQuote
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenP
    [GenLocated SrcSpanAnnA (HsType GhcPs)]
tys' <- [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsType GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsType GhcPs]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
tys
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseP
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XExplicitTupleTy GhcPs -> [LHsType GhcPs] -> HsType GhcPs
forall pass. XExplicitTupleTy pass -> [LHsType pass] -> HsType pass
HsExplicitTupleTy XExplicitTupleTy GhcPs
EpAnn [AddEpAnn]
an2 [LHsType GhcPs]
[GenLocated SrcSpanAnnA (HsType GhcPs)]
tys')
  exact (HsTyLit XTyLit GhcPs
a HsTyLit GhcPs
lit) = do
    case HsTyLit GhcPs
lit of
      (HsNumTy XNumTy GhcPs
src Integer
v) -> SourceText -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SourceText -> String -> EP w m ()
printSourceText XNumTy GhcPs
SourceText
src (Integer -> String
forall a. Show a => a -> String
show Integer
v)
      (HsStrTy XStrTy GhcPs
src FastString
v) -> SourceText -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SourceText -> String -> EP w m ()
printSourceText XStrTy GhcPs
SourceText
src (FastString -> String
forall a. Show a => a -> String
show FastString
v)
      (HsCharTy XCharTy GhcPs
src Char
v) -> SourceText -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
SourceText -> String -> EP w m ()
printSourceText XCharTy GhcPs
SourceText
src (Char -> String
forall a. Show a => a -> String
show Char
v)
    HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XTyLit GhcPs -> HsTyLit GhcPs -> HsType GhcPs
forall pass. XTyLit pass -> HsTyLit pass -> HsType pass
HsTyLit XTyLit GhcPs
a HsTyLit GhcPs
lit)
  exact t :: HsType GhcPs
t@(HsWildCardTy XWildCardTy GhcPs
_) = String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance String
"_" EP w m () -> EP w m (HsType GhcPs) -> EP w m (HsType GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HsType GhcPs -> EP w m (HsType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsType GhcPs
t
  exact x :: HsType GhcPs
x@(HsRecTy XRecTy GhcPs
_ [LConDeclField GhcPs]
_)    = String -> EP w m (HsType GhcPs)
forall a. HasCallStack => String -> a
error (String -> EP w m (HsType GhcPs))
-> String -> EP w m (HsType GhcPs)
forall a b. (a -> b) -> a -> b
$ String
"missing match for HsType:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ HsType GhcPs -> String
forall a. Data a => a -> String
showAst HsType GhcPs
x
  exact x :: HsType GhcPs
x@(XHsType XXType GhcPs
_)      = String -> EP w m (HsType GhcPs)
forall a. HasCallStack => String -> a
error (String -> EP w m (HsType GhcPs))
-> String -> EP w m (HsType GhcPs)
forall a b. (a -> b) -> a -> b
$ String
"missing match for HsType:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ HsType GhcPs -> String
forall a. Data a => a -> String
showAst HsType GhcPs
x


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

instance ExactPrint (HsForAllTelescope GhcPs) where
  getAnnotationEntry :: HsForAllTelescope GhcPs -> Entry
getAnnotationEntry (HsForAllVis XHsForAllVis GhcPs
an [LHsTyVarBndr () GhcPs]
_)   = EpAnnForallTy -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XHsForAllVis GhcPs
EpAnnForallTy
an
  getAnnotationEntry (HsForAllInvis XHsForAllInvis GhcPs
an [LHsTyVarBndr Specificity GhcPs]
_) = EpAnnForallTy -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XHsForAllInvis GhcPs
EpAnnForallTy
an

  setAnnotationAnchor :: HsForAllTelescope GhcPs
-> Anchor -> EpAnnComments -> HsForAllTelescope GhcPs
setAnnotationAnchor (HsForAllVis XHsForAllVis GhcPs
an [LHsTyVarBndr () GhcPs]
a) Anchor
anc EpAnnComments
cs = XHsForAllVis GhcPs
-> [LHsTyVarBndr () GhcPs] -> HsForAllTelescope GhcPs
forall pass.
XHsForAllVis pass
-> [LHsTyVarBndr () pass] -> HsForAllTelescope pass
HsForAllVis (EpAnnForallTy -> Anchor -> EpAnnComments -> EpAnnForallTy
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XHsForAllVis GhcPs
EpAnnForallTy
an Anchor
anc EpAnnComments
cs) [LHsTyVarBndr () GhcPs]
a
  setAnnotationAnchor (HsForAllInvis XHsForAllInvis GhcPs
an [LHsTyVarBndr Specificity GhcPs]
a) Anchor
anc EpAnnComments
cs = XHsForAllInvis GhcPs
-> [LHsTyVarBndr Specificity GhcPs] -> HsForAllTelescope GhcPs
forall pass.
XHsForAllInvis pass
-> [LHsTyVarBndr Specificity pass] -> HsForAllTelescope pass
HsForAllInvis (EpAnnForallTy -> Anchor -> EpAnnComments -> EpAnnForallTy
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XHsForAllInvis GhcPs
EpAnnForallTy
an Anchor
anc EpAnnComments
cs) [LHsTyVarBndr Specificity GhcPs]
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsForAllTelescope GhcPs -> EP w m (HsForAllTelescope GhcPs)
exact (HsForAllVis XHsForAllVis GhcPs
an [LHsTyVarBndr () GhcPs]
bndrs)   = do
    EpAnnForallTy
an0 <- EpAnnForallTy
-> Lens (AddEpAnn, AddEpAnn) AddEpAnn -> EP w m EpAnnForallTy
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA XHsForAllVis GhcPs
EpAnnForallTy
an (AddEpAnn -> f AddEpAnn)
-> (AddEpAnn, AddEpAnn) -> f (AddEpAnn, AddEpAnn)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
Lens (AddEpAnn, AddEpAnn) AddEpAnn
lfst -- AnnForall
    [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
bndrs' <- [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsTyVarBndr () GhcPs]
[GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
bndrs
    EpAnnForallTy
an1 <- EpAnnForallTy
-> Lens (AddEpAnn, AddEpAnn) AddEpAnn -> EP w m EpAnnForallTy
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA EpAnnForallTy
an0 (AddEpAnn -> f AddEpAnn)
-> (AddEpAnn, AddEpAnn) -> f (AddEpAnn, AddEpAnn)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
Lens (AddEpAnn, AddEpAnn) AddEpAnn
lsnd -- AnnRarrow
    HsForAllTelescope GhcPs -> EP w m (HsForAllTelescope GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsForAllVis GhcPs
-> [LHsTyVarBndr () GhcPs] -> HsForAllTelescope GhcPs
forall pass.
XHsForAllVis pass
-> [LHsTyVarBndr () pass] -> HsForAllTelescope pass
HsForAllVis XHsForAllVis GhcPs
EpAnnForallTy
an1 [LHsTyVarBndr () GhcPs]
[GenLocated SrcSpanAnnA (HsTyVarBndr () GhcPs)]
bndrs')

  exact (HsForAllInvis XHsForAllInvis GhcPs
an [LHsTyVarBndr Specificity GhcPs]
bndrs) = do
    EpAnnForallTy
an0 <- EpAnnForallTy
-> Lens (AddEpAnn, AddEpAnn) AddEpAnn -> EP w m EpAnnForallTy
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA XHsForAllInvis GhcPs
EpAnnForallTy
an (AddEpAnn -> f AddEpAnn)
-> (AddEpAnn, AddEpAnn) -> f (AddEpAnn, AddEpAnn)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
Lens (AddEpAnn, AddEpAnn) AddEpAnn
lfst -- AnnForall
    [GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)]
bndrs' <- [GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsTyVarBndr Specificity GhcPs]
[GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)]
bndrs
    EpAnnForallTy
an1 <- EpAnnForallTy
-> Lens (AddEpAnn, AddEpAnn) AddEpAnn -> EP w m EpAnnForallTy
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA EpAnnForallTy
an0 (AddEpAnn -> f AddEpAnn)
-> (AddEpAnn, AddEpAnn) -> f (AddEpAnn, AddEpAnn)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
Lens (AddEpAnn, AddEpAnn) AddEpAnn
lsnd -- AnnDot
    HsForAllTelescope GhcPs -> EP w m (HsForAllTelescope GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsForAllInvis GhcPs
-> [LHsTyVarBndr Specificity GhcPs] -> HsForAllTelescope GhcPs
forall pass.
XHsForAllInvis pass
-> [LHsTyVarBndr Specificity pass] -> HsForAllTelescope pass
HsForAllInvis XHsForAllInvis GhcPs
EpAnnForallTy
an1 [LHsTyVarBndr Specificity GhcPs]
[GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)]
bndrs')

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

instance ExactPrint (HsDerivingClause GhcPs) where
  getAnnotationEntry :: HsDerivingClause GhcPs -> Entry
getAnnotationEntry d :: HsDerivingClause GhcPs
d@(HsDerivingClause{}) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn (HsDerivingClause GhcPs -> XCHsDerivingClause GhcPs
forall pass. HsDerivingClause pass -> XCHsDerivingClause pass
deriv_clause_ext HsDerivingClause GhcPs
d)
  setAnnotationAnchor :: HsDerivingClause GhcPs
-> Anchor -> EpAnnComments -> HsDerivingClause GhcPs
setAnnotationAnchor HsDerivingClause GhcPs
x Anchor
anc EpAnnComments
cs = (HsDerivingClause GhcPs
x { deriv_clause_ext = setAnchorEpa (deriv_clause_ext x) anc cs})
                                   HsDerivingClause GhcPs -> String -> HsDerivingClause GhcPs
forall c. c -> String -> c
`debug` (String
"setAnnotationAnchor HsDerivingClause: (anc,cs):" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Anchor, EpAnnComments) -> String
forall a. Data a => a -> String
showAst (Anchor
anc,EpAnnComments
cs))

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsDerivingClause GhcPs -> EP w m (HsDerivingClause GhcPs)
exact (HsDerivingClause { deriv_clause_ext :: forall pass. HsDerivingClause pass -> XCHsDerivingClause pass
deriv_clause_ext      = XCHsDerivingClause GhcPs
an
                          , deriv_clause_strategy :: forall pass. HsDerivingClause pass -> Maybe (LDerivStrategy pass)
deriv_clause_strategy = Maybe (LDerivStrategy GhcPs)
dcs
                          , deriv_clause_tys :: forall pass. HsDerivingClause pass -> LDerivClauseTys pass
deriv_clause_tys      = LDerivClauseTys GhcPs
dct }) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XCHsDerivingClause GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDeriving
    RWST (EPOptions m w) (EPWriter w) EPState m ()
exact_strat_before
    GenLocated SrcSpanAnnC (DerivClauseTys GhcPs)
dct' <- GenLocated SrcSpanAnnC (DerivClauseTys GhcPs)
-> EP w m (GenLocated SrcSpanAnnC (DerivClauseTys GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LDerivClauseTys GhcPs
GenLocated SrcSpanAnnC (DerivClauseTys GhcPs)
dct
    RWST (EPOptions m w) (EPWriter w) EPState m ()
exact_strat_after
    HsDerivingClause GhcPs -> EP w m (HsDerivingClause GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsDerivingClause { deriv_clause_ext :: XCHsDerivingClause GhcPs
deriv_clause_ext      = XCHsDerivingClause GhcPs
EpAnn [AddEpAnn]
an0
                             , deriv_clause_strategy :: Maybe (LDerivStrategy GhcPs)
deriv_clause_strategy = Maybe (LDerivStrategy GhcPs)
dcs
                             , deriv_clause_tys :: LDerivClauseTys GhcPs
deriv_clause_tys      = LDerivClauseTys GhcPs
GenLocated SrcSpanAnnC (DerivClauseTys GhcPs)
dct' })
      where
        (RWST (EPOptions m w) (EPWriter w) EPState m ()
exact_strat_before, RWST (EPOptions m w) (EPWriter w) EPState m ()
exact_strat_after) =
          case Maybe (LDerivStrategy GhcPs)
dcs of
            Just v :: LDerivStrategy GhcPs
v@(L SrcAnn NoEpAnns
_ ViaStrategy{}) -> (() -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (), GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LDerivStrategy GhcPs
GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs)
v EP w m (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs))
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
            Maybe (LDerivStrategy GhcPs)
_                          -> ((GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs)
 -> EP w m (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs)))
-> Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs))
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (LDerivStrategy GhcPs)
Maybe (GenLocated (SrcAnn NoEpAnns) (DerivStrategy GhcPs))
dcs, () -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

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

instance ExactPrint (DerivStrategy GhcPs) where
  getAnnotationEntry :: DerivStrategy GhcPs -> Entry
getAnnotationEntry (StockStrategy XStockStrategy GhcPs
an)    = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XStockStrategy GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (AnyclassStrategy XAnyClassStrategy GhcPs
an) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XAnyClassStrategy GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (NewtypeStrategy XNewtypeStrategy GhcPs
an)  = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XNewtypeStrategy GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (ViaStrategy (XViaStrategyPs EpAnn [AddEpAnn]
an  LHsSigType GhcPs
_)) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn EpAnn [AddEpAnn]
an

  setAnnotationAnchor :: DerivStrategy GhcPs
-> Anchor -> EpAnnComments -> DerivStrategy GhcPs
setAnnotationAnchor (StockStrategy XStockStrategy GhcPs
an)    Anchor
anc EpAnnComments
cs = (XStockStrategy GhcPs -> DerivStrategy GhcPs
forall pass. XStockStrategy pass -> DerivStrategy pass
StockStrategy (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XStockStrategy GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs))
  setAnnotationAnchor (AnyclassStrategy XAnyClassStrategy GhcPs
an) Anchor
anc EpAnnComments
cs = (XAnyClassStrategy GhcPs -> DerivStrategy GhcPs
forall pass. XAnyClassStrategy pass -> DerivStrategy pass
AnyclassStrategy (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XAnyClassStrategy GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs))
  setAnnotationAnchor (NewtypeStrategy XNewtypeStrategy GhcPs
an)  Anchor
anc EpAnnComments
cs = (XNewtypeStrategy GhcPs -> DerivStrategy GhcPs
forall pass. XNewtypeStrategy pass -> DerivStrategy pass
NewtypeStrategy (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XNewtypeStrategy GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs))
  setAnnotationAnchor (ViaStrategy (XViaStrategyPs EpAnn [AddEpAnn]
an  LHsSigType GhcPs
a)) Anchor
anc EpAnnComments
cs = (XViaStrategy GhcPs -> DerivStrategy GhcPs
forall pass. XViaStrategy pass -> DerivStrategy pass
ViaStrategy (EpAnn [AddEpAnn] -> LHsSigType GhcPs -> XViaStrategyPs
XViaStrategyPs (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs)  LHsSigType GhcPs
a))

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DerivStrategy GhcPs -> EP w m (DerivStrategy GhcPs)
exact (StockStrategy XStockStrategy GhcPs
an)    = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XStockStrategy GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
AnnStock
    DerivStrategy GhcPs -> EP w m (DerivStrategy GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XStockStrategy GhcPs -> DerivStrategy GhcPs
forall pass. XStockStrategy pass -> DerivStrategy pass
StockStrategy XStockStrategy GhcPs
EpAnn [AddEpAnn]
an0)
  exact (AnyclassStrategy XAnyClassStrategy GhcPs
an) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XAnyClassStrategy GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
AnnAnyclass
    DerivStrategy GhcPs -> EP w m (DerivStrategy GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XAnyClassStrategy GhcPs -> DerivStrategy GhcPs
forall pass. XAnyClassStrategy pass -> DerivStrategy pass
AnyclassStrategy XAnyClassStrategy GhcPs
EpAnn [AddEpAnn]
an0)
  exact (NewtypeStrategy XNewtypeStrategy GhcPs
an)  = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XNewtypeStrategy GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
AnnNewtype
    DerivStrategy GhcPs -> EP w m (DerivStrategy GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XNewtypeStrategy GhcPs -> DerivStrategy GhcPs
forall pass. XNewtypeStrategy pass -> DerivStrategy pass
NewtypeStrategy XNewtypeStrategy GhcPs
EpAnn [AddEpAnn]
an0)
  exact (ViaStrategy (XViaStrategyPs EpAnn [AddEpAnn]
an LHsSigType GhcPs
ty)) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens [AddEpAnn] [AddEpAnn]
lid AnnKeywordId
AnnVia
    GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty
    DerivStrategy GhcPs -> EP w m (DerivStrategy GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XViaStrategy GhcPs -> DerivStrategy GhcPs
forall pass. XViaStrategy pass -> DerivStrategy pass
ViaStrategy (EpAnn [AddEpAnn] -> LHsSigType GhcPs -> XViaStrategyPs
XViaStrategyPs EpAnn [AddEpAnn]
an0 LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty'))

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

instance (ExactPrint a) => ExactPrint (LocatedC a) where
  getAnnotationEntry :: LocatedC a -> Entry
getAnnotationEntry (L SrcSpanAnnC
sann a
_) = SrcSpanAnnC -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn SrcSpanAnnC
sann
  setAnnotationAnchor :: LocatedC a -> Anchor -> EpAnnComments -> LocatedC a
setAnnotationAnchor = LocatedC a -> Anchor -> EpAnnComments -> LocatedC a
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LocatedC a -> EP w m (LocatedC a)
exact (L (SrcSpanAnn EpAnn AnnContext
EpAnnNotUsed SrcSpan
l) a
a) = do
    a
a' <- a -> EP w m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated a
a
    LocatedC a -> EP w m (LocatedC a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnC -> a -> LocatedC a
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnContext -> SrcSpan -> SrcSpanAnnC
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnContext
forall ann. EpAnn ann
EpAnnNotUsed SrcSpan
l) a
a')
  exact (L (SrcSpanAnn (EpAnn Anchor
anc (AnnContext Maybe (IsUnicodeSyntax, EpaLocation)
ma [EpaLocation]
opens [EpaLocation]
closes) EpAnnComments
cs) SrcSpan
l) a
a) = do
    [EpaLocation]
opens' <- (EpaLocation
 -> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation)
-> [EpaLocation]
-> RWST (EPOptions m w) (EPWriter w) EPState m [EpaLocation]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (AnnKeywordId
-> EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
AnnOpenP) [EpaLocation]
opens
    a
a' <- a -> EP w m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated a
a
    [EpaLocation]
closes' <- (EpaLocation
 -> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation)
-> [EpaLocation]
-> RWST (EPOptions m w) (EPWriter w) EPState m [EpaLocation]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (AnnKeywordId
-> EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
AnnCloseP) [EpaLocation]
closes
    Maybe (IsUnicodeSyntax, EpaLocation)
ma' <- case Maybe (IsUnicodeSyntax, EpaLocation)
ma of
      Just (IsUnicodeSyntax
UnicodeSyntax, EpaLocation
r) -> (IsUnicodeSyntax, EpaLocation)
-> Maybe (IsUnicodeSyntax, EpaLocation)
forall a. a -> Maybe a
Just ((IsUnicodeSyntax, EpaLocation)
 -> Maybe (IsUnicodeSyntax, EpaLocation))
-> (EpaLocation -> (IsUnicodeSyntax, EpaLocation))
-> EpaLocation
-> Maybe (IsUnicodeSyntax, EpaLocation)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IsUnicodeSyntax
UnicodeSyntax,) (EpaLocation -> Maybe (IsUnicodeSyntax, EpaLocation))
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (IsUnicodeSyntax, EpaLocation))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnnKeywordId
-> EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
AnnDarrowU EpaLocation
r
      Just (IsUnicodeSyntax
NormalSyntax,  EpaLocation
r) -> (IsUnicodeSyntax, EpaLocation)
-> Maybe (IsUnicodeSyntax, EpaLocation)
forall a. a -> Maybe a
Just ((IsUnicodeSyntax, EpaLocation)
 -> Maybe (IsUnicodeSyntax, EpaLocation))
-> (EpaLocation -> (IsUnicodeSyntax, EpaLocation))
-> EpaLocation
-> Maybe (IsUnicodeSyntax, EpaLocation)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IsUnicodeSyntax
NormalSyntax,) (EpaLocation -> Maybe (IsUnicodeSyntax, EpaLocation))
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (IsUnicodeSyntax, EpaLocation))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnnKeywordId
-> EpaLocation
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AnnKeywordId -> EpaLocation -> EP w m EpaLocation
markKwA AnnKeywordId
AnnDarrow  EpaLocation
r
      Maybe (IsUnicodeSyntax, EpaLocation)
Nothing -> Maybe (IsUnicodeSyntax, EpaLocation)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (IsUnicodeSyntax, EpaLocation))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (IsUnicodeSyntax, EpaLocation)
forall a. Maybe a
Nothing
    LocatedC a -> EP w m (LocatedC a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnC -> a -> LocatedC a
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnContext -> SrcSpan -> SrcSpanAnnC
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> AnnContext -> EpAnnComments -> EpAnn AnnContext
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Maybe (IsUnicodeSyntax, EpaLocation)
-> [EpaLocation] -> [EpaLocation] -> AnnContext
AnnContext Maybe (IsUnicodeSyntax, EpaLocation)
ma' [EpaLocation]
opens' [EpaLocation]
closes') EpAnnComments
cs) SrcSpan
l) a
a')

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

instance ExactPrint (DerivClauseTys GhcPs) where
  getAnnotationEntry :: DerivClauseTys GhcPs -> Entry
getAnnotationEntry = Entry -> DerivClauseTys GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: DerivClauseTys GhcPs
-> Anchor -> EpAnnComments -> DerivClauseTys GhcPs
setAnnotationAnchor DerivClauseTys GhcPs
a Anchor
_ EpAnnComments
_ = DerivClauseTys GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DerivClauseTys GhcPs -> EP w m (DerivClauseTys GhcPs)
exact (DctSingle XDctSingle GhcPs
x LHsSigType GhcPs
ty) = do
    GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsSigType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsSigType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty
    DerivClauseTys GhcPs -> EP w m (DerivClauseTys GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XDctSingle GhcPs -> LHsSigType GhcPs -> DerivClauseTys GhcPs
forall pass.
XDctSingle pass -> LHsSigType pass -> DerivClauseTys pass
DctSingle XDctSingle GhcPs
x LHsSigType GhcPs
GenLocated SrcSpanAnnA (HsSigType GhcPs)
ty')
  exact (DctMulti XDctMulti GhcPs
x [LHsSigType GhcPs]
tys) = do
    [GenLocated SrcSpanAnnA (HsSigType GhcPs)]
tys' <- [GenLocated SrcSpanAnnA (HsSigType GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsSigType GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsSigType GhcPs]
[GenLocated SrcSpanAnnA (HsSigType GhcPs)]
tys
    DerivClauseTys GhcPs -> EP w m (DerivClauseTys GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XDctMulti GhcPs -> [LHsSigType GhcPs] -> DerivClauseTys GhcPs
forall pass.
XDctMulti pass -> [LHsSigType pass] -> DerivClauseTys pass
DctMulti XDctMulti GhcPs
x [LHsSigType GhcPs]
[GenLocated SrcSpanAnnA (HsSigType GhcPs)]
tys')

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

instance ExactPrint (HsSigType GhcPs) where
  getAnnotationEntry :: HsSigType GhcPs -> Entry
getAnnotationEntry = Entry -> HsSigType GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: HsSigType GhcPs -> Anchor -> EpAnnComments -> HsSigType GhcPs
setAnnotationAnchor HsSigType GhcPs
a Anchor
_ EpAnnComments
_ = HsSigType GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsSigType GhcPs -> EP w m (HsSigType GhcPs)
exact (HsSig XHsSig GhcPs
a HsOuterSigTyVarBndrs GhcPs
bndrs LHsType GhcPs
ty) = do
    HsOuterSigTyVarBndrs GhcPs
bndrs' <- HsOuterSigTyVarBndrs GhcPs -> EP w m (HsOuterSigTyVarBndrs GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsOuterSigTyVarBndrs GhcPs
bndrs
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty
    HsSigType GhcPs -> EP w m (HsSigType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsSig GhcPs
-> HsOuterSigTyVarBndrs GhcPs -> LHsType GhcPs -> HsSigType GhcPs
forall pass.
XHsSig pass
-> HsOuterSigTyVarBndrs pass -> LHsType pass -> HsSigType pass
HsSig XHsSig GhcPs
a HsOuterSigTyVarBndrs GhcPs
bndrs' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty')

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

instance ExactPrint (LocatedN RdrName) where
  getAnnotationEntry :: GenLocated SrcSpanAnnN RdrName -> Entry
getAnnotationEntry (L SrcSpanAnnN
sann RdrName
_) = SrcSpanAnnN -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn SrcSpanAnnN
sann
  setAnnotationAnchor :: GenLocated SrcSpanAnnN RdrName
-> Anchor -> EpAnnComments -> GenLocated SrcSpanAnnN RdrName
setAnnotationAnchor = GenLocated SrcSpanAnnN RdrName
-> Anchor -> EpAnnComments -> GenLocated SrcSpanAnnN RdrName
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
exact x :: GenLocated SrcSpanAnnN RdrName
x@(L (SrcSpanAnn EpAnn NameAnn
EpAnnNotUsed SrcSpan
l) RdrName
n) = do
    Anchor
_ <- Anchor -> RdrName -> EP w m Anchor
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Anchor -> RdrName -> EP w m Anchor
printUnicode (SrcSpan -> Anchor
spanAsAnchor SrcSpan
l) RdrName
n
    GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return GenLocated SrcSpanAnnN RdrName
x
  exact (L (SrcSpanAnn (EpAnn Anchor
anc NameAnn
ann EpAnnComments
cs) SrcSpan
ll) RdrName
n) = do
    NameAnn
ann' <-
      case NameAnn
ann of
        NameAnn NameAdornment
a EpaLocation
o EpaLocation
l EpaLocation
c [TrailingAnn]
t -> do
          (EpaLocation, Maybe (EpaLocation, RdrName), EpaLocation)
mn <- NameAdornment
-> EpaLocation
-> Maybe (EpaLocation, RdrName)
-> EpaLocation
-> EP w m (EpaLocation, Maybe (EpaLocation, RdrName), EpaLocation)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
NameAdornment
-> EpaLocation
-> Maybe (EpaLocation, RdrName)
-> EpaLocation
-> EP w m (EpaLocation, Maybe (EpaLocation, RdrName), EpaLocation)
markName NameAdornment
a EpaLocation
o ((EpaLocation, RdrName) -> Maybe (EpaLocation, RdrName)
forall a. a -> Maybe a
Just (EpaLocation
l,RdrName
n)) EpaLocation
c
          case (EpaLocation, Maybe (EpaLocation, RdrName), EpaLocation)
mn of
            (EpaLocation
o', (Just (EpaLocation
l',RdrName
_n)), EpaLocation
c') -> do -- (o', (Just (l',n')), c')
              [TrailingAnn]
t' <- [TrailingAnn] -> EP w m [TrailingAnn]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[TrailingAnn] -> EP w m [TrailingAnn]
markTrailing [TrailingAnn]
t
              NameAnn -> RWST (EPOptions m w) (EPWriter w) EPState m NameAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (NameAdornment
-> EpaLocation
-> EpaLocation
-> EpaLocation
-> [TrailingAnn]
-> NameAnn
NameAnn NameAdornment
a EpaLocation
o' EpaLocation
l' EpaLocation
c' [TrailingAnn]
t')
            (EpaLocation, Maybe (EpaLocation, RdrName), EpaLocation)
_ -> String -> RWST (EPOptions m w) (EPWriter w) EPState m NameAnn
forall a. HasCallStack => String -> a
error String
"ExactPrint (LocatedN RdrName)"
        NameAnnCommas NameAdornment
a EpaLocation
o [EpaLocation]
commas EpaLocation
c [TrailingAnn]
t -> do
          let (AnnKeywordId
kwo,AnnKeywordId
kwc) = NameAdornment -> (AnnKeywordId, AnnKeywordId)
adornments NameAdornment
a
          (AddEpAnn AnnKeywordId
_ EpaLocation
o') <- CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
NoCaptureComments (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kwo EpaLocation
o)
          [EpaLocation]
commas' <- [EpaLocation]
-> (EpaLocation
    -> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation)
-> RWST (EPOptions m w) (EPWriter w) EPState m [EpaLocation]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [EpaLocation]
commas (\EpaLocation
loc -> AddEpAnn -> EpaLocation
locFromAdd (AddEpAnn -> EpaLocation)
-> EP w m AddEpAnn
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
NoCaptureComments (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
AnnComma EpaLocation
loc))
          (AddEpAnn AnnKeywordId
_ EpaLocation
c') <- CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
NoCaptureComments (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kwc EpaLocation
c)
          [TrailingAnn]
t' <- [TrailingAnn] -> EP w m [TrailingAnn]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[TrailingAnn] -> EP w m [TrailingAnn]
markTrailing [TrailingAnn]
t
          NameAnn -> RWST (EPOptions m w) (EPWriter w) EPState m NameAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (NameAdornment
-> EpaLocation
-> [EpaLocation]
-> EpaLocation
-> [TrailingAnn]
-> NameAnn
NameAnnCommas NameAdornment
a EpaLocation
o' [EpaLocation]
commas' EpaLocation
c' [TrailingAnn]
t')
        NameAnnBars NameAdornment
a EpaLocation
o [EpaLocation]
bars EpaLocation
c [TrailingAnn]
t -> do
          let (AnnKeywordId
kwo,AnnKeywordId
kwc) = NameAdornment -> (AnnKeywordId, AnnKeywordId)
adornments NameAdornment
a
          (AddEpAnn AnnKeywordId
_ EpaLocation
o') <- CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
NoCaptureComments (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kwo EpaLocation
o)
          [EpaLocation]
bars' <- [EpaLocation]
-> (EpaLocation
    -> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation)
-> RWST (EPOptions m w) (EPWriter w) EPState m [EpaLocation]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [EpaLocation]
bars (\EpaLocation
loc -> AddEpAnn -> EpaLocation
locFromAdd (AddEpAnn -> EpaLocation)
-> EP w m AddEpAnn
-> RWST (EPOptions m w) (EPWriter w) EPState m EpaLocation
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
NoCaptureComments (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
AnnVbar EpaLocation
loc))
          (AddEpAnn AnnKeywordId
_ EpaLocation
c') <- CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
NoCaptureComments (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kwc EpaLocation
c)
          [TrailingAnn]
t' <- [TrailingAnn] -> EP w m [TrailingAnn]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[TrailingAnn] -> EP w m [TrailingAnn]
markTrailing [TrailingAnn]
t
          NameAnn -> RWST (EPOptions m w) (EPWriter w) EPState m NameAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (NameAdornment
-> EpaLocation
-> [EpaLocation]
-> EpaLocation
-> [TrailingAnn]
-> NameAnn
NameAnnBars NameAdornment
a EpaLocation
o' [EpaLocation]
bars' EpaLocation
c' [TrailingAnn]
t')
        NameAnnOnly NameAdornment
a EpaLocation
o EpaLocation
c [TrailingAnn]
t -> do
          (EpaLocation
o',Maybe (EpaLocation, RdrName)
_,EpaLocation
c') <- NameAdornment
-> EpaLocation
-> Maybe (EpaLocation, RdrName)
-> EpaLocation
-> EP w m (EpaLocation, Maybe (EpaLocation, RdrName), EpaLocation)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
NameAdornment
-> EpaLocation
-> Maybe (EpaLocation, RdrName)
-> EpaLocation
-> EP w m (EpaLocation, Maybe (EpaLocation, RdrName), EpaLocation)
markName NameAdornment
a EpaLocation
o Maybe (EpaLocation, RdrName)
forall a. Maybe a
Nothing EpaLocation
c
          [TrailingAnn]
t' <- [TrailingAnn] -> EP w m [TrailingAnn]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[TrailingAnn] -> EP w m [TrailingAnn]
markTrailing [TrailingAnn]
t
          NameAnn -> RWST (EPOptions m w) (EPWriter w) EPState m NameAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (NameAdornment
-> EpaLocation -> EpaLocation -> [TrailingAnn] -> NameAnn
NameAnnOnly NameAdornment
a EpaLocation
o' EpaLocation
c' [TrailingAnn]
t')
        NameAnnRArrow EpaLocation
nl [TrailingAnn]
t -> do
          (AddEpAnn AnnKeywordId
_ EpaLocation
nl') <- CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
NoCaptureComments (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
AnnRarrow EpaLocation
nl)
          [TrailingAnn]
t' <- [TrailingAnn] -> EP w m [TrailingAnn]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[TrailingAnn] -> EP w m [TrailingAnn]
markTrailing [TrailingAnn]
t
          NameAnn -> RWST (EPOptions m w) (EPWriter w) EPState m NameAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpaLocation -> [TrailingAnn] -> NameAnn
NameAnnRArrow EpaLocation
nl' [TrailingAnn]
t')
        NameAnnQuote EpaLocation
q SrcSpanAnnN
name [TrailingAnn]
t -> do
          String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"NameAnnQuote"
          (AddEpAnn AnnKeywordId
_ EpaLocation
q') <- CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
NoCaptureComments (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
AnnSimpleQuote EpaLocation
q)
          (L SrcSpanAnnN
name' RdrName
_) <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated (SrcSpanAnnN -> RdrName -> GenLocated SrcSpanAnnN RdrName
forall l e. l -> e -> GenLocated l e
L SrcSpanAnnN
name RdrName
n)
          [TrailingAnn]
t' <- [TrailingAnn] -> EP w m [TrailingAnn]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[TrailingAnn] -> EP w m [TrailingAnn]
markTrailing [TrailingAnn]
t
          NameAnn -> RWST (EPOptions m w) (EPWriter w) EPState m NameAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpaLocation -> SrcSpanAnnN -> [TrailingAnn] -> NameAnn
NameAnnQuote EpaLocation
q' SrcSpanAnnN
name' [TrailingAnn]
t')
        NameAnnTrailing [TrailingAnn]
t -> do
          Anchor
_anc' <- Anchor -> RdrName -> EP w m Anchor
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Anchor -> RdrName -> EP w m Anchor
printUnicode Anchor
anc RdrName
n
          [TrailingAnn]
t' <- [TrailingAnn] -> EP w m [TrailingAnn]
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[TrailingAnn] -> EP w m [TrailingAnn]
markTrailing [TrailingAnn]
t
          NameAnn -> RWST (EPOptions m w) (EPWriter w) EPState m NameAnn
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([TrailingAnn] -> NameAnn
NameAnnTrailing [TrailingAnn]
t')
    GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnN -> RdrName -> GenLocated SrcSpanAnnN RdrName
forall l e. l -> e -> GenLocated l e
L (EpAnn NameAnn -> SrcSpan -> SrcSpanAnnN
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn (Anchor -> NameAnn -> EpAnnComments -> EpAnn NameAnn
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc NameAnn
ann' EpAnnComments
cs) SrcSpan
ll) RdrName
n)

locFromAdd :: AddEpAnn -> EpaLocation
locFromAdd :: AddEpAnn -> EpaLocation
locFromAdd (AddEpAnn AnnKeywordId
_ EpaLocation
loc) = EpaLocation
loc

printUnicode :: (Monad m, Monoid w) => Anchor -> RdrName -> EP w m Anchor
printUnicode :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Anchor -> RdrName -> EP w m Anchor
printUnicode Anchor
anc RdrName
n = do
  let str :: String
str = case (RdrName -> String
forall a. Outputable a => a -> String
showPprUnsafe RdrName
n) of
            -- TODO: unicode support?
              String
"forall" -> if RealSrcSpan -> Int
spanLength (Anchor -> RealSrcSpan
anchor Anchor
anc) Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1 then String
"∀" else String
"forall"
              String
s -> String
s
  EpaLocation
loc <- CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
printStringAtAAC CaptureComments
NoCaptureComments (DeltaPos -> [LEpaComment] -> EpaLocation
EpaDelta (Int -> DeltaPos
SameLine Int
0) []) String
str
  case EpaLocation
loc of
    EpaSpan RealSrcSpan
_ Maybe BufSpan
_ -> Anchor -> EP w m Anchor
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Anchor
anc
    EpaDelta DeltaPos
dp [] -> Anchor -> EP w m Anchor
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Anchor
anc { anchor_op = MovedAnchor dp }
    EpaDelta DeltaPos
_ [LEpaComment]
_cs -> String -> EP w m Anchor
forall a. HasCallStack => String -> a
error String
"printUnicode should not capture comments"


markName :: (Monad m, Monoid w)
  => NameAdornment -> EpaLocation -> Maybe (EpaLocation,RdrName) -> EpaLocation
  -> EP w m (EpaLocation, Maybe (EpaLocation,RdrName), EpaLocation)
markName :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
NameAdornment
-> EpaLocation
-> Maybe (EpaLocation, RdrName)
-> EpaLocation
-> EP w m (EpaLocation, Maybe (EpaLocation, RdrName), EpaLocation)
markName NameAdornment
adorn EpaLocation
open Maybe (EpaLocation, RdrName)
mname EpaLocation
close = do
  let (AnnKeywordId
kwo,AnnKeywordId
kwc) = NameAdornment -> (AnnKeywordId, AnnKeywordId)
adornments NameAdornment
adorn
  (AddEpAnn AnnKeywordId
_ EpaLocation
open') <- CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
CaptureComments (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kwo EpaLocation
open)
  Maybe (EpaLocation, RdrName)
mname' <-
    case Maybe (EpaLocation, RdrName)
mname of
      Maybe (EpaLocation, RdrName)
Nothing -> Maybe (EpaLocation, RdrName)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (EpaLocation, RdrName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (EpaLocation, RdrName)
forall a. Maybe a
Nothing
      Just (EpaLocation
name, RdrName
a) -> do
        EpaLocation
name' <- CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> EpaLocation -> String -> EP w m EpaLocation
printStringAtAAC CaptureComments
CaptureComments EpaLocation
name (RdrName -> String
forall a. Outputable a => a -> String
showPprUnsafe RdrName
a)
        Maybe (EpaLocation, RdrName)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe (EpaLocation, RdrName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ((EpaLocation, RdrName) -> Maybe (EpaLocation, RdrName)
forall a. a -> Maybe a
Just (EpaLocation
name',RdrName
a))
  (AddEpAnn AnnKeywordId
_ EpaLocation
close') <- CaptureComments -> AddEpAnn -> EP w m AddEpAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
CaptureComments -> AddEpAnn -> EP w m AddEpAnn
markKwC CaptureComments
CaptureComments (AnnKeywordId -> EpaLocation -> AddEpAnn
AddEpAnn AnnKeywordId
kwc EpaLocation
close)
  (EpaLocation, Maybe (EpaLocation, RdrName), EpaLocation)
-> EP w m (EpaLocation, Maybe (EpaLocation, RdrName), EpaLocation)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpaLocation
open', Maybe (EpaLocation, RdrName)
mname', EpaLocation
close')

adornments :: NameAdornment -> (AnnKeywordId, AnnKeywordId)
adornments :: NameAdornment -> (AnnKeywordId, AnnKeywordId)
adornments NameAdornment
NameParens     = (AnnKeywordId
AnnOpenP, AnnKeywordId
AnnCloseP)
adornments NameAdornment
NameParensHash = (AnnKeywordId
AnnOpenPH, AnnKeywordId
AnnClosePH)
adornments NameAdornment
NameBackquotes = (AnnKeywordId
AnnBackquote, AnnKeywordId
AnnBackquote)
adornments NameAdornment
NameSquare     = (AnnKeywordId
AnnOpenS, AnnKeywordId
AnnCloseS)


markTrailingL :: (Monad m, Monoid w) => EpAnn a -> Lens a [TrailingAnn] -> EP w m (EpAnn a)
markTrailingL :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [TrailingAnn] -> EP w m (EpAnn a)
markTrailingL EpAnn a
EpAnnNotUsed Lens a [TrailingAnn]
_ = EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn a
forall ann. EpAnn ann
EpAnnNotUsed
markTrailingL (EpAnn Anchor
anc a
an EpAnnComments
cs) Lens a [TrailingAnn]
l = do
  [TrailingAnn]
ts <- (TrailingAnn
 -> RWST (EPOptions m w) (EPWriter w) EPState m TrailingAnn)
-> [TrailingAnn]
-> RWST (EPOptions m w) (EPWriter w) EPState m [TrailingAnn]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM TrailingAnn
-> RWST (EPOptions m w) (EPWriter w) EPState m TrailingAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
TrailingAnn -> EP w m TrailingAnn
markKwT (Getting a [TrailingAnn] -> a -> [TrailingAnn]
forall s (m :: * -> *) a. MonadReader s m => Getting s a -> m a
view Getting a [TrailingAnn]
Lens a [TrailingAnn]
l a
an)
  EpAnn a -> RWST (EPOptions m w) (EPWriter w) EPState m (EpAnn a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Anchor -> a -> EpAnnComments -> EpAnn a
forall ann. Anchor -> ann -> EpAnnComments -> EpAnn ann
EpAnn Anchor
anc (Lens a [TrailingAnn] -> [TrailingAnn] -> a -> a
forall a b. Lens a b -> b -> a -> a
set ([TrailingAnn] -> f [TrailingAnn]) -> a -> f a
Lens a [TrailingAnn]
l [TrailingAnn]
ts a
an) EpAnnComments
cs)

markTrailing :: (Monad m, Monoid w) => [TrailingAnn] -> EP w m [TrailingAnn]
markTrailing :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[TrailingAnn] -> EP w m [TrailingAnn]
markTrailing [TrailingAnn]
ts = do
  Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"markTrailing:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, [TrailingAnn]) -> String
forall a. Outputable a => a -> String
showPprUnsafe (Pos
p,[TrailingAnn]
ts)
  (TrailingAnn
 -> RWST (EPOptions m w) (EPWriter w) EPState m TrailingAnn)
-> [TrailingAnn] -> EP w m [TrailingAnn]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM TrailingAnn
-> RWST (EPOptions m w) (EPWriter w) EPState m TrailingAnn
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
TrailingAnn -> EP w m TrailingAnn
markKwT [TrailingAnn]
ts

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

-- based on pp_condecls in Decls.hs
exact_condecls :: (Monad m, Monoid w)
  => EpAnn [AddEpAnn] -> [LConDecl GhcPs] -> EP w m (EpAnn [AddEpAnn],[LConDecl GhcPs])
exact_condecls :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn [AddEpAnn]
-> [LConDecl GhcPs] -> EP w m (EpAnn [AddEpAnn], [LConDecl GhcPs])
exact_condecls EpAnn [AddEpAnn]
an [LConDecl GhcPs]
cs
  | Bool
gadt_syntax                  -- In GADT syntax
  = do
      [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
cs' <- (GenLocated SrcSpanAnnA (ConDecl GhcPs)
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnA (ConDecl GhcPs)))
-> [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated SrcSpanAnnA (ConDecl GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LConDecl GhcPs]
[GenLocated SrcSpanAnnA (ConDecl GhcPs)]
cs
      (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (ConDecl GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (ConDecl GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an, [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
cs')
  | Bool
otherwise                    -- In H98 syntax
  = do
      EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnEqual
      [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
cs' <- (GenLocated SrcSpanAnnA (ConDecl GhcPs)
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnA (ConDecl GhcPs)))
-> [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated SrcSpanAnnA (ConDecl GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (ConDecl GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LConDecl GhcPs]
[GenLocated SrcSpanAnnA (ConDecl GhcPs)]
cs
      (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (ConDecl GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], [GenLocated SrcSpanAnnA (ConDecl GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, [GenLocated SrcSpanAnnA (ConDecl GhcPs)]
cs')
  where
    gadt_syntax :: Bool
gadt_syntax = case [LConDecl GhcPs]
cs of
      []                      -> Bool
False
      (L SrcSpanAnnA
_ ConDeclH98{}  : [LConDecl GhcPs]
_) -> Bool
False
      (L SrcSpanAnnA
_ ConDeclGADT{} : [LConDecl GhcPs]
_) -> Bool
True

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

instance ExactPrint (ConDecl GhcPs) where
  getAnnotationEntry :: ConDecl GhcPs -> Entry
getAnnotationEntry x :: ConDecl GhcPs
x@(ConDeclGADT{}) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn (ConDecl GhcPs -> XConDeclGADT GhcPs
forall pass. ConDecl pass -> XConDeclGADT pass
con_g_ext ConDecl GhcPs
x)
  getAnnotationEntry x :: ConDecl GhcPs
x@(ConDeclH98{})  = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn (ConDecl GhcPs -> XConDeclH98 GhcPs
forall pass. ConDecl pass -> XConDeclH98 pass
con_ext ConDecl GhcPs
x)

  setAnnotationAnchor :: ConDecl GhcPs -> Anchor -> EpAnnComments -> ConDecl GhcPs
setAnnotationAnchor x :: ConDecl GhcPs
x@ConDeclGADT{} Anchor
anc EpAnnComments
cs = ConDecl GhcPs
x { con_g_ext = setAnchorEpa (con_g_ext x) anc cs}
  setAnnotationAnchor x :: ConDecl GhcPs
x@ConDeclH98{}  Anchor
anc EpAnnComments
cs = ConDecl GhcPs
x { con_ext   = setAnchorEpa (con_ext x) anc cs}

-- based on pprConDecl
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
ConDecl GhcPs -> EP w m (ConDecl GhcPs)
exact (ConDeclH98 { con_ext :: forall pass. ConDecl pass -> XConDeclH98 pass
con_ext = XConDeclH98 GhcPs
an
                    , con_name :: forall pass. ConDecl pass -> LIdP pass
con_name = LIdP GhcPs
con
                    , con_forall :: forall pass. ConDecl pass -> Bool
con_forall = Bool
has_forall
                    , con_ex_tvs :: forall pass. ConDecl pass -> [LHsTyVarBndr Specificity pass]
con_ex_tvs = [LHsTyVarBndr Specificity GhcPs]
ex_tvs
                    , con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (LHsContext GhcPs)
mcxt
                    , con_args :: forall pass. ConDecl pass -> HsConDeclH98Details pass
con_args = HsConDeclH98Details GhcPs
args
                    , con_doc :: forall pass. ConDecl pass -> Maybe (LHsDoc pass)
con_doc = Maybe (LHsDoc GhcPs)
doc }) = do
    -- doc' <- mapM markAnnotated doc
    EpAnn [AddEpAnn]
an0 <- if Bool
has_forall
      then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XConDeclH98 GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnForall
      else EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XConDeclH98 GhcPs
EpAnn [AddEpAnn]
an
    [GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)]
ex_tvs' <- (GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)))
-> [GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsTyVarBndr Specificity GhcPs]
[GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)]
ex_tvs
    EpAnn [AddEpAnn]
an1 <- if Bool
has_forall
      then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDot
      else EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn [AddEpAnn]
an0
    Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mcxt' <- (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
-> Maybe
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe
        (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mcxt
    EpAnn [AddEpAnn]
an2 <- if (Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
-> Bool
forall a. Maybe a -> Bool
isJust Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mcxt)
      then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDarrow
      else EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn [AddEpAnn]
an1

    (GenLocated SrcSpanAnnN RdrName
con', HsConDetails
  Void
  (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
  (GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
args') <- HsConDetails
  Void
  (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
  (GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      HsConDetails
        Void
        (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
        (GenLocated
           SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]))
exact_details HsConDeclH98Details GhcPs
HsConDetails
  Void
  (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
  (GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
args
    ConDecl GhcPs -> EP w m (ConDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (ConDeclH98 { con_ext :: XConDeclH98 GhcPs
con_ext = XConDeclH98 GhcPs
EpAnn [AddEpAnn]
an2
                       , con_name :: LIdP GhcPs
con_name = LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
con'
                       , con_forall :: Bool
con_forall = Bool
has_forall
                       , con_ex_tvs :: [LHsTyVarBndr Specificity GhcPs]
con_ex_tvs = [LHsTyVarBndr Specificity GhcPs]
[GenLocated SrcSpanAnnA (HsTyVarBndr Specificity GhcPs)]
ex_tvs'
                       , con_mb_cxt :: Maybe (LHsContext GhcPs)
con_mb_cxt = Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mcxt'
                       , con_args :: HsConDeclH98Details GhcPs
con_args = HsConDeclH98Details GhcPs
HsConDetails
  Void
  (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
  (GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
args'
                       , con_doc :: Maybe (LHsDoc GhcPs)
con_doc = Maybe (LHsDoc GhcPs)
doc })

    where
    --   -- In ppr_details: let's not print the multiplicities (they are always 1, by
    --   -- definition) as they do not appear in an actual declaration.
      exact_details :: HsConDetails
  Void
  (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
  (GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      HsConDetails
        Void
        (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
        (GenLocated
           SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]))
exact_details (InfixCon HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
t1 HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
t2) = do
        HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
t1' <- HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> EP w m (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
t1
        GenLocated SrcSpanAnnN RdrName
con' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
con
        HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
t2' <- HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> EP w m (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
t2
        (GenLocated SrcSpanAnnN RdrName,
 HsConDetails
   Void
   (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
   (GenLocated
      SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      HsConDetails
        Void
        (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
        (GenLocated
           SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnN RdrName
con', HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> HsConDetails
     Void
     (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
     (GenLocated
        SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
forall tyarg arg rec. arg -> arg -> HsConDetails tyarg arg rec
InfixCon HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
t1' HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
t2')
      exact_details (PrefixCon [Void]
tyargs [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
tys) = do
        GenLocated SrcSpanAnnN RdrName
con' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
con
        [Void]
tyargs' <- [Void] -> EP w m [Void]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [Void]
tyargs
        [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
tys' <- [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
-> EP w m [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
tys
        (GenLocated SrcSpanAnnN RdrName,
 HsConDetails
   Void
   (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
   (GenLocated
      SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      HsConDetails
        Void
        (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
        (GenLocated
           SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnN RdrName
con', [Void]
-> [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
-> HsConDetails
     Void
     (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
     (GenLocated
        SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
forall tyarg arg rec.
[tyarg] -> [arg] -> HsConDetails tyarg arg rec
PrefixCon [Void]
tyargs' [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
tys')
      exact_details (RecCon GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fields) = do
        GenLocated SrcSpanAnnN RdrName
con' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
con
        GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fields' <- GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fields
        (GenLocated SrcSpanAnnN RdrName,
 HsConDetails
   Void
   (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
   (GenLocated
      SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnN RdrName,
      HsConDetails
        Void
        (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
        (GenLocated
           SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnN RdrName
con', GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> HsConDetails
     Void
     (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
     (GenLocated
        SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
forall tyarg arg rec. rec -> HsConDetails tyarg arg rec
RecCon GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fields')

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

  exact (ConDeclGADT { con_g_ext :: forall pass. ConDecl pass -> XConDeclGADT pass
con_g_ext = XConDeclGADT GhcPs
an
                     , con_names :: forall pass. ConDecl pass -> NonEmpty (LIdP pass)
con_names = NonEmpty (LIdP GhcPs)
cons
                     , con_dcolon :: forall pass. ConDecl pass -> LHsUniToken "::" "\8759" pass
con_dcolon = LHsUniToken "::" "\8759" GhcPs
dcol
                     , con_bndrs :: forall pass. ConDecl pass -> XRec pass (HsOuterSigTyVarBndrs pass)
con_bndrs = XRec GhcPs (HsOuterSigTyVarBndrs GhcPs)
bndrs
                     , con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (LHsContext GhcPs)
mcxt, con_g_args :: forall pass. ConDecl pass -> HsConDeclGADTDetails pass
con_g_args = HsConDeclGADTDetails GhcPs
args
                     , con_res_ty :: forall pass. ConDecl pass -> LHsType pass
con_res_ty = LHsType GhcPs
res_ty, con_doc :: forall pass. ConDecl pass -> Maybe (LHsDoc pass)
con_doc = Maybe (LHsDoc GhcPs)
doc }) = do
    -- doc' <- mapM markAnnotated doc
    NonEmpty (GenLocated SrcSpanAnnN RdrName)
cons' <- (GenLocated SrcSpanAnnN RdrName
 -> EP w m (GenLocated SrcSpanAnnN RdrName))
-> NonEmpty (GenLocated SrcSpanAnnN RdrName)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (NonEmpty (GenLocated SrcSpanAnnN RdrName))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> NonEmpty a -> m (NonEmpty b)
mapM GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated NonEmpty (LIdP GhcPs)
NonEmpty (GenLocated SrcSpanAnnN RdrName)
cons
    GenLocated TokenLocation (HsUniToken "::" "\8759")
dcol' <- LHsUniToken "::" "\8759" GhcPs
-> EP w m (LHsUniToken "::" "\8759" GhcPs)
forall (m :: * -> *) w (tok :: Symbol) (utok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok, KnownSymbol utok) =>
LHsUniToken tok utok GhcPs -> EP w m (LHsUniToken tok utok GhcPs)
markUniToken LHsUniToken "::" "\8759" GhcPs
dcol
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> [AnnKeywordId]
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [AddEpAnn] -> [AnnKeywordId] -> EP w m (EpAnn a)
annotationsToComments XConDeclGADT GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl  [AnnKeywordId
AnnOpenP, AnnKeywordId
AnnCloseP]

    -- Work around https://gitlab.haskell.org/ghc/ghc/-/issues/20558
    GenLocated SrcSpanAnnA (HsOuterSigTyVarBndrs GhcPs)
bndrs' <- case XRec GhcPs (HsOuterSigTyVarBndrs GhcPs)
bndrs of
      L SrcSpanAnnA
_ (HsOuterImplicit XHsOuterImplicit GhcPs
_) -> GenLocated SrcSpanAnnA (HsOuterSigTyVarBndrs GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (HsOuterSigTyVarBndrs GhcPs))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XRec GhcPs (HsOuterSigTyVarBndrs GhcPs)
GenLocated SrcSpanAnnA (HsOuterSigTyVarBndrs GhcPs)
bndrs
      XRec GhcPs (HsOuterSigTyVarBndrs GhcPs)
_ -> GenLocated SrcSpanAnnA (HsOuterSigTyVarBndrs GhcPs)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnA (HsOuterSigTyVarBndrs GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsOuterSigTyVarBndrs GhcPs)
GenLocated SrcSpanAnnA (HsOuterSigTyVarBndrs GhcPs)
bndrs

    Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mcxt' <- (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
-> Maybe
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (Maybe
        (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mcxt
    EpAnn [AddEpAnn]
an2 <- if (Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
-> Bool
forall a. Maybe a -> Bool
isJust Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mcxt)
      then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDarrow
      else EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn [AddEpAnn]
an1
    HsConDeclGADTDetails GhcPs
args' <-
      case HsConDeclGADTDetails GhcPs
args of
          (PrefixConGADT [HsScaled GhcPs (LHsType GhcPs)]
args0) -> do
            [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
args0' <- (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
 -> EP w m (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))))
-> [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
-> EP w m [HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> EP w m (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [HsScaled GhcPs (LHsType GhcPs)]
[HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
args0
            HsConDeclGADTDetails GhcPs
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (HsConDeclGADTDetails GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([HsScaled GhcPs (LHsType GhcPs)] -> HsConDeclGADTDetails GhcPs
forall pass.
[HsScaled pass (LBangType pass)] -> HsConDeclGADTDetails pass
PrefixConGADT [HsScaled GhcPs (LHsType GhcPs)]
[HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))]
args0')
          (RecConGADT XRec GhcPs [LConDeclField GhcPs]
fields LHsUniToken "->" "\8594" GhcPs
rarr) -> do
            GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fields' <- GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs [LConDeclField GhcPs]
GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fields
            GenLocated TokenLocation (HsUniToken "->" "\8594")
rarr' <- LHsUniToken "->" "\8594" GhcPs
-> EP w m (LHsUniToken "->" "\8594" GhcPs)
forall (m :: * -> *) w (tok :: Symbol) (utok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok, KnownSymbol utok) =>
LHsUniToken tok utok GhcPs -> EP w m (LHsUniToken tok utok GhcPs)
markUniToken LHsUniToken "->" "\8594" GhcPs
rarr
            HsConDeclGADTDetails GhcPs
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (HsConDeclGADTDetails GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XRec GhcPs [LConDeclField GhcPs]
-> LHsUniToken "->" "\8594" GhcPs -> HsConDeclGADTDetails GhcPs
forall pass.
XRec pass [LConDeclField pass]
-> LHsUniToken "->" "\8594" pass -> HsConDeclGADTDetails pass
RecConGADT XRec GhcPs [LConDeclField GhcPs]
GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fields' LHsUniToken "->" "\8594" GhcPs
GenLocated TokenLocation (HsUniToken "->" "\8594")
rarr')
    GenLocated SrcSpanAnnA (HsType GhcPs)
res_ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
res_ty
    ConDecl GhcPs -> EP w m (ConDecl GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (ConDeclGADT { con_g_ext :: XConDeclGADT GhcPs
con_g_ext = XConDeclGADT GhcPs
EpAnn [AddEpAnn]
an2
                        , con_names :: NonEmpty (LIdP GhcPs)
con_names = NonEmpty (LIdP GhcPs)
NonEmpty (GenLocated SrcSpanAnnN RdrName)
cons'
                        , con_dcolon :: LHsUniToken "::" "\8759" GhcPs
con_dcolon = LHsUniToken "::" "\8759" GhcPs
GenLocated TokenLocation (HsUniToken "::" "\8759")
dcol'
                        , con_bndrs :: XRec GhcPs (HsOuterSigTyVarBndrs GhcPs)
con_bndrs = XRec GhcPs (HsOuterSigTyVarBndrs GhcPs)
GenLocated SrcSpanAnnA (HsOuterSigTyVarBndrs GhcPs)
bndrs'
                        , con_mb_cxt :: Maybe (LHsContext GhcPs)
con_mb_cxt = Maybe (LHsContext GhcPs)
Maybe
  (GenLocated SrcSpanAnnC [GenLocated SrcSpanAnnA (HsType GhcPs)])
mcxt', con_g_args :: HsConDeclGADTDetails GhcPs
con_g_args = HsConDeclGADTDetails GhcPs
args'
                        , con_res_ty :: LHsType GhcPs
con_res_ty = LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
res_ty', con_doc :: Maybe (LHsDoc GhcPs)
con_doc = Maybe (LHsDoc GhcPs)
doc })

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

instance ExactPrint Void where
  getAnnotationEntry :: Void -> Entry
getAnnotationEntry = Entry -> Void -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: Void -> Anchor -> EpAnnComments -> Void
setAnnotationAnchor Void
a Anchor
_ EpAnnComments
_ = Void
a
  exact :: forall (m :: * -> *) w. (Monad m, Monoid w) => Void -> EP w m Void
exact Void
x = Void -> RWST (EPOptions m w) (EPWriter w) EPState m Void
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Void
x

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

instance ExactPrintTVFlag flag => ExactPrint (HsOuterTyVarBndrs flag GhcPs) where
  getAnnotationEntry :: HsOuterTyVarBndrs flag GhcPs -> Entry
getAnnotationEntry (HsOuterImplicit XHsOuterImplicit GhcPs
_) = Entry
NoEntryVal
  getAnnotationEntry (HsOuterExplicit XHsOuterExplicit GhcPs flag
an [LHsTyVarBndr flag (NoGhcTc GhcPs)]
_) = EpAnnForallTy -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XHsOuterExplicit GhcPs flag
EpAnnForallTy
an

  setAnnotationAnchor :: HsOuterTyVarBndrs flag GhcPs
-> Anchor -> EpAnnComments -> HsOuterTyVarBndrs flag GhcPs
setAnnotationAnchor (HsOuterImplicit XHsOuterImplicit GhcPs
a) Anchor
_ EpAnnComments
_ = XHsOuterImplicit GhcPs -> HsOuterTyVarBndrs flag GhcPs
forall flag pass.
XHsOuterImplicit pass -> HsOuterTyVarBndrs flag pass
HsOuterImplicit XHsOuterImplicit GhcPs
a
  setAnnotationAnchor (HsOuterExplicit XHsOuterExplicit GhcPs flag
an [LHsTyVarBndr flag (NoGhcTc GhcPs)]
a) Anchor
anc EpAnnComments
cs = XHsOuterExplicit GhcPs flag
-> [LHsTyVarBndr flag (NoGhcTc GhcPs)]
-> HsOuterTyVarBndrs flag GhcPs
forall flag pass.
XHsOuterExplicit pass flag
-> [LHsTyVarBndr flag (NoGhcTc pass)]
-> HsOuterTyVarBndrs flag pass
HsOuterExplicit (EpAnnForallTy -> Anchor -> EpAnnComments -> EpAnnForallTy
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XHsOuterExplicit GhcPs flag
EpAnnForallTy
an Anchor
anc EpAnnComments
cs) [LHsTyVarBndr flag (NoGhcTc GhcPs)]
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsOuterTyVarBndrs flag GhcPs
-> EP w m (HsOuterTyVarBndrs flag GhcPs)
exact b :: HsOuterTyVarBndrs flag GhcPs
b@(HsOuterImplicit XHsOuterImplicit GhcPs
_) = HsOuterTyVarBndrs flag GhcPs
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (HsOuterTyVarBndrs flag GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HsOuterTyVarBndrs flag GhcPs
b
  exact (HsOuterExplicit XHsOuterExplicit GhcPs flag
an [LHsTyVarBndr flag (NoGhcTc GhcPs)]
bndrs) = do
    EpAnnForallTy
an0 <- EpAnnForallTy
-> Lens (AddEpAnn, AddEpAnn) AddEpAnn -> EP w m EpAnnForallTy
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA XHsOuterExplicit GhcPs flag
EpAnnForallTy
an (AddEpAnn -> f AddEpAnn)
-> (AddEpAnn, AddEpAnn) -> f (AddEpAnn, AddEpAnn)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
Lens (AddEpAnn, AddEpAnn) AddEpAnn
lfst -- "forall"
    [GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs)]
bndrs' <- [GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LHsTyVarBndr flag (NoGhcTc GhcPs)]
[GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs)]
bndrs
    EpAnnForallTy
an1 <- EpAnnForallTy
-> Lens (AddEpAnn, AddEpAnn) AddEpAnn -> EP w m EpAnnForallTy
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a AddEpAnn -> EP w m (EpAnn a)
markLensAA EpAnnForallTy
an0 (AddEpAnn -> f AddEpAnn)
-> (AddEpAnn, AddEpAnn) -> f (AddEpAnn, AddEpAnn)
forall a (f :: * -> *).
Functor f =>
(a -> f a) -> (a, a) -> f (a, a)
Lens (AddEpAnn, AddEpAnn) AddEpAnn
lsnd -- "."
    HsOuterTyVarBndrs flag GhcPs
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (HsOuterTyVarBndrs flag GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsOuterExplicit GhcPs flag
-> [LHsTyVarBndr flag (NoGhcTc GhcPs)]
-> HsOuterTyVarBndrs flag GhcPs
forall flag pass.
XHsOuterExplicit pass flag
-> [LHsTyVarBndr flag (NoGhcTc pass)]
-> HsOuterTyVarBndrs flag pass
HsOuterExplicit XHsOuterExplicit GhcPs flag
EpAnnForallTy
an1 [LHsTyVarBndr flag (NoGhcTc GhcPs)]
[GenLocated SrcSpanAnnA (HsTyVarBndr flag GhcPs)]
bndrs')

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

instance ExactPrint (ConDeclField GhcPs) where
  getAnnotationEntry :: ConDeclField GhcPs -> Entry
getAnnotationEntry f :: ConDeclField GhcPs
f@(ConDeclField{}) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn (ConDeclField GhcPs -> XConDeclField GhcPs
forall pass. ConDeclField pass -> XConDeclField pass
cd_fld_ext ConDeclField GhcPs
f)

  setAnnotationAnchor :: ConDeclField GhcPs -> Anchor -> EpAnnComments -> ConDeclField GhcPs
setAnnotationAnchor ConDeclField GhcPs
x Anchor
anc EpAnnComments
cs = ConDeclField GhcPs
x { cd_fld_ext = setAnchorEpa (cd_fld_ext x) anc cs}

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
ConDeclField GhcPs -> EP w m (ConDeclField GhcPs)
exact (ConDeclField XConDeclField GhcPs
an [LFieldOcc GhcPs]
names LHsType GhcPs
ftype Maybe (LHsDoc GhcPs)
mdoc) = do
    [GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)]
names' <- [GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)]
-> EP w m [GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LFieldOcc GhcPs]
[GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)]
names
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XConDeclField GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
    GenLocated SrcSpanAnnA (HsType GhcPs)
ftype' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ftype
    -- mdoc' <- mapM markAnnotated mdoc
    ConDeclField GhcPs -> EP w m (ConDeclField GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XConDeclField GhcPs
-> [LFieldOcc GhcPs]
-> LHsType GhcPs
-> Maybe (LHsDoc GhcPs)
-> ConDeclField GhcPs
forall pass.
XConDeclField pass
-> [LFieldOcc pass]
-> LBangType pass
-> Maybe (LHsDoc pass)
-> ConDeclField pass
ConDeclField XConDeclField GhcPs
EpAnn [AddEpAnn]
an0 [LFieldOcc GhcPs]
[GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)]
names' LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ftype' Maybe (LHsDoc GhcPs)
mdoc)

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

instance ExactPrint (FieldOcc GhcPs) where
  getAnnotationEntry :: FieldOcc GhcPs -> Entry
getAnnotationEntry = Entry -> FieldOcc GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: FieldOcc GhcPs -> Anchor -> EpAnnComments -> FieldOcc GhcPs
setAnnotationAnchor FieldOcc GhcPs
a Anchor
_ EpAnnComments
_ = FieldOcc GhcPs
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
FieldOcc GhcPs -> EP w m (FieldOcc GhcPs)
exact f :: FieldOcc GhcPs
f@(FieldOcc XCFieldOcc GhcPs
_ XRec GhcPs RdrName
n) = GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs RdrName
GenLocated SrcSpanAnnN RdrName
n EP w m (GenLocated SrcSpanAnnN RdrName)
-> RWST (EPOptions m w) (EPWriter w) EPState m (FieldOcc GhcPs)
-> RWST (EPOptions m w) (EPWriter w) EPState m (FieldOcc GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> FieldOcc GhcPs
-> RWST (EPOptions m w) (EPWriter w) EPState m (FieldOcc GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return FieldOcc GhcPs
f

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

instance ExactPrint (AmbiguousFieldOcc GhcPs) where
  getAnnotationEntry :: AmbiguousFieldOcc GhcPs -> Entry
getAnnotationEntry = Entry -> AmbiguousFieldOcc GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: AmbiguousFieldOcc GhcPs
-> Anchor -> EpAnnComments -> AmbiguousFieldOcc GhcPs
setAnnotationAnchor AmbiguousFieldOcc GhcPs
a Anchor
_ EpAnnComments
_ = AmbiguousFieldOcc GhcPs
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
AmbiguousFieldOcc GhcPs -> EP w m (AmbiguousFieldOcc GhcPs)
exact f :: AmbiguousFieldOcc GhcPs
f@(Unambiguous XUnambiguous GhcPs
_ XRec GhcPs RdrName
n) = GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs RdrName
GenLocated SrcSpanAnnN RdrName
n EP w m (GenLocated SrcSpanAnnN RdrName)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (AmbiguousFieldOcc GhcPs)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (AmbiguousFieldOcc GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> AmbiguousFieldOcc GhcPs
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (AmbiguousFieldOcc GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return AmbiguousFieldOcc GhcPs
f
  exact f :: AmbiguousFieldOcc GhcPs
f@(Ambiguous   XAmbiguous GhcPs
_ XRec GhcPs RdrName
n) = GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs RdrName
GenLocated SrcSpanAnnN RdrName
n EP w m (GenLocated SrcSpanAnnN RdrName)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (AmbiguousFieldOcc GhcPs)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (AmbiguousFieldOcc GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> AmbiguousFieldOcc GhcPs
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (AmbiguousFieldOcc GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return AmbiguousFieldOcc GhcPs
f

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

instance (ExactPrint a) => ExactPrint (HsScaled GhcPs a) where
  getAnnotationEntry :: HsScaled GhcPs a -> Entry
getAnnotationEntry = Entry -> HsScaled GhcPs a -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: HsScaled GhcPs a -> Anchor -> EpAnnComments -> HsScaled GhcPs a
setAnnotationAnchor HsScaled GhcPs a
a Anchor
_ EpAnnComments
_ = HsScaled GhcPs a
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsScaled GhcPs a -> EP w m (HsScaled GhcPs a)
exact (HsScaled HsArrow GhcPs
arr a
t) = do
    a
t' <- a -> EP w m a
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated a
t
    HsArrow GhcPs
arr' <- HsArrow GhcPs -> EP w m (HsArrow GhcPs)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsArrow GhcPs -> EP w m (HsArrow GhcPs)
markArrow HsArrow GhcPs
arr
    HsScaled GhcPs a -> EP w m (HsScaled GhcPs a)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsArrow GhcPs -> a -> HsScaled GhcPs a
forall pass a. HsArrow pass -> a -> HsScaled pass a
HsScaled HsArrow GhcPs
arr' a
t')

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

instance ExactPrint (LocatedP CType) where
  getAnnotationEntry :: GenLocated SrcSpanAnnP CType -> Entry
getAnnotationEntry = GenLocated SrcSpanAnnP CType -> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: GenLocated SrcSpanAnnP CType
-> Anchor -> EpAnnComments -> GenLocated SrcSpanAnnP CType
setAnnotationAnchor = GenLocated SrcSpanAnnP CType
-> Anchor -> EpAnnComments -> GenLocated SrcSpanAnnP CType
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated SrcSpanAnnP CType
-> EP w m (GenLocated SrcSpanAnnP CType)
exact x :: GenLocated SrcSpanAnnP CType
x@(L (SrcSpanAnn EpAnn AnnPragma
EpAnnNotUsed SrcSpan
_) CType
ct) = CType -> EP w m CType
forall (m :: * -> *) w a.
(Monad m, Monoid w, Outputable a) =>
a -> EP w m a
withPpr CType
ct EP w m CType
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnP CType)
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnP CType)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> GenLocated SrcSpanAnnP CType
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnP CType)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return GenLocated SrcSpanAnnP CType
x
  exact (L (SrcSpanAnn EpAnn AnnPragma
an SrcSpan
ll)
         (CType SourceText
stp Maybe Header
mh (SourceText
stct,FastString
ct))) = do
    EpAnn AnnPragma
an0 <- EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> SourceText -> String -> EP w m (EpAnn AnnPragma)
markAnnOpenP EpAnn AnnPragma
an SourceText
stp String
"{-# CTYPE"
    EpAnn AnnPragma
an1 <- case Maybe Header
mh of
             Maybe Header
Nothing -> EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return EpAnn AnnPragma
an0
             Just (Header SourceText
srcH FastString
_h) ->
               EpAnn AnnPragma
-> Lens AnnPragma [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn AnnPragma
an0 ([AddEpAnn] -> f [AddEpAnn]) -> AnnPragma -> f AnnPragma
Lens AnnPragma [AddEpAnn]
lapr_rest AnnKeywordId
AnnHeader (String -> Maybe String
forall a. a -> Maybe a
Just (SourceText -> String -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix SourceText
srcH String
"" String
""))
    EpAnn AnnPragma
an2 <- EpAnn AnnPragma
-> Lens AnnPragma [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a
-> Lens a [AddEpAnn]
-> AnnKeywordId
-> Maybe String
-> EP w m (EpAnn a)
markEpAnnLMS EpAnn AnnPragma
an1 ([AddEpAnn] -> f [AddEpAnn]) -> AnnPragma -> f AnnPragma
Lens AnnPragma [AddEpAnn]
lapr_rest AnnKeywordId
AnnVal (String -> Maybe String
forall a. a -> Maybe a
Just (SourceText -> String -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix SourceText
stct (FastString -> String
unpackFS FastString
ct) String
""))
    EpAnn AnnPragma
an3 <- EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpAnn AnnPragma -> EP w m (EpAnn AnnPragma)
markAnnCloseP EpAnn AnnPragma
an2
    GenLocated SrcSpanAnnP CType
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated SrcSpanAnnP CType)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnP -> CType -> GenLocated SrcSpanAnnP CType
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnPragma -> SrcSpan -> SrcSpanAnnP
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnPragma
an3 SrcSpan
ll)
         (SourceText -> Maybe Header -> (SourceText, FastString) -> CType
CType SourceText
stp Maybe Header
mh (SourceText
stct,FastString
ct)))

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

instance ExactPrint (SourceText, RuleName) where
  -- We end up at the right place from the Located wrapper
  getAnnotationEntry :: (SourceText, FastString) -> Entry
getAnnotationEntry = Entry -> (SourceText, FastString) -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: (SourceText, FastString)
-> Anchor -> EpAnnComments -> (SourceText, FastString)
setAnnotationAnchor (SourceText, FastString)
a Anchor
_ EpAnnComments
_ = (SourceText, FastString)
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
(SourceText, FastString) -> EP w m (SourceText, FastString)
exact (SourceText
st, FastString
rn)
    = String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance (SourceText -> String -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix SourceText
st (FastString -> String
unpackFS FastString
rn) String
"")
      EP w m ()
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (SourceText, FastString)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (SourceText, FastString)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (SourceText, FastString)
-> RWST
     (EPOptions m w) (EPWriter w) EPState m (SourceText, FastString)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SourceText
st, FastString
rn)


-- =====================================================================
-- LocatedL instances start --
--
-- Each is dealt with specifically, as they have
-- different wrapping annotations in the al_rest zone.
--
-- In future, the annotation could perhaps be improved, with an
-- 'al_pre' and 'al_post' set of annotations to be simply sorted and
-- applied.
-- ---------------------------------------------------------------------

instance ExactPrint (LocatedL [LocatedA (IE GhcPs)]) where
  getAnnotationEntry :: GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)] -> Entry
getAnnotationEntry = GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)] -> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
-> Anchor
-> EpAnnComments
-> GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
setAnnotationAnchor = GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
-> Anchor
-> EpAnnComments
-> GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
-> EP
     w m (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
exact (L (SrcSpanAnn EpAnn AnnList
an SrcSpan
l) [GenLocated SrcSpanAnnA (IE GhcPs)]
ies) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LocatedL [LIE"
    EpAnn AnnList
an0 <- EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn AnnList
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
AnnHiding
    Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LocatedL [LIE:p=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Pos -> String
forall a. Outputable a => a -> String
showPprUnsafe Pos
p
    (EpAnn AnnList
an1, [GenLocated SrcSpanAnnA (IE GhcPs)]
ies') <- Bool
-> EpAnn AnnList
-> EP w m [GenLocated SrcSpanAnnA (IE GhcPs)]
-> EP w m (EpAnn AnnList, [GenLocated SrcSpanAnnA (IE GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList Bool
True EpAnn AnnList
an0 ([GenLocated SrcSpanAnnA (IE GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (IE GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GenLocated SrcSpanAnnA (IE GhcPs)]
ies)
    GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
-> EP
     w m (GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnL
-> [GenLocated SrcSpanAnnA (IE GhcPs)]
-> GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (IE GhcPs)]
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnList -> SrcSpan -> SrcSpanAnnL
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnList
an1 SrcSpan
l) [GenLocated SrcSpanAnnA (IE GhcPs)]
ies')

instance (ExactPrint (Match GhcPs (LocatedA body)))
   => ExactPrint (LocatedL [LocatedA (Match GhcPs (LocatedA body))]) where
  getAnnotationEntry :: LocatedL [LocatedA (Match GhcPs (LocatedA body))] -> Entry
getAnnotationEntry = LocatedL [LocatedA (Match GhcPs (LocatedA body))] -> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: LocatedL [LocatedA (Match GhcPs (LocatedA body))]
-> Anchor
-> EpAnnComments
-> LocatedL [LocatedA (Match GhcPs (LocatedA body))]
setAnnotationAnchor = LocatedL [LocatedA (Match GhcPs (LocatedA body))]
-> Anchor
-> EpAnnComments
-> LocatedL [LocatedA (Match GhcPs (LocatedA body))]
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LocatedL [LocatedA (Match GhcPs (LocatedA body))]
-> EP w m (LocatedL [LocatedA (Match GhcPs (LocatedA body))])
exact (L SrcSpanAnnL
la [LocatedA (Match GhcPs (LocatedA body))]
a) = do
    let an :: EpAnn AnnList
an = SrcSpanAnnL -> EpAnn AnnList
forall a. SrcSpanAnn' a -> a
ann SrcSpanAnnL
la
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LocatedL [LMatch"
    -- TODO: markAnnList?
    EpAnn AnnList
an0 <- EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn AnnList
an ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
AnnWhere
    EpAnn AnnList
an1 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn AnnList
an0 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_open
    EpAnn AnnList
an2 <- EpAnn AnnList
-> Lens AnnList [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn AnnList)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnAllL EpAnn AnnList
an1 ([AddEpAnn] -> f [AddEpAnn]) -> AnnList -> f AnnList
Lens AnnList [AddEpAnn]
lal_rest AnnKeywordId
AnnSemi
    [LocatedA (Match GhcPs (LocatedA body))]
a' <- [LocatedA (Match GhcPs (LocatedA body))]
-> EP w m [LocatedA (Match GhcPs (LocatedA body))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LocatedA (Match GhcPs (LocatedA body))]
a
    EpAnn AnnList
an3 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn AnnList
an2 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_close
    LocatedL [LocatedA (Match GhcPs (LocatedA body))]
-> EP w m (LocatedL [LocatedA (Match GhcPs (LocatedA body))])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnL
-> [LocatedA (Match GhcPs (LocatedA body))]
-> LocatedL [LocatedA (Match GhcPs (LocatedA body))]
forall l e. l -> e -> GenLocated l e
L (SrcSpanAnnL
la { ann = an3}) [LocatedA (Match GhcPs (LocatedA body))]
a')

instance ExactPrint (LocatedL [LocatedA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))]) where
  getAnnotationEntry :: LocatedL
  [GenLocated
     SrcSpanAnnA
     (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> Entry
getAnnotationEntry = LocatedL
  [GenLocated
     SrcSpanAnnA
     (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: LocatedL
  [GenLocated
     SrcSpanAnnA
     (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> Anchor
-> EpAnnComments
-> LocatedL
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
setAnnotationAnchor = LocatedL
  [GenLocated
     SrcSpanAnnA
     (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> Anchor
-> EpAnnComments
-> LocatedL
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LocatedL
  [GenLocated
     SrcSpanAnnA
     (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     (LocatedL
        [GenLocated
           SrcSpanAnnA
           (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))])
exact (L (SrcSpanAnn EpAnn AnnList
an SrcSpan
l) [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LocatedL [ExprLStmt"
    (EpAnn AnnList
an'', [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts') <- Bool
-> EpAnn AnnList
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     (EpAnn AnnList,
      [GenLocated
         SrcSpanAnnA
         (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList Bool
True EpAnn AnnList
an (EP
   w
   m
   [GenLocated
      SrcSpanAnnA
      (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
 -> EP
      w
      m
      (EpAnn AnnList,
       [GenLocated
          SrcSpanAnnA
          (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]))
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     (EpAnn AnnList,
      [GenLocated
         SrcSpanAnnA
         (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))])
forall a b. (a -> b) -> a -> b
$ do
      case [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> Maybe
     ([GenLocated
         SrcSpanAnnA
         (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))],
      GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))))
forall a. [a] -> Maybe ([a], a)
snocView [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts of
        Just ([GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
initStmts, ls :: GenLocated
  SrcSpanAnnA
  (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
ls@(L SrcSpanAnnA
_ (LastStmt XLastStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
_ GenLocated SrcSpanAnnA (HsExpr GhcPs)
_body Maybe Bool
_ SyntaxExpr GhcPs
_))) -> do
          String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LocatedL [ExprLStmt: snocView"
          GenLocated
  SrcSpanAnnA
  (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
ls' <- GenLocated
  SrcSpanAnnA
  (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated GenLocated
  SrcSpanAnnA
  (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
ls
          [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
initStmts' <- [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
initStmts
          [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
initStmts' [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> [GenLocated
      SrcSpanAnnA
      (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> [GenLocated
      SrcSpanAnnA
      (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall a. [a] -> [a] -> [a]
++ [GenLocated
  SrcSpanAnnA
  (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))
ls'])
        Maybe
  ([GenLocated
      SrcSpanAnnA
      (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))],
   GenLocated
     SrcSpanAnnA
     (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))))
_ -> do
          [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts
    LocatedL
  [GenLocated
     SrcSpanAnnA
     (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> EP
     w
     m
     (LocatedL
        [GenLocated
           SrcSpanAnnA
           (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnL
-> [GenLocated
      SrcSpanAnnA
      (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
-> LocatedL
     [GenLocated
        SrcSpanAnnA
        (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnList -> SrcSpan -> SrcSpanAnnL
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnList
an'' SrcSpan
l) [GenLocated
   SrcSpanAnnA
   (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))]
stmts')

-- instance ExactPrint (LocatedL [CmdLStmt GhcPs]) where
instance ExactPrint (LocatedL [LocatedA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]) where
  getAnnotationEntry :: GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
-> Entry
getAnnotationEntry = GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
-> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
-> Anchor
-> EpAnnComments
-> GenLocated
     SrcSpanAnnL
     [GenLocated
        SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
setAnnotationAnchor = GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
-> Anchor
-> EpAnnComments
-> GenLocated
     SrcSpanAnnL
     [GenLocated
        SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL
        [GenLocated
           SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))])
exact (L (SrcSpanAnn EpAnn AnnList
ann SrcSpan
l) [GenLocated
   SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
es) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LocatedL [CmdLStmt"
    EpAnn AnnList
an0 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn AnnList
ann (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_open
    [GenLocated
   SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
es' <- (GenLocated
   SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))
 -> RWST
      (EPOptions m w)
      (EPWriter w)
      EPState
      m
      (GenLocated
         SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))))
-> [GenLocated
      SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     [GenLocated
        SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM GenLocated
  SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (GenLocated
        SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs))))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GenLocated
   SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
es
    EpAnn AnnList
an1 <- EpAnn AnnList
-> Lens AnnList (Maybe AddEpAnn) -> EP w m (EpAnn AnnList)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a (Maybe AddEpAnn) -> EP w m (EpAnn a)
markLensMAA EpAnn AnnList
an0 (Maybe AddEpAnn -> f (Maybe AddEpAnn)) -> AnnList -> f AnnList
Lens AnnList (Maybe AddEpAnn)
lal_close
    GenLocated
  SrcSpanAnnL
  [GenLocated
     SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL
        [GenLocated
           SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnL
-> [GenLocated
      SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
-> GenLocated
     SrcSpanAnnL
     [GenLocated
        SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnList -> SrcSpan -> SrcSpanAnnL
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnList
an1 SrcSpan
l) [GenLocated
   SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]
es')

instance ExactPrint (LocatedL [LocatedA (ConDeclField GhcPs)]) where
  getAnnotationEntry :: GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> Entry
getAnnotationEntry = GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> Anchor
-> EpAnnComments
-> GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
setAnnotationAnchor = GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> Anchor
-> EpAnnComments
-> GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
exact (L (SrcSpanAnn EpAnn AnnList
an SrcSpan
l) [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fs) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LocatedL [LConDeclField"
    (EpAnn AnnList
an', [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fs') <- Bool
-> EpAnn AnnList
-> EP w m [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> EP
     w m (EpAnn AnnList, [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList Bool
True EpAnn AnnList
an ([GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fs)
    GenLocated
  SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> EP
     w
     m
     (GenLocated
        SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnL
-> [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
-> GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnList -> SrcSpan -> SrcSpanAnnL
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnList
an' SrcSpan
l) [GenLocated SrcSpanAnnA (ConDeclField GhcPs)]
fs')

instance ExactPrint (LocatedL (BF.BooleanFormula (LocatedN RdrName))) where
  getAnnotationEntry :: LBooleanFormula (GenLocated SrcSpanAnnN RdrName) -> Entry
getAnnotationEntry = LBooleanFormula (GenLocated SrcSpanAnnN RdrName) -> Entry
forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA
  setAnnotationAnchor :: LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> Anchor
-> EpAnnComments
-> LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
setAnnotationAnchor = LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> Anchor
-> EpAnnComments
-> LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
forall an a.
Default an =>
LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a
setAnchorAn
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> EP w m (LBooleanFormula (GenLocated SrcSpanAnnN RdrName))
exact (L (SrcSpanAnn EpAnn AnnList
an SrcSpan
l) BooleanFormula (GenLocated SrcSpanAnnN RdrName)
bf) = do
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"LocatedL [LBooleanFormula"
    (EpAnn AnnList
an', BooleanFormula (GenLocated SrcSpanAnnN RdrName)
bf') <- Bool
-> EpAnn AnnList
-> EP w m (BooleanFormula (GenLocated SrcSpanAnnN RdrName))
-> EP
     w
     m
     (EpAnn AnnList, BooleanFormula (GenLocated SrcSpanAnnN RdrName))
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList Bool
True EpAnn AnnList
an (BooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> EP w m (BooleanFormula (GenLocated SrcSpanAnnN RdrName))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated BooleanFormula (GenLocated SrcSpanAnnN RdrName)
bf)
    LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> EP w m (LBooleanFormula (GenLocated SrcSpanAnnN RdrName))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpanAnnL
-> BooleanFormula (GenLocated SrcSpanAnnN RdrName)
-> LBooleanFormula (GenLocated SrcSpanAnnN RdrName)
forall l e. l -> e -> GenLocated l e
L (EpAnn AnnList -> SrcSpan -> SrcSpanAnnL
forall a. a -> SrcSpan -> SrcSpanAnn' a
SrcSpanAnn EpAnn AnnList
an' SrcSpan
l) BooleanFormula (GenLocated SrcSpanAnnN RdrName)
bf')

-- ---------------------------------------------------------------------
-- LocatedL instances end --
-- =====================================================================

instance ExactPrint (IE GhcPs) where
  getAnnotationEntry :: IE GhcPs -> Entry
getAnnotationEntry (IEVar XIEVar GhcPs
_ LIEWrappedName GhcPs
_)            = Entry
NoEntryVal
  getAnnotationEntry (IEThingAbs XIEThingAbs GhcPs
an LIEWrappedName GhcPs
_)      = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XIEThingAbs GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (IEThingAll XIEThingAll GhcPs
an LIEWrappedName GhcPs
_)      = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XIEThingAll GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (IEThingWith XIEThingWith GhcPs
an LIEWrappedName GhcPs
_ IEWildcard
_ [LIEWrappedName GhcPs]
_) = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XIEThingWith GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (IEModuleContents XIEModuleContents GhcPs
an XRec GhcPs ModuleName
_)= EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XIEModuleContents GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (IEGroup XIEGroup GhcPs
_ Int
_ LHsDoc GhcPs
_)        = Entry
NoEntryVal
  getAnnotationEntry (IEDoc XIEDoc GhcPs
_ LHsDoc GhcPs
_)            = Entry
NoEntryVal
  getAnnotationEntry (IEDocNamed XIEDocNamed GhcPs
_ String
_)       = Entry
NoEntryVal

  setAnnotationAnchor :: IE GhcPs -> Anchor -> EpAnnComments -> IE GhcPs
setAnnotationAnchor a :: IE GhcPs
a@(IEVar XIEVar GhcPs
_ LIEWrappedName GhcPs
_)             Anchor
_ EpAnnComments
_s = IE GhcPs
a
  setAnnotationAnchor (IEThingAbs XIEThingAbs GhcPs
an LIEWrappedName GhcPs
a)       Anchor
anc EpAnnComments
cs = (XIEThingAbs GhcPs -> LIEWrappedName GhcPs -> IE GhcPs
forall pass. XIEThingAbs pass -> LIEWrappedName pass -> IE pass
IEThingAbs (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XIEThingAbs GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LIEWrappedName GhcPs
a)
  setAnnotationAnchor (IEThingAll XIEThingAll GhcPs
an LIEWrappedName GhcPs
a)       Anchor
anc EpAnnComments
cs = (XIEThingAll GhcPs -> LIEWrappedName GhcPs -> IE GhcPs
forall pass. XIEThingAll pass -> LIEWrappedName pass -> IE pass
IEThingAll (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XIEThingAll GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LIEWrappedName GhcPs
a)
  setAnnotationAnchor (IEThingWith XIEThingWith GhcPs
an LIEWrappedName GhcPs
a IEWildcard
b [LIEWrappedName GhcPs]
c)  Anchor
anc EpAnnComments
cs = (XIEThingWith GhcPs
-> LIEWrappedName GhcPs
-> IEWildcard
-> [LIEWrappedName GhcPs]
-> IE GhcPs
forall pass.
XIEThingWith pass
-> LIEWrappedName pass
-> IEWildcard
-> [LIEWrappedName pass]
-> IE pass
IEThingWith (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XIEThingWith GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LIEWrappedName GhcPs
a IEWildcard
b [LIEWrappedName GhcPs]
c)
  setAnnotationAnchor (IEModuleContents XIEModuleContents GhcPs
an XRec GhcPs ModuleName
a) Anchor
anc EpAnnComments
cs = (XIEModuleContents GhcPs -> XRec GhcPs ModuleName -> IE GhcPs
forall pass.
XIEModuleContents pass -> XRec pass ModuleName -> IE pass
IEModuleContents (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XIEModuleContents GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs ModuleName
a)
  setAnnotationAnchor a :: IE GhcPs
a@(IEGroup XIEGroup GhcPs
_ Int
_ LHsDoc GhcPs
_)         Anchor
_ EpAnnComments
_s = IE GhcPs
a
  setAnnotationAnchor a :: IE GhcPs
a@(IEDoc XIEDoc GhcPs
_ LHsDoc GhcPs
_)             Anchor
_ EpAnnComments
_s = IE GhcPs
a
  setAnnotationAnchor a :: IE GhcPs
a@(IEDocNamed XIEDocNamed GhcPs
_ String
_)        Anchor
_ EpAnnComments
_s = IE GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
IE GhcPs -> EP w m (IE GhcPs)
exact (IEVar XIEVar GhcPs
x LIEWrappedName GhcPs
ln) = do
    GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
ln' <- GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (IEWrappedName GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
ln
    IE GhcPs -> EP w m (IE GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEVar GhcPs -> LIEWrappedName GhcPs -> IE GhcPs
forall pass. XIEVar pass -> LIEWrappedName pass -> IE pass
IEVar XIEVar GhcPs
x LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
ln')
  exact (IEThingAbs XIEThingAbs GhcPs
x LIEWrappedName GhcPs
thing) = do
    GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
thing' <- GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (IEWrappedName GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
thing
    IE GhcPs -> EP w m (IE GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEThingAbs GhcPs -> LIEWrappedName GhcPs -> IE GhcPs
forall pass. XIEThingAbs pass -> LIEWrappedName pass -> IE pass
IEThingAbs XIEThingAbs GhcPs
x LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
thing')
  exact (IEThingAll XIEThingAll GhcPs
an LIEWrappedName GhcPs
thing) = do
    GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
thing' <- GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (IEWrappedName GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
thing
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XIEThingAll GhcPs
EpAnn [AddEpAnn]
an  ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenP
    EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDotdot
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseP
    IE GhcPs -> EP w m (IE GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEThingAll GhcPs -> LIEWrappedName GhcPs -> IE GhcPs
forall pass. XIEThingAll pass -> LIEWrappedName pass -> IE pass
IEThingAll XIEThingAll GhcPs
EpAnn [AddEpAnn]
an2 LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
thing')

  exact (IEThingWith XIEThingWith GhcPs
an LIEWrappedName GhcPs
thing IEWildcard
wc [LIEWrappedName GhcPs]
withs) = do
    GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
thing' <- GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (IEWrappedName GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
thing
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XIEThingWith GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenP
    (EpAnn [AddEpAnn]
an1, IEWildcard
wc', [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
withs') <-
      case IEWildcard
wc of
        IEWildcard
NoIEWildcard -> do
          [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
withs'' <- [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LIEWrappedName GhcPs]
[GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
withs
          (EpAnn [AddEpAnn], IEWildcard,
 [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], IEWildcard,
      [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an0, IEWildcard
wc, [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
withs'')
        IEWildcard Int
pos -> do
          let ([GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
bs, [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
as) = Int
-> [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
-> ([GenLocated SrcSpanAnnA (IEWrappedName GhcPs)],
    [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)])
forall a. Int -> [a] -> ([a], [a])
splitAt Int
pos [LIEWrappedName GhcPs]
[GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
withs
          [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
bs' <- [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
bs
          EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDotdot
          EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnComma
          [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
as' <- [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
as
          (EpAnn [AddEpAnn], IEWildcard,
 [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)])
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], IEWildcard,
      [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an2, IEWildcard
wc, [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
bs'[GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
-> [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
-> [GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
forall a. [a] -> [a] -> [a]
++[GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
as')
    EpAnn [AddEpAnn]
an2 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an1 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseP
    IE GhcPs -> EP w m (IE GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEThingWith GhcPs
-> LIEWrappedName GhcPs
-> IEWildcard
-> [LIEWrappedName GhcPs]
-> IE GhcPs
forall pass.
XIEThingWith pass
-> LIEWrappedName pass
-> IEWildcard
-> [LIEWrappedName pass]
-> IE pass
IEThingWith XIEThingWith GhcPs
EpAnn [AddEpAnn]
an2 LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
thing' IEWildcard
wc' [LIEWrappedName GhcPs]
[GenLocated SrcSpanAnnA (IEWrappedName GhcPs)]
withs')

  exact (IEModuleContents XIEModuleContents GhcPs
an XRec GhcPs ModuleName
m) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XIEModuleContents GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnModule
    GenLocated SrcSpanAnnA ModuleName
m' <- GenLocated SrcSpanAnnA ModuleName
-> EP w m (GenLocated SrcSpanAnnA ModuleName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs ModuleName
GenLocated SrcSpanAnnA ModuleName
m
    IE GhcPs -> EP w m (IE GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEModuleContents GhcPs -> XRec GhcPs ModuleName -> IE GhcPs
forall pass.
XIEModuleContents pass -> XRec pass ModuleName -> IE pass
IEModuleContents XIEModuleContents GhcPs
EpAnn [AddEpAnn]
an0 XRec GhcPs ModuleName
GenLocated SrcSpanAnnA ModuleName
m')

  -- These three exist to not error out, but are no-ops The contents
  -- appear as "normal" comments too, which we process instead.
  exact (IEGroup XIEGroup GhcPs
x Int
lev LHsDoc GhcPs
doc) = do
    IE GhcPs -> EP w m (IE GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEGroup GhcPs -> Int -> LHsDoc GhcPs -> IE GhcPs
forall pass. XIEGroup pass -> Int -> LHsDoc pass -> IE pass
IEGroup XIEGroup GhcPs
x Int
lev LHsDoc GhcPs
doc)
  exact (IEDoc XIEDoc GhcPs
x LHsDoc GhcPs
doc) = do
    IE GhcPs -> EP w m (IE GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEDoc GhcPs -> LHsDoc GhcPs -> IE GhcPs
forall pass. XIEDoc pass -> LHsDoc pass -> IE pass
IEDoc XIEDoc GhcPs
x LHsDoc GhcPs
doc)
  exact (IEDocNamed XIEDocNamed GhcPs
x String
str) = do
    IE GhcPs -> EP w m (IE GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEDocNamed GhcPs -> String -> IE GhcPs
forall pass. XIEDocNamed pass -> String -> IE pass
IEDocNamed XIEDocNamed GhcPs
x String
str)

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

instance ExactPrint (IEWrappedName GhcPs) where
  getAnnotationEntry :: IEWrappedName GhcPs -> Entry
getAnnotationEntry = Entry -> IEWrappedName GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: IEWrappedName GhcPs
-> Anchor -> EpAnnComments -> IEWrappedName GhcPs
setAnnotationAnchor IEWrappedName GhcPs
a Anchor
_ EpAnnComments
_ = IEWrappedName GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
IEWrappedName GhcPs -> EP w m (IEWrappedName GhcPs)
exact (IEName XIEName GhcPs
x LIdP GhcPs
n) = do
    GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
    IEWrappedName GhcPs -> EP w m (IEWrappedName GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEName GhcPs -> LIdP GhcPs -> IEWrappedName GhcPs
forall p. XIEName p -> LIdP p -> IEWrappedName p
IEName XIEName GhcPs
x LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n')
  exact (IEPattern XIEPattern GhcPs
r LIdP GhcPs
n) = do
    EpaLocation
r' <- EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA XIEPattern GhcPs
EpaLocation
r String
"pattern"
    GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
    IEWrappedName GhcPs -> EP w m (IEWrappedName GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEPattern GhcPs -> LIdP GhcPs -> IEWrappedName GhcPs
forall p. XIEPattern p -> LIdP p -> IEWrappedName p
IEPattern XIEPattern GhcPs
EpaLocation
r' LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n')
  exact (IEType XIEType GhcPs
r LIdP GhcPs
n) = do
    EpaLocation
r' <- EpaLocation -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EpaLocation -> String -> EP w m EpaLocation
printStringAtAA XIEType GhcPs
EpaLocation
r String
"type"
    GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
    IEWrappedName GhcPs -> EP w m (IEWrappedName GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XIEType GhcPs -> LIdP GhcPs -> IEWrappedName GhcPs
forall p. XIEType p -> LIdP p -> IEWrappedName p
IEType XIEType GhcPs
EpaLocation
r' LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n')

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

instance ExactPrint (Pat GhcPs) where
  getAnnotationEntry :: Pat GhcPs -> Entry
getAnnotationEntry (WildPat XWildPat GhcPs
_)              = Entry
NoEntryVal
  getAnnotationEntry (VarPat XVarPat GhcPs
_ LIdP GhcPs
_)             = Entry
NoEntryVal
  getAnnotationEntry (LazyPat XLazyPat GhcPs
an LPat GhcPs
_)           = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XLazyPat GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (AsPat XAsPat GhcPs
an LIdP GhcPs
_ LHsToken "@" GhcPs
_ LPat GhcPs
_)         = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XAsPat GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (ParPat XParPat GhcPs
an LHsToken "(" GhcPs
_ LPat GhcPs
_ LHsToken ")" GhcPs
_)        = EpAnn NoEpAnns -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XParPat GhcPs
EpAnn NoEpAnns
an
  getAnnotationEntry (BangPat XBangPat GhcPs
an LPat GhcPs
_)           = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XBangPat GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (ListPat XListPat GhcPs
an [LPat GhcPs]
_)           = EpAnn AnnList -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XListPat GhcPs
EpAnn AnnList
an
  getAnnotationEntry (TuplePat XTuplePat GhcPs
an [LPat GhcPs]
_ Boxity
_)        = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XTuplePat GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (SumPat XSumPat GhcPs
an LPat GhcPs
_ Int
_ Int
_)        = EpAnn EpAnnSumPat -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XSumPat GhcPs
EpAnn EpAnnSumPat
an
  getAnnotationEntry (ConPat XConPat GhcPs
an XRec GhcPs (ConLikeP GhcPs)
_ HsConPatDetails GhcPs
_)          = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XConPat GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (ViewPat XViewPat GhcPs
an XRec GhcPs (HsExpr GhcPs)
_ LPat GhcPs
_)         = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XViewPat GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (SplicePat XSplicePat GhcPs
_ HsUntypedSplice GhcPs
_)          = Entry
NoEntryVal
  getAnnotationEntry (LitPat XLitPat GhcPs
_ HsLit GhcPs
_)             = Entry
NoEntryVal
  getAnnotationEntry (NPat XNPat GhcPs
an XRec GhcPs (HsOverLit GhcPs)
_ Maybe (SyntaxExpr GhcPs)
_ SyntaxExpr GhcPs
_)          = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XNPat GhcPs
EpAnn [AddEpAnn]
an
  getAnnotationEntry (NPlusKPat XNPlusKPat GhcPs
an LIdP GhcPs
_ XRec GhcPs (HsOverLit GhcPs)
_ HsOverLit GhcPs
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_) = EpAnn EpaLocation -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XNPlusKPat GhcPs
EpAnn EpaLocation
an
  getAnnotationEntry (SigPat XSigPat GhcPs
an LPat GhcPs
_ HsPatSigType (NoGhcTc GhcPs)
_)          = EpAnn [AddEpAnn] -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn XSigPat GhcPs
EpAnn [AddEpAnn]
an

  setAnnotationAnchor :: Pat GhcPs -> Anchor -> EpAnnComments -> Pat GhcPs
setAnnotationAnchor a :: Pat GhcPs
a@(WildPat XWildPat GhcPs
_)              Anchor
_ EpAnnComments
_s = Pat GhcPs
a
  setAnnotationAnchor a :: Pat GhcPs
a@(VarPat XVarPat GhcPs
_ LIdP GhcPs
_)             Anchor
_ EpAnnComments
_s = Pat GhcPs
a
  setAnnotationAnchor (LazyPat XLazyPat GhcPs
an LPat GhcPs
a)            Anchor
anc EpAnnComments
cs = (XLazyPat GhcPs -> LPat GhcPs -> Pat GhcPs
forall p. XLazyPat p -> LPat p -> Pat p
LazyPat (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XLazyPat GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LPat GhcPs
a)
  setAnnotationAnchor (AsPat XAsPat GhcPs
an LIdP GhcPs
a LHsToken "@" GhcPs
at LPat GhcPs
b)         Anchor
anc EpAnnComments
cs = (XAsPat GhcPs
-> LIdP GhcPs -> LHsToken "@" GhcPs -> LPat GhcPs -> Pat GhcPs
forall p. XAsPat p -> LIdP p -> LHsToken "@" p -> LPat p -> Pat p
AsPat (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XAsPat GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) LIdP GhcPs
a LHsToken "@" GhcPs
at LPat GhcPs
b)
  setAnnotationAnchor (ParPat XParPat GhcPs
an LHsToken "(" GhcPs
a LPat GhcPs
b LHsToken ")" GhcPs
c)         Anchor
anc EpAnnComments
cs = (XParPat GhcPs
-> LHsToken "(" GhcPs
-> LPat GhcPs
-> LHsToken ")" GhcPs
-> Pat GhcPs
forall p.
XParPat p -> LHsToken "(" p -> LPat p -> LHsToken ")" p -> Pat p
ParPat (EpAnn NoEpAnns -> Anchor -> EpAnnComments -> EpAnn NoEpAnns
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XParPat GhcPs
EpAnn NoEpAnns
an Anchor
anc EpAnnComments
cs) LHsToken "(" GhcPs
a LPat GhcPs
b LHsToken ")" GhcPs
c)
  setAnnotationAnchor (BangPat XBangPat GhcPs
an LPat GhcPs
a)            Anchor
anc EpAnnComments
cs = (XBangPat GhcPs -> LPat GhcPs -> Pat GhcPs
forall p. XBangPat p -> LPat p -> Pat p
BangPat (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XBangPat GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LPat GhcPs
a)
  setAnnotationAnchor (ListPat XListPat GhcPs
an [LPat GhcPs]
a)            Anchor
anc EpAnnComments
cs = (XListPat GhcPs -> [LPat GhcPs] -> Pat GhcPs
forall p. XListPat p -> [LPat p] -> Pat p
ListPat (EpAnn AnnList -> Anchor -> EpAnnComments -> EpAnn AnnList
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XListPat GhcPs
EpAnn AnnList
an Anchor
anc EpAnnComments
cs) [LPat GhcPs]
a)
  setAnnotationAnchor (TuplePat XTuplePat GhcPs
an [LPat GhcPs]
a Boxity
b)         Anchor
anc EpAnnComments
cs = (XTuplePat GhcPs -> [LPat GhcPs] -> Boxity -> Pat GhcPs
forall p. XTuplePat p -> [LPat p] -> Boxity -> Pat p
TuplePat (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XTuplePat GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) [LPat GhcPs]
a Boxity
b)
  setAnnotationAnchor (SumPat XSumPat GhcPs
an LPat GhcPs
a Int
b Int
c)         Anchor
anc EpAnnComments
cs = (XSumPat GhcPs -> LPat GhcPs -> Int -> Int -> Pat GhcPs
forall p. XSumPat p -> LPat p -> Int -> Int -> Pat p
SumPat (EpAnn EpAnnSumPat -> Anchor -> EpAnnComments -> EpAnn EpAnnSumPat
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XSumPat GhcPs
EpAnn EpAnnSumPat
an Anchor
anc EpAnnComments
cs) LPat GhcPs
a Int
b Int
c)
  setAnnotationAnchor (ConPat XConPat GhcPs
an XRec GhcPs (ConLikeP GhcPs)
a HsConPatDetails GhcPs
b)           Anchor
anc EpAnnComments
cs = (XConPat GhcPs
-> XRec GhcPs (ConLikeP GhcPs)
-> HsConPatDetails GhcPs
-> Pat GhcPs
forall p.
XConPat p -> XRec p (ConLikeP p) -> HsConPatDetails p -> Pat p
ConPat (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XConPat GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (ConLikeP GhcPs)
a HsConPatDetails GhcPs
b)
  setAnnotationAnchor (ViewPat XViewPat GhcPs
an XRec GhcPs (HsExpr GhcPs)
a LPat GhcPs
b)          Anchor
anc EpAnnComments
cs = (XViewPat GhcPs
-> XRec GhcPs (HsExpr GhcPs) -> LPat GhcPs -> Pat GhcPs
forall p. XViewPat p -> LHsExpr p -> LPat p -> Pat p
ViewPat (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XViewPat GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsExpr GhcPs)
a LPat GhcPs
b)
  setAnnotationAnchor a :: Pat GhcPs
a@(SplicePat XSplicePat GhcPs
_ HsUntypedSplice GhcPs
_)           Anchor
_ EpAnnComments
_s = Pat GhcPs
a
  setAnnotationAnchor a :: Pat GhcPs
a@(LitPat XLitPat GhcPs
_ HsLit GhcPs
_)              Anchor
_ EpAnnComments
_s = Pat GhcPs
a
  setAnnotationAnchor (NPat XNPat GhcPs
an XRec GhcPs (HsOverLit GhcPs)
a Maybe (SyntaxExpr GhcPs)
b SyntaxExpr GhcPs
c)          Anchor
anc EpAnnComments
cs = (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 (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XNPat GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) XRec GhcPs (HsOverLit GhcPs)
a Maybe (SyntaxExpr GhcPs)
b SyntaxExpr GhcPs
c)
  setAnnotationAnchor (NPlusKPat XNPlusKPat GhcPs
an LIdP GhcPs
a XRec GhcPs (HsOverLit GhcPs)
b HsOverLit GhcPs
c SyntaxExpr GhcPs
d SyntaxExpr GhcPs
e) Anchor
anc EpAnnComments
cs = (XNPlusKPat GhcPs
-> LIdP GhcPs
-> XRec GhcPs (HsOverLit GhcPs)
-> HsOverLit GhcPs
-> SyntaxExpr GhcPs
-> SyntaxExpr GhcPs
-> Pat GhcPs
forall p.
XNPlusKPat p
-> LIdP p
-> XRec p (HsOverLit p)
-> HsOverLit p
-> SyntaxExpr p
-> SyntaxExpr p
-> Pat p
NPlusKPat (EpAnn EpaLocation -> Anchor -> EpAnnComments -> EpAnn EpaLocation
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XNPlusKPat GhcPs
EpAnn EpaLocation
an Anchor
anc EpAnnComments
cs) LIdP GhcPs
a XRec GhcPs (HsOverLit GhcPs)
b HsOverLit GhcPs
c SyntaxExpr GhcPs
d SyntaxExpr GhcPs
e)
  setAnnotationAnchor (SigPat XSigPat GhcPs
an LPat GhcPs
a HsPatSigType (NoGhcTc GhcPs)
b)          Anchor
anc EpAnnComments
cs = (XSigPat GhcPs
-> LPat GhcPs -> HsPatSigType (NoGhcTc GhcPs) -> Pat GhcPs
forall p. XSigPat p -> LPat p -> HsPatSigType (NoGhcTc p) -> Pat p
SigPat (EpAnn [AddEpAnn] -> Anchor -> EpAnnComments -> EpAnn [AddEpAnn]
forall an.
Default an =>
EpAnn an -> Anchor -> EpAnnComments -> EpAnn an
setAnchorEpa XSigPat GhcPs
EpAnn [AddEpAnn]
an Anchor
anc EpAnnComments
cs) LPat GhcPs
a HsPatSigType (NoGhcTc GhcPs)
b)

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Pat GhcPs -> EP w m (Pat GhcPs)
exact (WildPat XWildPat GhcPs
w) = do
    RealSrcSpan
anchor <- EP w m RealSrcSpan
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m RealSrcSpan
getAnchorU
    String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"WildPat:anchor=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ RealSrcSpan -> String
forall a. Show a => a -> String
show RealSrcSpan
anchor
    EpaLocation
_ <- RealSrcSpan -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRs RealSrcSpan
anchor String
"_"
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XWildPat GhcPs -> Pat GhcPs
forall p. XWildPat p -> Pat p
WildPat XWildPat GhcPs
w)
  exact (VarPat XVarPat GhcPs
x LIdP GhcPs
n) = do
    -- The parser inserts a placeholder value for a record pun rhs. This must be
    -- filtered.
    let pun_RDR :: String
pun_RDR = String
"pun-right-hand-side"
    GenLocated SrcSpanAnnN RdrName
n' <- if (GenLocated SrcSpanAnnN RdrName -> String
forall a. Outputable a => a -> String
showPprUnsafe LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= String
pun_RDR)
      then GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
      else GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XVarPat GhcPs -> LIdP GhcPs -> Pat GhcPs
forall p. XVarPat p -> LIdP p -> Pat p
VarPat XVarPat GhcPs
x LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n')
  exact (LazyPat XLazyPat GhcPs
an LPat GhcPs
pat) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XLazyPat GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnTilde
    GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XLazyPat GhcPs -> LPat GhcPs -> Pat GhcPs
forall p. XLazyPat p -> LPat p -> Pat p
LazyPat XLazyPat GhcPs
EpAnn [AddEpAnn]
an0 LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat')
  exact (AsPat XAsPat GhcPs
an LIdP GhcPs
n LHsToken "@" GhcPs
at LPat GhcPs
pat) = do
    GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
    GenLocated TokenLocation (HsToken "@")
at' <- LHsToken "@" GhcPs -> EP w m (LHsToken "@" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "@" GhcPs
at
    GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XAsPat GhcPs
-> LIdP GhcPs -> LHsToken "@" GhcPs -> LPat GhcPs -> Pat GhcPs
forall p. XAsPat p -> LIdP p -> LHsToken "@" p -> LPat p -> Pat p
AsPat XAsPat GhcPs
an LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n' LHsToken "@" GhcPs
GenLocated TokenLocation (HsToken "@")
at' LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat')
  exact (ParPat XParPat GhcPs
an LHsToken "(" GhcPs
lpar LPat GhcPs
pat LHsToken ")" GhcPs
rpar) = do
    GenLocated TokenLocation (HsToken "(")
lpar' <- LHsToken "(" GhcPs -> EP w m (LHsToken "(" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "(" GhcPs
lpar
    GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
    GenLocated TokenLocation (HsToken ")")
rpar' <- LHsToken ")" GhcPs -> EP w m (LHsToken ")" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken ")" GhcPs
rpar
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XParPat GhcPs
-> LHsToken "(" GhcPs
-> LPat GhcPs
-> LHsToken ")" GhcPs
-> Pat GhcPs
forall p.
XParPat p -> LHsToken "(" p -> LPat p -> LHsToken ")" p -> Pat p
ParPat XParPat GhcPs
an LHsToken "(" GhcPs
GenLocated TokenLocation (HsToken "(")
lpar' LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat' LHsToken ")" GhcPs
GenLocated TokenLocation (HsToken ")")
rpar')

  exact (BangPat XBangPat GhcPs
an LPat GhcPs
pat) = do
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XBangPat GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnBang
    GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XBangPat GhcPs -> LPat GhcPs -> Pat GhcPs
forall p. XBangPat p -> LPat p -> Pat p
BangPat XBangPat GhcPs
EpAnn [AddEpAnn]
an0 LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat')

  exact (ListPat XListPat GhcPs
an [LPat GhcPs]
pats) = do
    (EpAnn AnnList
an', [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats') <- Bool
-> EpAnn AnnList
-> EP w m [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> EP w m (EpAnn AnnList, [GenLocated SrcSpanAnnA (Pat GhcPs)])
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
Bool -> EpAnn AnnList -> EP w m a -> EP w m (EpAnn AnnList, a)
markAnnList Bool
True XListPat GhcPs
EpAnn AnnList
an ([GenLocated SrcSpanAnnA (Pat GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (Pat GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats)
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XListPat GhcPs -> [LPat GhcPs] -> Pat GhcPs
forall p. XListPat p -> [LPat p] -> Pat p
ListPat XListPat GhcPs
EpAnn AnnList
an' [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats')

  exact (TuplePat XTuplePat GhcPs
an [LPat GhcPs]
pats Boxity
boxity) = do
    EpAnn [AddEpAnn]
an0 <- case Boxity
boxity of
             Boxity
Boxed   -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XTuplePat GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenP
             Boxity
Unboxed -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XTuplePat GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenPH
    [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats' <- [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (Pat GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats
    EpAnn [AddEpAnn]
an1 <- case Boxity
boxity of
             Boxity
Boxed   -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseP
             Boxity
Unboxed -> EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnClosePH
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XTuplePat GhcPs -> [LPat GhcPs] -> Boxity -> Pat GhcPs
forall p. XTuplePat p -> [LPat p] -> Boxity -> Pat p
TuplePat XTuplePat GhcPs
EpAnn [AddEpAnn]
an1 [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats' Boxity
boxity)

  exact (SumPat XSumPat GhcPs
an LPat GhcPs
pat Int
alt Int
arity) = do
    EpAnn EpAnnSumPat
an0 <- EpAnn EpAnnSumPat
-> Lens EpAnnSumPat [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn EpAnnSumPat)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XSumPat GhcPs
EpAnn EpAnnSumPat
an ([AddEpAnn] -> f [AddEpAnn]) -> EpAnnSumPat -> f EpAnnSumPat
Lens EpAnnSumPat [AddEpAnn]
lsumPatParens AnnKeywordId
AnnOpenPH
    EpAnn EpAnnSumPat
an1 <- EpAnn EpAnnSumPat
-> Lens EpAnnSumPat [EpaLocation]
-> AnnKeywordId
-> EP w m (EpAnn EpAnnSumPat)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [EpaLocation] -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwAllL EpAnn EpAnnSumPat
an0 ([EpaLocation] -> f [EpaLocation]) -> EpAnnSumPat -> f EpAnnSumPat
Lens EpAnnSumPat [EpaLocation]
lsumPatVbarsBefore AnnKeywordId
AnnVbar
    GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
    EpAnn EpAnnSumPat
an2 <- EpAnn EpAnnSumPat
-> Lens EpAnnSumPat [EpaLocation]
-> AnnKeywordId
-> EP w m (EpAnn EpAnnSumPat)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a [EpaLocation] -> AnnKeywordId -> EP w m (EpAnn a)
markAnnKwAllL EpAnn EpAnnSumPat
an1 ([EpaLocation] -> f [EpaLocation]) -> EpAnnSumPat -> f EpAnnSumPat
Lens EpAnnSumPat [EpaLocation]
lsumPatVbarsAfter AnnKeywordId
AnnVbar
    EpAnn EpAnnSumPat
an3 <- EpAnn EpAnnSumPat
-> Lens EpAnnSumPat [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn EpAnnSumPat)
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn EpAnnSumPat
an2 ([AddEpAnn] -> f [AddEpAnn]) -> EpAnnSumPat -> f EpAnnSumPat
Lens EpAnnSumPat [AddEpAnn]
lsumPatParens AnnKeywordId
AnnClosePH
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSumPat GhcPs -> LPat GhcPs -> Int -> Int -> Pat GhcPs
forall p. XSumPat p -> LPat p -> Int -> Int -> Pat p
SumPat XSumPat GhcPs
EpAnn EpAnnSumPat
an3 LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat' Int
alt Int
arity)

  -- | ConPat an con args)
  exact (ConPat XConPat GhcPs
an XRec GhcPs (ConLikeP GhcPs)
con HsConPatDetails GhcPs
details) = do
    (EpAnn [AddEpAnn]
an', GenLocated SrcSpanAnnN RdrName
con', HsConDetails
  (HsConPatTyArg GhcPs)
  (GenLocated SrcSpanAnnA (Pat GhcPs))
  (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
details') <- EpAnn [AddEpAnn]
-> GenLocated SrcSpanAnnN RdrName
-> HsConPatDetails GhcPs
-> EP
     w
     m
     (EpAnn [AddEpAnn], GenLocated SrcSpanAnnN RdrName,
      HsConPatDetails GhcPs)
forall (m :: * -> *) w con.
(Monad m, Monoid w, ExactPrint con) =>
EpAnn [AddEpAnn]
-> con
-> HsConPatDetails GhcPs
-> EP w m (EpAnn [AddEpAnn], con, HsConPatDetails GhcPs)
exactUserCon XConPat GhcPs
EpAnn [AddEpAnn]
an XRec GhcPs (ConLikeP GhcPs)
GenLocated SrcSpanAnnN RdrName
con HsConPatDetails GhcPs
details
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XConPat GhcPs
-> XRec GhcPs (ConLikeP GhcPs)
-> HsConPatDetails GhcPs
-> Pat GhcPs
forall p.
XConPat p -> XRec p (ConLikeP p) -> HsConPatDetails p -> Pat p
ConPat XConPat GhcPs
EpAnn [AddEpAnn]
an' XRec GhcPs (ConLikeP GhcPs)
GenLocated SrcSpanAnnN RdrName
con' HsConPatDetails GhcPs
HsConDetails
  (HsConPatTyArg GhcPs)
  (GenLocated SrcSpanAnnA (Pat GhcPs))
  (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
details')
  exact (ViewPat XViewPat GhcPs
an XRec GhcPs (HsExpr GhcPs)
expr LPat GhcPs
pat) = do
    GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' <- GenLocated SrcSpanAnnA (HsExpr GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsExpr GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XViewPat GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnRarrow
    GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XViewPat GhcPs
-> XRec GhcPs (HsExpr GhcPs) -> LPat GhcPs -> Pat GhcPs
forall p. XViewPat p -> LHsExpr p -> LPat p -> Pat p
ViewPat XViewPat GhcPs
EpAnn [AddEpAnn]
an0 XRec GhcPs (HsExpr GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
expr' LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat')
  exact (SplicePat XSplicePat GhcPs
x HsUntypedSplice GhcPs
splice) = do
    HsUntypedSplice GhcPs
splice' <- HsUntypedSplice GhcPs -> EP w m (HsUntypedSplice GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsUntypedSplice GhcPs
splice
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSplicePat GhcPs -> HsUntypedSplice GhcPs -> Pat GhcPs
forall p. XSplicePat p -> HsUntypedSplice p -> Pat p
SplicePat XSplicePat GhcPs
x HsUntypedSplice GhcPs
splice')
  exact p :: Pat GhcPs
p@(LitPat XLitPat GhcPs
_ HsLit GhcPs
lit) = String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance (HsLit GhcPs -> String
hsLit2String HsLit GhcPs
lit) RWST (EPOptions m w) (EPWriter w) EPState m ()
-> EP w m (Pat GhcPs) -> EP w m (Pat GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Pat GhcPs
p
  exact (NPat XNPat GhcPs
an XRec GhcPs (HsOverLit GhcPs)
ol Maybe (SyntaxExpr GhcPs)
mn SyntaxExpr GhcPs
z) = do
    EpAnn [AddEpAnn]
an0 <- if (Maybe NoExtField -> Bool
forall a. Maybe a -> Bool
isJust Maybe NoExtField
Maybe (SyntaxExpr GhcPs)
mn)
      then EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XNPat GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnMinus
      else EpAnn [AddEpAnn] -> EP w m (EpAnn [AddEpAnn])
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return XNPat GhcPs
EpAnn [AddEpAnn]
an
    GenLocated (SrcAnn NoEpAnns) (HsOverLit GhcPs)
ol' <- GenLocated (SrcAnn NoEpAnns) (HsOverLit GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (HsOverLit GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsOverLit GhcPs)
GenLocated (SrcAnn NoEpAnns) (HsOverLit GhcPs)
ol
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (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 XNPat GhcPs
EpAnn [AddEpAnn]
an0 XRec GhcPs (HsOverLit GhcPs)
GenLocated (SrcAnn NoEpAnns) (HsOverLit GhcPs)
ol' Maybe (SyntaxExpr GhcPs)
mn SyntaxExpr GhcPs
z)

  -- | NPlusKPat an n lit1 lit2 _ _)
  exact (NPlusKPat XNPlusKPat GhcPs
an LIdP GhcPs
n XRec GhcPs (HsOverLit GhcPs)
k HsOverLit GhcPs
lit2 SyntaxExpr GhcPs
a SyntaxExpr GhcPs
b) = do
    GenLocated SrcSpanAnnN RdrName
n' <- GenLocated SrcSpanAnnN RdrName
-> EP w m (GenLocated SrcSpanAnnN RdrName)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n
    EpAnn EpaLocation
an' <- EpAnn EpaLocation
-> Lens EpaLocation EpaLocation
-> String
-> EP w m (EpAnn EpaLocation)
forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EpAnn a -> Lens a EpaLocation -> String -> EP w m (EpAnn a)
printStringAtAAL XNPlusKPat GhcPs
EpAnn EpaLocation
an (EpaLocation -> f EpaLocation) -> EpaLocation -> f EpaLocation
forall a (f :: * -> *). Functor f => (a -> f a) -> a -> f a
Lens EpaLocation EpaLocation
lid String
"+"
    GenLocated (SrcAnn NoEpAnns) (HsOverLit GhcPs)
k' <- GenLocated (SrcAnn NoEpAnns) (HsOverLit GhcPs)
-> EP w m (GenLocated (SrcAnn NoEpAnns) (HsOverLit GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated XRec GhcPs (HsOverLit GhcPs)
GenLocated (SrcAnn NoEpAnns) (HsOverLit GhcPs)
k
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XNPlusKPat GhcPs
-> LIdP GhcPs
-> XRec GhcPs (HsOverLit GhcPs)
-> HsOverLit GhcPs
-> SyntaxExpr GhcPs
-> SyntaxExpr GhcPs
-> Pat GhcPs
forall p.
XNPlusKPat p
-> LIdP p
-> XRec p (HsOverLit p)
-> HsOverLit p
-> SyntaxExpr p
-> SyntaxExpr p
-> Pat p
NPlusKPat XNPlusKPat GhcPs
EpAnn EpaLocation
an' LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
n' XRec GhcPs (HsOverLit GhcPs)
GenLocated (SrcAnn NoEpAnns) (HsOverLit GhcPs)
k' HsOverLit GhcPs
lit2 SyntaxExpr GhcPs
a SyntaxExpr GhcPs
b)

  exact (SigPat XSigPat GhcPs
an LPat GhcPs
pat HsPatSigType (NoGhcTc GhcPs)
sig) = do
    GenLocated SrcSpanAnnA (Pat GhcPs)
pat' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat
    EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL XSigPat GhcPs
EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnDcolon
    HsPatSigType GhcPs
sig' <- HsPatSigType GhcPs -> EP w m (HsPatSigType GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsPatSigType (NoGhcTc GhcPs)
HsPatSigType GhcPs
sig
    Pat GhcPs -> EP w m (Pat GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XSigPat GhcPs
-> LPat GhcPs -> HsPatSigType (NoGhcTc GhcPs) -> Pat GhcPs
forall p. XSigPat p -> LPat p -> HsPatSigType (NoGhcTc p) -> Pat p
SigPat XSigPat GhcPs
EpAnn [AddEpAnn]
an0 LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
pat' HsPatSigType (NoGhcTc GhcPs)
HsPatSigType GhcPs
sig')

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

instance ExactPrint (HsPatSigType GhcPs) where
  getAnnotationEntry :: HsPatSigType GhcPs -> Entry
getAnnotationEntry = Entry -> HsPatSigType GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: HsPatSigType GhcPs -> Anchor -> EpAnnComments -> HsPatSigType GhcPs
setAnnotationAnchor HsPatSigType GhcPs
a Anchor
_ EpAnnComments
_ = HsPatSigType GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsPatSigType GhcPs -> EP w m (HsPatSigType GhcPs)
exact (HsPS XHsPS GhcPs
an LHsType GhcPs
ty) = do
    GenLocated SrcSpanAnnA (HsType GhcPs)
ty' <- GenLocated SrcSpanAnnA (HsType GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (HsType GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty
    HsPatSigType GhcPs -> EP w m (HsPatSigType GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (XHsPS GhcPs -> LHsType GhcPs -> HsPatSigType GhcPs
forall pass. XHsPS pass -> LHsType pass -> HsPatSigType pass
HsPS XHsPS GhcPs
an LHsType GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
ty')

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

instance ExactPrint (HsOverLit GhcPs) where
  getAnnotationEntry :: HsOverLit GhcPs -> Entry
getAnnotationEntry = Entry -> HsOverLit GhcPs -> Entry
forall a b. a -> b -> a
const Entry
NoEntryVal
  setAnnotationAnchor :: HsOverLit GhcPs -> Anchor -> EpAnnComments -> HsOverLit GhcPs
setAnnotationAnchor HsOverLit GhcPs
a Anchor
_ EpAnnComments
_ = HsOverLit GhcPs
a

  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsOverLit GhcPs -> EP w m (HsOverLit GhcPs)
exact HsOverLit GhcPs
ol =
    let str :: SourceText
str = case HsOverLit GhcPs -> OverLitVal
forall p. HsOverLit p -> OverLitVal
ol_val HsOverLit GhcPs
ol of
                HsIntegral   (IL SourceText
src Bool
_ Integer
_) -> SourceText
src
                HsFractional (FL{ fl_text :: FractionalLit -> SourceText
fl_text = SourceText
src }) -> SourceText
src
                HsIsString SourceText
src FastString
_ -> SourceText
src
    in
      case SourceText
str of
        SourceText String
s -> String -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance String
s EP w m () -> EP w m (HsOverLit GhcPs) -> EP w m (HsOverLit GhcPs)
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HsOverLit GhcPs -> EP w m (HsOverLit GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsOverLit GhcPs
ol
        SourceText
NoSourceText -> HsOverLit GhcPs -> EP w m (HsOverLit GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return HsOverLit GhcPs
ol

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

hsLit2String :: HsLit GhcPs -> String
hsLit2String :: HsLit GhcPs -> String
hsLit2String HsLit GhcPs
lit =
  case HsLit GhcPs
lit of
    HsChar       XHsChar GhcPs
src Char
v   -> SourceText -> Char -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix XHsChar GhcPs
SourceText
src Char
v String
""
    HsCharPrim   XHsCharPrim GhcPs
src Char
p   -> SourceText -> Char -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix XHsCharPrim GhcPs
SourceText
src Char
p String
""
    HsString     XHsString GhcPs
src FastString
v   -> SourceText -> FastString -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix XHsString GhcPs
SourceText
src FastString
v String
""
    HsStringPrim XHsStringPrim GhcPs
src ByteString
v   -> SourceText -> ByteString -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix XHsStringPrim GhcPs
SourceText
src ByteString
v String
""
    HsInt        XHsInt GhcPs
_ (IL SourceText
src Bool
_ Integer
v)   -> SourceText -> Integer -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix SourceText
src Integer
v String
""
    HsIntPrim    XHsIntPrim GhcPs
src Integer
v   -> SourceText -> Integer -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix XHsIntPrim GhcPs
SourceText
src Integer
v String
""
    HsWordPrim   XHsWordPrim GhcPs
src Integer
v   -> SourceText -> Integer -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix XHsWordPrim GhcPs
SourceText
src Integer
v String
""
    HsInt64Prim  XHsInt64Prim GhcPs
src Integer
v   -> SourceText -> Integer -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix XHsInt64Prim GhcPs
SourceText
src Integer
v String
""
    HsWord64Prim XHsWord64Prim GhcPs
src Integer
v   -> SourceText -> Integer -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix XHsWord64Prim GhcPs
SourceText
src Integer
v String
""
    HsInteger    XHsInteger GhcPs
src Integer
v Type
_ -> SourceText -> Integer -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix XHsInteger GhcPs
SourceText
src Integer
v String
""
    HsRat        XHsRat GhcPs
_ fl :: FractionalLit
fl@(FL{fl_text :: FractionalLit -> SourceText
fl_text = SourceText
src }) Type
_ -> SourceText -> FractionalLit -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix SourceText
src FractionalLit
fl String
""
    HsFloatPrim  XHsFloatPrim GhcPs
_ fl :: FractionalLit
fl@(FL{fl_text :: FractionalLit -> SourceText
fl_text = SourceText
src })   -> SourceText -> FractionalLit -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix SourceText
src FractionalLit
fl String
"#"
    HsDoublePrim XHsDoublePrim GhcPs
_ fl :: FractionalLit
fl@(FL{fl_text :: FractionalLit -> SourceText
fl_text = SourceText
src })   -> SourceText -> FractionalLit -> ShowS
forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix SourceText
src FractionalLit
fl String
"##"

toSourceTextWithSuffix :: (Show a) => SourceText -> a -> String -> String
toSourceTextWithSuffix :: forall a. Show a => SourceText -> a -> ShowS
toSourceTextWithSuffix (SourceText
NoSourceText)    a
alt String
suffix = a -> String
forall a. Show a => a -> String
show a
alt String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
suffix
toSourceTextWithSuffix (SourceText String
txt) a
_alt String
suffix = String
txt String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
suffix

sourceTextToString :: SourceText -> String -> String
sourceTextToString :: SourceText -> ShowS
sourceTextToString SourceText
NoSourceText String
alt   = String
alt
sourceTextToString (SourceText String
txt) String
_ = String
txt

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

exactUserCon :: (Monad m, Monoid w, ExactPrint con)
  => EpAnn [AddEpAnn] -> con -> HsConPatDetails GhcPs
  -> EP w m (EpAnn [AddEpAnn], con, HsConPatDetails GhcPs)
exactUserCon :: forall (m :: * -> *) w con.
(Monad m, Monoid w, ExactPrint con) =>
EpAnn [AddEpAnn]
-> con
-> HsConPatDetails GhcPs
-> EP w m (EpAnn [AddEpAnn], con, HsConPatDetails GhcPs)
exactUserCon EpAnn [AddEpAnn]
an con
c (InfixCon LPat GhcPs
p1 LPat GhcPs
p2) = do
  GenLocated SrcSpanAnnA (Pat GhcPs)
p1' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
p1
  con
c' <- con -> EP w m con
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated con
c
  GenLocated SrcSpanAnnA (Pat GhcPs)
p2' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
p2
  (EpAnn [AddEpAnn], con,
 HsConDetails
   (HsConPatTyArg GhcPs)
   (GenLocated SrcSpanAnnA (Pat GhcPs))
   (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], con,
      HsConDetails
        (HsConPatTyArg GhcPs)
        (GenLocated SrcSpanAnnA (Pat GhcPs))
        (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an, con
c', GenLocated SrcSpanAnnA (Pat GhcPs)
-> GenLocated SrcSpanAnnA (Pat GhcPs)
-> HsConDetails
     (HsConPatTyArg GhcPs)
     (GenLocated SrcSpanAnnA (Pat GhcPs))
     (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
forall tyarg arg rec. arg -> arg -> HsConDetails tyarg arg rec
InfixCon GenLocated SrcSpanAnnA (Pat GhcPs)
p1' GenLocated SrcSpanAnnA (Pat GhcPs)
p2')
exactUserCon EpAnn [AddEpAnn]
an con
c HsConPatDetails GhcPs
details = do
  con
c' <- con -> EP w m con
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated con
c
  EpAnn [AddEpAnn]
an0 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnOpenC
  HsConDetails
  (HsConPatTyArg GhcPs)
  (GenLocated SrcSpanAnnA (Pat GhcPs))
  (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
details' <- HsConPatDetails GhcPs -> EP w m (HsConPatDetails GhcPs)
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsConPatDetails GhcPs -> EP w m (HsConPatDetails GhcPs)
exactConArgs HsConPatDetails GhcPs
details
  EpAnn [AddEpAnn]
an1 <- EpAnn [AddEpAnn]
-> Lens [AddEpAnn] [AddEpAnn]
-> AnnKeywordId
-> EP w m (EpAnn [AddEpAnn])
forall (m :: * -> *) w ann.
(Monad m, Monoid w) =>
EpAnn ann
-> Lens ann [AddEpAnn] -> AnnKeywordId -> EP w m (EpAnn ann)
markEpAnnL EpAnn [AddEpAnn]
an0 ([AddEpAnn] -> f [AddEpAnn]) -> [AddEpAnn] -> f [AddEpAnn]
Lens [AddEpAnn] [AddEpAnn]
lidl AnnKeywordId
AnnCloseC
  (EpAnn [AddEpAnn], con,
 HsConDetails
   (HsConPatTyArg GhcPs)
   (GenLocated SrcSpanAnnA (Pat GhcPs))
   (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (EpAnn [AddEpAnn], con,
      HsConDetails
        (HsConPatTyArg GhcPs)
        (GenLocated SrcSpanAnnA (Pat GhcPs))
        (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (EpAnn [AddEpAnn]
an1, con
c', HsConDetails
  (HsConPatTyArg GhcPs)
  (GenLocated SrcSpanAnnA (Pat GhcPs))
  (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
details')

instance ExactPrint (HsConPatTyArg GhcPs) where
  getAnnotationEntry :: HsConPatTyArg GhcPs -> Entry
getAnnotationEntry HsConPatTyArg GhcPs
_ = Entry
NoEntryVal
  setAnnotationAnchor :: HsConPatTyArg GhcPs
-> Anchor -> EpAnnComments -> HsConPatTyArg GhcPs
setAnnotationAnchor HsConPatTyArg GhcPs
a Anchor
_ EpAnnComments
_ = HsConPatTyArg GhcPs
a
  exact :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsConPatTyArg GhcPs -> EP w m (HsConPatTyArg GhcPs)
exact (HsConPatTyArg LHsToken "@" GhcPs
at HsPatSigType GhcPs
tyarg) = do
    GenLocated TokenLocation (HsToken "@")
at' <- LHsToken "@" GhcPs -> EP w m (LHsToken "@" GhcPs)
forall (m :: * -> *) w (tok :: Symbol).
(Monad m, Monoid w, KnownSymbol tok) =>
LHsToken tok GhcPs -> EP w m (LHsToken tok GhcPs)
markToken LHsToken "@" GhcPs
at
    HsPatSigType GhcPs
tyarg' <- HsPatSigType GhcPs -> EP w m (HsPatSigType GhcPs)
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsPatSigType GhcPs
tyarg
    HsConPatTyArg GhcPs -> EP w m (HsConPatTyArg GhcPs)
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsToken "@" GhcPs -> HsPatSigType GhcPs -> HsConPatTyArg GhcPs
forall p. LHsToken "@" p -> HsPatSigType p -> HsConPatTyArg p
HsConPatTyArg LHsToken "@" GhcPs
GenLocated TokenLocation (HsToken "@")
at' HsPatSigType GhcPs
tyarg')

exactConArgs :: (Monad m, Monoid w)
  => HsConPatDetails GhcPs -> EP w m (HsConPatDetails GhcPs)
exactConArgs :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
HsConPatDetails GhcPs -> EP w m (HsConPatDetails GhcPs)
exactConArgs (PrefixCon [HsConPatTyArg (NoGhcTc GhcPs)]
tyargs [LPat GhcPs]
pats) = do
  [HsConPatTyArg GhcPs]
tyargs' <- [HsConPatTyArg GhcPs] -> EP w m [HsConPatTyArg GhcPs]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [HsConPatTyArg (NoGhcTc GhcPs)]
[HsConPatTyArg GhcPs]
tyargs
  [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats' <- [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> EP w m [GenLocated SrcSpanAnnA (Pat GhcPs)]
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated [LPat GhcPs]
[GenLocated SrcSpanAnnA (Pat GhcPs)]
pats
  HsConDetails
  (HsConPatTyArg GhcPs)
  (GenLocated SrcSpanAnnA (Pat GhcPs))
  (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (HsConDetails
        (HsConPatTyArg GhcPs)
        (GenLocated SrcSpanAnnA (Pat GhcPs))
        (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([HsConPatTyArg GhcPs]
-> [GenLocated SrcSpanAnnA (Pat GhcPs)]
-> HsConDetails
     (HsConPatTyArg GhcPs)
     (GenLocated SrcSpanAnnA (Pat GhcPs))
     (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
forall tyarg arg rec.
[tyarg] -> [arg] -> HsConDetails tyarg arg rec
PrefixCon [HsConPatTyArg GhcPs]
tyargs' [GenLocated SrcSpanAnnA (Pat GhcPs)]
pats')
exactConArgs (InfixCon LPat GhcPs
p1 LPat GhcPs
p2) = do
  GenLocated SrcSpanAnnA (Pat GhcPs)
p1' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
p1
  GenLocated SrcSpanAnnA (Pat GhcPs)
p2' <- GenLocated SrcSpanAnnA (Pat GhcPs)
-> EP w m (GenLocated SrcSpanAnnA (Pat GhcPs))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated LPat GhcPs
GenLocated SrcSpanAnnA (Pat GhcPs)
p2
  HsConDetails
  (HsConPatTyArg GhcPs)
  (GenLocated SrcSpanAnnA (Pat GhcPs))
  (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (HsConDetails
        (HsConPatTyArg GhcPs)
        (GenLocated SrcSpanAnnA (Pat GhcPs))
        (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpanAnnA (Pat GhcPs)
-> GenLocated SrcSpanAnnA (Pat GhcPs)
-> HsConDetails
     (HsConPatTyArg GhcPs)
     (GenLocated SrcSpanAnnA (Pat GhcPs))
     (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
forall tyarg arg rec. arg -> arg -> HsConDetails tyarg arg rec
InfixCon GenLocated SrcSpanAnnA (Pat GhcPs)
p1' GenLocated SrcSpanAnnA (Pat GhcPs)
p2')
exactConArgs (RecCon HsRecFields GhcPs (LPat GhcPs)
rpats) = do
  HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))
rpats' <- HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))
-> EP w m (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
forall (m :: * -> *) w a.
(Monad m, Monoid w, ExactPrint a) =>
a -> EP w m a
markAnnotated HsRecFields GhcPs (LPat GhcPs)
HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))
rpats
  HsConDetails
  (HsConPatTyArg GhcPs)
  (GenLocated SrcSpanAnnA (Pat GhcPs))
  (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
-> RWST
     (EPOptions m w)
     (EPWriter w)
     EPState
     m
     (HsConDetails
        (HsConPatTyArg GhcPs)
        (GenLocated SrcSpanAnnA (Pat GhcPs))
        (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))))
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))
-> HsConDetails
     (HsConPatTyArg GhcPs)
     (GenLocated SrcSpanAnnA (Pat GhcPs))
     (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs)))
forall tyarg arg rec. rec -> HsConDetails tyarg arg rec
RecCon HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))
rpats')

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

entryFromLocatedA :: LocatedAn ann a -> Entry
entryFromLocatedA :: forall ann a. LocatedAn ann a -> Entry
entryFromLocatedA (L SrcAnn ann
la a
_) = SrcAnn ann -> Entry
forall ast. HasEntry ast => ast -> Entry
fromAnn SrcAnn ann
la

-- =====================================================================
-- Utility stuff
-- ---------------------------------------------------------------------

-- |This should be the final point where things are mode concrete,
-- before output.
-- NOTE: despite the name, this is the ghc-exactprint final output for
-- the PRINT phase.
printStringAtLsDelta :: (Monad m, Monoid w) => DeltaPos -> String -> EP w m ()
printStringAtLsDelta :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> String -> EP w m ()
printStringAtLsDelta DeltaPos
cl String
s = do
  Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  LayoutStartCol
colOffset <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetP
  if DeltaPos -> LayoutStartCol -> Bool
isGoodDeltaWithOffset DeltaPos
cl LayoutStartCol
colOffset
    then do
      Pos -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Pos -> String -> EP w m ()
printStringAt (Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta Pos
p DeltaPos
cl LayoutStartCol
colOffset) String
s
        -- `debug` ("printStringAtLsDelta:(pos,s):" ++ show (undelta p cl colOffset,s))
      Pos
p' <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
      Pos
d <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
      String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"printStringAtLsDelta:(pos,p',d,s):" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos, Pos, String) -> String
forall a. Show a => a -> String
show (Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta Pos
p DeltaPos
cl LayoutStartCol
colOffset,Pos
p',Pos
d,String
s)
    else () -> EP w m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return () EP w m () -> String -> EP w m ()
forall c. c -> String -> c
`debug` (String
"printStringAtLsDelta:bad delta for (mc,s):" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (DeltaPos, String) -> String
forall a. Show a => a -> String
show (DeltaPos
cl,String
s))

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

isGoodDeltaWithOffset :: DeltaPos -> LayoutStartCol -> Bool
isGoodDeltaWithOffset :: DeltaPos -> LayoutStartCol -> Bool
isGoodDeltaWithOffset DeltaPos
dp LayoutStartCol
colOffset = DeltaPos -> Bool
isGoodDelta (Int -> Int -> DeltaPos
deltaPos Int
l Int
c)
  where (Int
l,Int
c) = Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta (Int
0,Int
0) DeltaPos
dp LayoutStartCol
colOffset

-- | Print a comment, using the current layout offset to convert the
-- @DeltaPos@ to an absolute position.
printQueuedComment :: (Monad m, Monoid w) => RealSrcSpan -> Comment -> DeltaPos -> EP w m ()
printQueuedComment :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> Comment -> DeltaPos -> EP w m ()
printQueuedComment RealSrcSpan
_loc Comment{String
commentContents :: String
commentContents :: Comment -> String
commentContents} DeltaPos
dp = do
  Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  Pos
d <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
  LayoutStartCol
colOffset <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetP
  let (Int
dr,Int
dc) = Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta (Int
0,Int
0) DeltaPos
dp LayoutStartCol
colOffset
  -- do not lose comments against the left margin
  Bool -> EP w m () -> EP w m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (DeltaPos -> Bool
isGoodDelta (Int -> Int -> DeltaPos
deltaPos Int
dr (Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
0 Int
dc))) (EP w m () -> EP w m ()) -> EP w m () -> EP w m ()
forall a b. (a -> b) -> a -> b
$ do
    Pos -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Pos -> String -> EP w m ()
printCommentAt (Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta Pos
p DeltaPos
dp LayoutStartCol
colOffset) String
commentContents
  Pos
p' <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  Pos
d' <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"printQueuedComment: (p,p',d,d')=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos, Pos, Pos) -> String
forall a. Show a => a -> String
show (Pos
p,Pos
p',Pos
d,Pos
d')
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"printQueuedComment: (p,p',dp,colOffset,undelta)=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos, DeltaPos, LayoutStartCol, Pos) -> String
forall a. Show a => a -> String
show (Pos
p,Pos
p',DeltaPos
dp,LayoutStartCol
colOffset,Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta Pos
p DeltaPos
dp LayoutStartCol
colOffset)

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

setLayoutBoth :: (Monad m, Monoid w) => EP w m a -> EP w m a
setLayoutBoth :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutBoth EP w m a
k = do
  LayoutStartCol
oldLHS <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetD
  LayoutStartCol
oldAnchorOffset <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetP
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"setLayoutBoth: (oldLHS,oldAnchorOffset)=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (LayoutStartCol, LayoutStartCol) -> String
forall a. Show a => a -> String
show (LayoutStartCol
oldLHS,LayoutStartCol
oldAnchorOffset)
  (EPState -> EPState)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
a -> EPState
a { dMarkLayout = True
                  , pMarkLayout = True } )
  let reset :: RWST (EPOptions m w) (EPWriter w) EPState m ()
reset = do
        String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"setLayoutBoth:reset: (oldLHS,oldAnchorOffset)=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (LayoutStartCol, LayoutStartCol) -> String
forall a. Show a => a -> String
show (LayoutStartCol
oldLHS,LayoutStartCol
oldAnchorOffset)
        (EPState -> EPState)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
a -> EPState
a { dMarkLayout = False
                        , dLHS = oldLHS
                        , pMarkLayout = False
                        , pLHS = oldAnchorOffset} )
  EP w m a
k EP w m a
-> RWST (EPOptions m w) (EPWriter w) EPState m () -> EP w m a
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* RWST (EPOptions m w) (EPWriter w) EPState m ()
reset

-- Use 'local', designed for this
setLayoutTopLevelP :: (Monad m, Monoid w) => EP w m a -> EP w m a
setLayoutTopLevelP :: forall (m :: * -> *) w a.
(Monad m, Monoid w) =>
EP w m a -> EP w m a
setLayoutTopLevelP EP w m a
k = do
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"setLayoutTopLevelP entered"
  LayoutStartCol
oldAnchorOffset <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetP
  (EPState -> EPState)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
a -> EPState
a { pMarkLayout = False
                  , pLHS = 1} )
  a
r <- EP w m a
k
  String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> RWST (EPOptions m w) (EPWriter w) EPState m ())
-> String -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall a b. (a -> b) -> a -> b
$ String
"setLayoutTopLevelP:resetting"
  LayoutStartCol -> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LayoutStartCol -> EP w m ()
setLayoutOffsetP LayoutStartCol
oldAnchorOffset
  a -> EP w m a
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
r

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

getPosP :: (Monad m, Monoid w) => EP w m Pos
getPosP :: forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP = (EPState -> Pos) -> RWST (EPOptions m w) (EPWriter w) EPState m Pos
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets EPState -> Pos
epPos

setPosP :: (Monad m, Monoid w) => Pos -> EP w m ()
setPosP :: forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPosP Pos
l = do
  -- debugM $ "setPosP:" ++ show l
  (EPState -> EPState) -> EP w m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s {epPos = l})

getExtraDP :: (Monad m, Monoid w) => EP w m (Maybe Anchor)
getExtraDP :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m (Maybe Anchor)
getExtraDP = (EPState -> Maybe Anchor)
-> RWST (EPOptions m w) (EPWriter w) EPState m (Maybe Anchor)
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets EPState -> Maybe Anchor
uExtraDP

setExtraDP :: (Monad m, Monoid w) => Maybe Anchor -> EP w m ()
setExtraDP :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Maybe Anchor -> EP w m ()
setExtraDP Maybe Anchor
md = do
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"setExtraDP:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Maybe Anchor -> String
forall a. Show a => a -> String
show Maybe Anchor
md
  (EPState -> EPState) -> EP w m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s {uExtraDP = md})

getPriorEndD :: (Monad m, Monoid w) => EP w m Pos
getPriorEndD :: forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD = (EPState -> Pos) -> RWST (EPOptions m w) (EPWriter w) EPState m Pos
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets EPState -> Pos
dPriorEndPosition

getAnchorU :: (Monad m, Monoid w) => EP w m RealSrcSpan
getAnchorU :: forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m RealSrcSpan
getAnchorU = (EPState -> RealSrcSpan)
-> RWST (EPOptions m w) (EPWriter w) EPState m RealSrcSpan
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets EPState -> RealSrcSpan
uAnchorSpan

setPriorEndD :: (Monad m, Monoid w) => Pos -> EP w m ()
setPriorEndD :: forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPriorEndD Pos
pe = do
  Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPriorEndNoLayoutD Pos
pe

setPriorEndNoLayoutD :: (Monad m, Monoid w) => Pos -> EP w m ()
setPriorEndNoLayoutD :: forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPriorEndNoLayoutD Pos
pe = do
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"setPriorEndNoLayoutD:pe=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Pos -> String
forall a. Show a => a -> String
show Pos
pe
  (EPState -> EPState) -> EP w m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { dPriorEndPosition = pe })

setPriorEndASTD :: (Monad m, Monoid w) => Bool -> RealSrcSpan -> EP w m ()
setPriorEndASTD :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> RealSrcSpan -> EP w m ()
setPriorEndASTD Bool
layout RealSrcSpan
pe = Bool -> (Pos, Pos) -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> (Pos, Pos) -> EP w m ()
setPriorEndASTPD Bool
layout (RealSrcSpan -> (Pos, Pos)
rs2range RealSrcSpan
pe)

setPriorEndASTPD :: (Monad m, Monoid w) => Bool -> (Pos,Pos) -> EP w m ()
setPriorEndASTPD :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> (Pos, Pos) -> EP w m ()
setPriorEndASTPD Bool
layout pe :: (Pos, Pos)
pe@(Pos
fm,Pos
to) = do
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"setPriorEndASTD:pe=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos) -> String
forall a. Show a => a -> String
show (Pos, Pos)
pe
  Bool -> EP w m () -> EP w m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
layout (EP w m () -> EP w m ()) -> EP w m () -> EP w m ()
forall a b. (a -> b) -> a -> b
$ Int -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Int -> EP w m ()
setLayoutStartD (Pos -> Int
forall a b. (a, b) -> b
snd Pos
fm)
  (EPState -> EPState) -> EP w m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { dPriorEndPosition = to } )

setLayoutStartD :: (Monad m, Monoid w) => Int -> EP w m ()
setLayoutStartD :: forall (m :: * -> *) w. (Monad m, Monoid w) => Int -> EP w m ()
setLayoutStartD Int
p = do
  EPState{Bool
dMarkLayout :: EPState -> Bool
dMarkLayout :: Bool
dMarkLayout} <- RWST (EPOptions m w) (EPWriter w) EPState m EPState
forall s (m :: * -> *). MonadState s m => m s
get
  Bool -> EP w m () -> EP w m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
dMarkLayout (EP w m () -> EP w m ()) -> EP w m () -> EP w m ()
forall a b. (a -> b) -> a -> b
$ do
    String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"setLayoutStartD: setting dLHS=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
p
    (EPState -> EPState) -> EP w m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { dMarkLayout = False
                    , dLHS = LayoutStartCol p})

getLayoutOffsetD :: (Monad m, Monoid w) => EP w m LayoutStartCol
getLayoutOffsetD :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetD = (EPState -> LayoutStartCol)
-> RWST (EPOptions m w) (EPWriter w) EPState m LayoutStartCol
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets EPState -> LayoutStartCol
dLHS

setAnchorU :: (Monad m, Monoid w) => RealSrcSpan -> EP w m ()
setAnchorU :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> EP w m ()
setAnchorU RealSrcSpan
rss = do
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"setAnchorU:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos) -> String
forall a. Show a => a -> String
show (RealSrcSpan -> (Pos, Pos)
rs2range RealSrcSpan
rss)
  (EPState -> EPState) -> EP w m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { uAnchorSpan = rss })

getUnallocatedComments :: (Monad m, Monoid w) => EP w m [Comment]
getUnallocatedComments :: forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m [Comment]
getUnallocatedComments = (EPState -> [Comment])
-> RWST (EPOptions m w) (EPWriter w) EPState m [Comment]
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets EPState -> [Comment]
epComments

putUnallocatedComments :: (Monad m, Monoid w) => [Comment] -> EP w m ()
putUnallocatedComments :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
[Comment] -> EP w m ()
putUnallocatedComments [Comment]
cs = (EPState -> EPState)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { epComments = cs } )

-- | Push a fresh stack frame for the applied comments gatherer
pushAppliedComments  :: (Monad m, Monoid w) => EP w m ()
pushAppliedComments :: forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m ()
pushAppliedComments = (EPState -> EPState)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { epCommentsApplied = []:(epCommentsApplied s) })

-- | Return the comments applied since the last call
-- takeAppliedComments, and clear them, not popping the stack
takeAppliedComments :: (Monad m, Monoid w) => EP w m [Comment]
takeAppliedComments :: forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m [Comment]
takeAppliedComments = do
  [[Comment]]
ccs <- (EPState -> [[Comment]])
-> RWST (EPOptions m w) (EPWriter w) EPState m [[Comment]]
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets EPState -> [[Comment]]
epCommentsApplied
  case [[Comment]]
ccs of
    [] -> do
      (EPState -> EPState)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { epCommentsApplied = [] })
      [Comment] -> EP w m [Comment]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return []
    [Comment]
h:[[Comment]]
t -> do
      (EPState -> EPState)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { epCommentsApplied = []:t })
      [Comment] -> EP w m [Comment]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Comment] -> [Comment]
forall a. [a] -> [a]
reverse [Comment]
h)

-- | Return the comments applied since the last call
-- takeAppliedComments, and clear them, popping the stack
takeAppliedCommentsPop :: (Monad m, Monoid w) => EP w m [Comment]
takeAppliedCommentsPop :: forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m [Comment]
takeAppliedCommentsPop = do
  [[Comment]]
ccs <- (EPState -> [[Comment]])
-> RWST (EPOptions m w) (EPWriter w) EPState m [[Comment]]
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets EPState -> [[Comment]]
epCommentsApplied
  case [[Comment]]
ccs of
    [] -> do
      (EPState -> EPState)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { epCommentsApplied = [] })
      [Comment] -> EP w m [Comment]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return []
    [Comment]
h:[[Comment]]
t -> do
      (EPState -> EPState)
-> RWST (EPOptions m w) (EPWriter w) EPState m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { epCommentsApplied = t })
      [Comment] -> EP w m [Comment]
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Comment] -> [Comment]
forall a. [a] -> [a]
reverse [Comment]
h)

-- | Mark a comment as being applied.  This is used to update comments
-- when doing delta processing
applyComment :: (Monad m, Monoid w) => Comment -> EP w m ()
applyComment :: forall (m :: * -> *) w. (Monad m, Monoid w) => Comment -> EP w m ()
applyComment Comment
c = do
  [[Comment]]
ccs <- (EPState -> [[Comment]])
-> RWST (EPOptions m w) (EPWriter w) EPState m [[Comment]]
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets EPState -> [[Comment]]
epCommentsApplied
  case [[Comment]]
ccs of
    []    -> (EPState -> EPState) -> EP w m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { epCommentsApplied = [[c]] } )
    ([Comment]
h:[[Comment]]
t) -> (EPState -> EPState) -> EP w m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { epCommentsApplied = (c:h):t } )

getLayoutOffsetP :: (Monad m, Monoid w) => EP w m LayoutStartCol
getLayoutOffsetP :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetP = (EPState -> LayoutStartCol)
-> RWST (EPOptions m w) (EPWriter w) EPState m LayoutStartCol
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets EPState -> LayoutStartCol
pLHS

setLayoutOffsetP :: (Monad m, Monoid w) => LayoutStartCol -> EP w m ()
setLayoutOffsetP :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
LayoutStartCol -> EP w m ()
setLayoutOffsetP LayoutStartCol
c = do
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"setLayoutOffsetP:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ LayoutStartCol -> String
forall a. Show a => a -> String
show LayoutStartCol
c
  (EPState -> EPState) -> EP w m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { pLHS = c })


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

advance :: (Monad m, Monoid w) => DeltaPos -> EP w m ()
advance :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> EP w m ()
advance DeltaPos
dp = do
  Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  LayoutStartCol
colOffset <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetP
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"advance:(p,dp,colOffset,ws)=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, DeltaPos, LayoutStartCol, Pos) -> String
forall a. Show a => a -> String
show (Pos
p,DeltaPos
dp,LayoutStartCol
colOffset,Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta Pos
p DeltaPos
dp LayoutStartCol
colOffset)
  if DeltaPos -> Bool
isGoodDelta DeltaPos
dp
    then do
      Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
printWhitespace (Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta Pos
p DeltaPos
dp LayoutStartCol
colOffset)
      -- Sync point. We only call advance as we start the sub-span
      -- processing, so force the dPriorEndPosition to ???
      Pos
p0 <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
      Pos
d <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
      RealSrcSpan
r <- EP w m RealSrcSpan
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m RealSrcSpan
getAnchorU
      Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPriorEndD ((Pos, Pos) -> Pos
forall a b. (a, b) -> a
fst ((Pos, Pos) -> Pos) -> (Pos, Pos) -> Pos
forall a b. (a -> b) -> a -> b
$ RealSrcSpan -> (Pos, Pos)
rs2range RealSrcSpan
r)
      String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"advance:after: (posp, posd, posd')=" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, Pos, Pos) -> String
forall a. Show a => a -> String
show (Pos
p0,Pos
d,(Pos, Pos) -> Pos
forall a b. (a, b) -> a
fst ((Pos, Pos) -> Pos) -> (Pos, Pos) -> Pos
forall a b. (a -> b) -> a -> b
$ RealSrcSpan -> (Pos, Pos)
rs2range RealSrcSpan
r)
    else
      () -> EP w m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

adjustDeltaForOffsetM :: (Monad m, Monoid w) => DeltaPos -> EP w m DeltaPos
adjustDeltaForOffsetM :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
DeltaPos -> EP w m DeltaPos
adjustDeltaForOffsetM DeltaPos
dp = do
  LayoutStartCol
colOffset <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetD
  DeltaPos -> EP w m DeltaPos
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (LayoutStartCol -> DeltaPos -> DeltaPos
adjustDeltaForOffset LayoutStartCol
colOffset DeltaPos
dp)

-- ---------------------------------------------------------------------
-- Printing functions

printString :: (Monad m, Monoid w) => Bool -> String -> EP w m ()
printString :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> String -> EP w m ()
printString Bool
layout String
str = do
  EPState{epPos :: EPState -> Pos
epPos = (Int
_,Int
c), Bool
pMarkLayout :: EPState -> Bool
pMarkLayout :: Bool
pMarkLayout} <- RWST (EPOptions m w) (EPWriter w) EPState m EPState
forall s (m :: * -> *). MonadState s m => m s
get
  EPOptions{String -> m w
epTokenPrint :: forall (m :: * -> *) a. EPOptions m a -> String -> m a
epTokenPrint :: String -> m w
epTokenPrint, String -> m w
epWhitespacePrint :: forall (m :: * -> *) a. EPOptions m a -> String -> m a
epWhitespacePrint :: String -> m w
epWhitespacePrint} <- RWST (EPOptions m w) (EPWriter w) EPState m (EPOptions m w)
forall r (m :: * -> *). MonadReader r m => m r
ask
  Bool -> EP w m () -> EP w m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool
pMarkLayout Bool -> Bool -> Bool
&& Bool
layout) (EP w m () -> EP w m ()) -> EP w m () -> EP w m ()
forall a b. (a -> b) -> a -> b
$ do
    String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"printString: setting pLHS to " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
c
    (EPState -> EPState) -> EP w m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\EPState
s -> EPState
s { pLHS = LayoutStartCol c, pMarkLayout = False } )

  -- Advance position, taking care of any newlines in the string
  let strDP :: DeltaPos
strDP = String -> DeltaPos
dpFromString String
str
      cr :: Int
cr = DeltaPos -> Int
getDeltaLine DeltaPos
strDP
  Pos
p <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
  Pos
d <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
  LayoutStartCol
colOffsetP <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetP
  LayoutStartCol
colOffsetD <- EP w m LayoutStartCol
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
EP w m LayoutStartCol
getLayoutOffsetD
  -- debugM $ "printString:(p,colOffset,strDP,cr)="  ++ show (p,colOffset,strDP,cr)
  if Int
cr Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0
    then do
      Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPosP      (Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta Pos
p DeltaPos
strDP LayoutStartCol
colOffsetP)
      Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPriorEndD (Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta Pos
d DeltaPos
strDP LayoutStartCol
colOffsetD)
    else do
      Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPosP      (Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta Pos
p DeltaPos
strDP LayoutStartCol
1)
      Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPriorEndD (Pos -> DeltaPos -> LayoutStartCol -> Pos
undelta Pos
d DeltaPos
strDP LayoutStartCol
1)

  -- Debug stuff
  -- pp <- getPosP
  -- debugM $ "printString: (p,pp,str)" ++ show (p,pp,str)
  -- Debug end

  --
  if Bool -> Bool
not Bool
layout Bool -> Bool -> Bool
&& Int
c Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0
    then m w -> RWST (EPOptions m w) (EPWriter w) EPState m w
forall (m :: * -> *) a.
Monad m =>
m a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (String -> m w
epWhitespacePrint String
str) RWST (EPOptions m w) (EPWriter w) EPState m w
-> (w -> EP w m ()) -> EP w m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> (a -> RWST (EPOptions m w) (EPWriter w) EPState m b)
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \w
s -> EPWriter w -> EP w m ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell EPWriter { output :: w
output = w
s}
    else m w -> RWST (EPOptions m w) (EPWriter w) EPState m w
forall (m :: * -> *) a.
Monad m =>
m a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (String -> m w
epTokenPrint      String
str) RWST (EPOptions m w) (EPWriter w) EPState m w
-> (w -> EP w m ()) -> EP w m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> (a -> RWST (EPOptions m w) (EPWriter w) EPState m b)
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \w
s -> EPWriter w -> EP w m ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell EPWriter { output :: w
output = w
s}

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

printStringAdvance :: (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance :: forall (m :: * -> *) w. (Monad m, Monoid w) => String -> EP w m ()
printStringAdvance String
str = do
  RealSrcSpan
ss <- EP w m RealSrcSpan
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m RealSrcSpan
getAnchorU
  EpaLocation
_ <- RealSrcSpan -> String -> EP w m EpaLocation
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
RealSrcSpan -> String -> EP w m EpaLocation
printStringAtRs RealSrcSpan
ss String
str
  () -> EP w m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

newLine :: (Monad m, Monoid w) => EP w m ()
newLine :: forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m ()
newLine = do
    (Int
l,Int
_) <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
    (Int
ld,Int
_) <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPriorEndD
    Bool -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> String -> EP w m ()
printString Bool
False String
"\n"
    Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPosP (Int
lInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1,Int
1)
    Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
setPriorEndNoLayoutD (Int
ldInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1,Int
1)

padUntil :: (Monad m, Monoid w) => Pos -> EP w m ()
padUntil :: forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
padUntil (Int
l,Int
c) = do
    (Int
l1,Int
c1) <- EP w m Pos
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m Pos
getPosP
    if | Int
l1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
l Bool -> Bool -> Bool
&& Int
c1 Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
c -> Bool -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> String -> EP w m ()
printString Bool
False (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ Int -> Char -> String
forall a. Int -> a -> [a]
replicate (Int
c Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
c1) Char
' '
       | Int
l1 Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
l             -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => EP w m ()
newLine EP w m () -> EP w m () -> EP w m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
padUntil (Int
l,Int
c)
       | Bool
otherwise          -> () -> EP w m ()
forall a. a -> RWST (EPOptions m w) (EPWriter w) EPState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

printWhitespace :: (Monad m, Monoid w) => Pos -> EP w m ()
printWhitespace :: forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
printWhitespace = Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
padUntil

printCommentAt :: (Monad m, Monoid w) => Pos -> String -> EP w m ()
printCommentAt :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Pos -> String -> EP w m ()
printCommentAt Pos
p String
str = do
  String -> EP w m ()
forall (m :: * -> *). Monad m => String -> m ()
debugM (String -> EP w m ()) -> String -> EP w m ()
forall a b. (a -> b) -> a -> b
$ String
"printCommentAt: (pos,str)" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Pos, String) -> String
forall a. Show a => a -> String
show (Pos
p,String
str)
  Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
printWhitespace Pos
p EP w m () -> EP w m () -> EP w m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Bool -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> String -> EP w m ()
printString Bool
False String
str

printStringAt :: (Monad m, Monoid w) => Pos -> String -> EP w m ()
printStringAt :: forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Pos -> String -> EP w m ()
printStringAt Pos
p String
str = Pos -> EP w m ()
forall (m :: * -> *) w. (Monad m, Monoid w) => Pos -> EP w m ()
printWhitespace Pos
p EP w m () -> EP w m () -> EP w m ()
forall a b.
RWST (EPOptions m w) (EPWriter w) EPState m a
-> RWST (EPOptions m w) (EPWriter w) EPState m b
-> RWST (EPOptions m w) (EPWriter w) EPState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Bool -> String -> EP w m ()
forall (m :: * -> *) w.
(Monad m, Monoid w) =>
Bool -> String -> EP w m ()
printString Bool
True String
str