{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeFamilies #-}
module GHC.SourceGen.Decl
( HsDecl'
, type'
, newtype'
, data'
, ConDecl'
, prefixCon
, infixCon
, recordCon
, Field
, field
, strict
, lazy
, HsDerivingClause'
, deriving'
, derivingStock
, derivingAnyclass
, derivingNewtype
#if MIN_VERSION_ghc(8,6,0)
, derivingVia
#endif
, standaloneDeriving
, standaloneDerivingStock
, standaloneDerivingNewtype
, standaloneDerivingAnyclass
, class'
, ClassDecl
, funDep
, instance'
, RawInstDecl
, HasTyFamInst(..)
, tyFamInst
, patSynSigs
, patSynSig
, patSynBind
) where
#if MIN_VERSION_ghc(9,0,0)
import GHC (LexicalFixity(Prefix))
import GHC.Data.Bag (listToBag)
import GHC.Types.SrcLoc (LayoutInfo(..))
#else
import BasicTypes (LexicalFixity(Prefix))
import Bag (listToBag)
#endif
#if !MIN_VERSION_ghc(8,6,0)
import BasicTypes (DerivStrategy(..))
#endif
import GHC (GhcPs)
import GHC.Hs.Binds
import GHC.Hs.Decls
import GHC.Hs.Type
( ConDeclField(..)
, FieldOcc(..)
, HsConDetails(..)
#if !MIN_VERSION_ghc(9,2,0)
, HsImplicitBndrs (..)
#endif
#if MIN_VERSION_ghc(9,2,0)
, HsOuterTyVarBndrs (..)
#endif
, HsSrcBang(..)
, HsType(..)
, LHsType
#if MIN_VERSION_ghc(8,6,0)
, HsWildCardBndrs (..)
#endif
#if MIN_VERSION_ghc(8,8,0)
, HsArg(..)
#endif
, SrcStrictness(..)
, SrcUnpackedness(..)
#if MIN_VERSION_ghc(9,0,0)
, hsUnrestricted
#endif
)
#if MIN_VERSION_ghc(9,2,0)
import GHC.Parser.Annotation (AnnSortKey(..), EpAnn(..))
#elif MIN_VERSION_ghc(8,10,0)
import GHC.Hs.Extension (NoExtField(NoExtField))
#elif MIN_VERSION_ghc(8,6,0)
import GHC.Hs.Extension (NoExt(NoExt))
#else
import PlaceHolder (PlaceHolder(..))
#endif
import GHC.SourceGen.Binds.Internal
import GHC.SourceGen.Lit.Internal (noSourceText)
import GHC.SourceGen.Name
import GHC.SourceGen.Name.Internal
import GHC.SourceGen.Syntax.Internal
import GHC.SourceGen.Type.Internal
data ClassDecl
= ClassSig Sig'
| ClassDefaultMethod HsBind'
| ClassFunDep [RdrNameStr] [RdrNameStr]
instance HasValBind ClassDecl where
sigB :: Sig' -> ClassDecl
sigB = Sig' -> ClassDecl
ClassSig
bindB :: HsBind' -> ClassDecl
bindB = HsBind' -> ClassDecl
ClassDefaultMethod
funDep :: [RdrNameStr] -> [RdrNameStr] -> ClassDecl
funDep :: [RdrNameStr] -> [RdrNameStr] -> ClassDecl
funDep = [RdrNameStr] -> [RdrNameStr] -> ClassDecl
ClassFunDep
class'
:: [HsType']
-> OccNameStr
-> [HsTyVarBndr']
-> [ClassDecl]
-> HsDecl'
class' :: [HsType'] -> OccNameStr -> [HsTyVarBndr'] -> [ClassDecl] -> HsDecl'
class' [HsType']
context OccNameStr
name [HsTyVarBndr']
vars [ClassDecl]
decls
= (NoExtField -> TyClDecl GhcPs -> HsDecl')
-> TyClDecl GhcPs -> HsDecl'
forall a. (NoExtField -> a) -> a
noExt NoExtField -> TyClDecl GhcPs -> HsDecl'
forall p. XTyClD p -> TyClDecl p -> HsDecl p
TyClD (TyClDecl GhcPs -> HsDecl') -> TyClDecl GhcPs -> HsDecl'
forall a b. (a -> b) -> a -> b
$ ClassDecl :: forall pass.
XClassDecl pass
-> LHsContext pass
-> Located (IdP pass)
-> LHsQTyVars pass
-> LexicalFixity
-> [LHsFunDep pass]
-> [LSig pass]
-> LHsBinds pass
-> [LFamilyDecl pass]
-> [LTyFamDefltDecl pass]
-> [LDocDecl]
-> TyClDecl pass
ClassDecl
{ tcdCtxt :: LHsContext GhcPs
tcdCtxt = LHsContext GhcPs -> LHsContext GhcPs
forall a. a -> a
toHsContext (LHsContext GhcPs -> LHsContext GhcPs)
-> LHsContext GhcPs -> LHsContext GhcPs
forall a b. (a -> b) -> a -> b
$ [GenLocated (SrcSpanAnn Any) HsType'] -> LHsContext GhcPs
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated ([GenLocated (SrcSpanAnn Any) HsType'] -> LHsContext GhcPs)
-> [GenLocated (SrcSpanAnn Any) HsType'] -> LHsContext GhcPs
forall a b. (a -> b) -> a -> b
$ (HsType' -> GenLocated (SrcSpanAnn Any) HsType')
-> [HsType'] -> [GenLocated (SrcSpanAnn Any) HsType']
forall a b. (a -> b) -> [a] -> [b]
map HsType' -> GenLocated (SrcSpanAnn Any) HsType'
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated [HsType']
context
#if MIN_VERSION_ghc(9,2,0)
, tcdCExt = (EpAnnNotUsed, NoAnnSortKey, NoLayoutInfo)
#elif MIN_VERSION_ghc(9,0,0)
, tcdCExt = NoLayoutInfo
#elif MIN_VERSION_ghc(8,10,0)
, tcdCExt :: XClassDecl GhcPs
tcdCExt = NoExtField
XClassDecl GhcPs
NoExtField
#elif MIN_VERSION_ghc(8,6,0)
, tcdCExt = NoExt
#else
, tcdFVs = PlaceHolder
#endif
, tcdLName :: Located (IdP GhcPs)
tcdLName = RdrNameStr -> LocatedN RdrName
typeRdrName (RdrNameStr -> LocatedN RdrName) -> RdrNameStr -> LocatedN RdrName
forall a b. (a -> b) -> a -> b
$ OccNameStr -> RdrNameStr
unqual OccNameStr
name
, tcdTyVars :: LHsQTyVars GhcPs
tcdTyVars = [HsTyVarBndr'] -> LHsQTyVars GhcPs
mkQTyVars [HsTyVarBndr']
vars
, tcdFixity :: LexicalFixity
tcdFixity = LexicalFixity
Prefix
, tcdFDs :: [LHsFunDep GhcPs]
tcdFDs = [ ([LocatedN RdrName], [LocatedN RdrName])
-> GenLocated
(SrcSpanAnn Any) ([LocatedN RdrName], [LocatedN RdrName])
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated (([LocatedN RdrName], [LocatedN RdrName])
-> GenLocated
(SrcSpanAnn Any) ([LocatedN RdrName], [LocatedN RdrName]))
-> ([LocatedN RdrName], [LocatedN RdrName])
-> GenLocated
(SrcSpanAnn Any) ([LocatedN RdrName], [LocatedN RdrName])
forall a b. (a -> b) -> a -> b
$ [LocatedN RdrName]
-> [LocatedN RdrName] -> ([LocatedN RdrName], [LocatedN RdrName])
forall a b. a -> b -> (a, b)
funDep' ((RdrNameStr -> LocatedN RdrName)
-> [RdrNameStr] -> [LocatedN RdrName]
forall a b. (a -> b) -> [a] -> [b]
map RdrNameStr -> LocatedN RdrName
typeRdrName [RdrNameStr]
xs) ((RdrNameStr -> LocatedN RdrName)
-> [RdrNameStr] -> [LocatedN RdrName]
forall a b. (a -> b) -> [a] -> [b]
map RdrNameStr -> LocatedN RdrName
typeRdrName [RdrNameStr]
ys)
| ClassFunDep [RdrNameStr]
xs [RdrNameStr]
ys <- [ClassDecl]
decls
]
, tcdSigs :: [LSig GhcPs]
tcdSigs = [Sig' -> LSig GhcPs
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated Sig'
sig | ClassSig Sig'
sig <- [ClassDecl]
decls]
, tcdMeths :: LHsBinds GhcPs
tcdMeths =
[GenLocated (SrcSpanAnn Any) HsBind'] -> LHsBinds GhcPs
forall a. [a] -> Bag a
listToBag [HsBind' -> GenLocated (SrcSpanAnn Any) HsBind'
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated HsBind'
bind | ClassDefaultMethod HsBind'
bind <- [ClassDecl]
decls]
, tcdATs :: [LFamilyDecl GhcPs]
tcdATs = []
, tcdATDefs :: [LTyFamDefltDecl GhcPs]
tcdATDefs = []
, tcdDocs :: [LDocDecl]
tcdDocs = []
}
where
#if MIN_VERSION_ghc(9,2,0)
funDep' = withEpAnnNotUsed FunDep
#else
funDep' :: a -> b -> (a, b)
funDep' = (,)
#endif
#if MIN_VERSION_ghc(9,2,0)
toHsContext = Just
#else
toHsContext :: a -> a
toHsContext = a -> a
forall a. a -> a
id
#endif
data RawInstDecl
= InstSig Sig'
| InstBind HsBind'
| InstTyFam TyFamInstDecl'
instance HasValBind RawInstDecl where
sigB :: Sig' -> RawInstDecl
sigB = Sig' -> RawInstDecl
InstSig
bindB :: HsBind' -> RawInstDecl
bindB = HsBind' -> RawInstDecl
InstBind
instance' :: HsType' -> [RawInstDecl] -> HsDecl'
instance' :: HsType' -> [RawInstDecl] -> HsDecl'
instance' HsType'
ty [RawInstDecl]
decls = (NoExtField -> InstDecl GhcPs -> HsDecl')
-> InstDecl GhcPs -> HsDecl'
forall a. (NoExtField -> a) -> a
noExt NoExtField -> InstDecl GhcPs -> HsDecl'
forall p. XInstD p -> InstDecl p -> HsDecl p
InstD (InstDecl GhcPs -> HsDecl') -> InstDecl GhcPs -> HsDecl'
forall a b. (a -> b) -> a -> b
$ (NoExtField -> ClsInstDecl GhcPs -> InstDecl GhcPs)
-> ClsInstDecl GhcPs -> InstDecl GhcPs
forall a. (NoExtField -> a) -> a
noExt NoExtField -> ClsInstDecl GhcPs -> InstDecl GhcPs
forall pass. XClsInstD pass -> ClsInstDecl pass -> InstDecl pass
ClsInstD (ClsInstDecl GhcPs -> InstDecl GhcPs)
-> ClsInstDecl GhcPs -> InstDecl GhcPs
forall a b. (a -> b) -> a -> b
$ ClsInstDecl :: forall pass.
XCClsInstDecl pass
-> LHsSigType pass
-> LHsBinds pass
-> [LSig pass]
-> [LTyFamInstDecl pass]
-> [LDataFamInstDecl pass]
-> Maybe (Located OverlapMode)
-> ClsInstDecl pass
ClsInstDecl
{ cid_poly_ty :: LHsSigType GhcPs
cid_poly_ty = HsType' -> LHsSigType GhcPs
sigType HsType'
ty
#if MIN_VERSION_ghc(9,2,0)
, cid_ext = (EpAnnNotUsed, NoAnnSortKey)
#elif MIN_VERSION_ghc(8,10,0)
, cid_ext :: XCClsInstDecl GhcPs
cid_ext = NoExtField
XCClsInstDecl GhcPs
NoExtField
#elif MIN_VERSION_ghc(8,6,0)
, cid_ext = NoExt
#endif
, cid_binds :: LHsBinds GhcPs
cid_binds = [GenLocated (SrcSpanAnn Any) HsBind'] -> LHsBinds GhcPs
forall a. [a] -> Bag a
listToBag [HsBind' -> GenLocated (SrcSpanAnn Any) HsBind'
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated HsBind'
b | InstBind HsBind'
b <- [RawInstDecl]
decls]
, cid_sigs :: [LSig GhcPs]
cid_sigs = [Sig' -> LSig GhcPs
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated Sig'
sig | InstSig Sig'
sig <- [RawInstDecl]
decls]
, cid_tyfam_insts :: [LTyFamDefltDecl GhcPs]
cid_tyfam_insts = [TyFamInstDecl' -> LTyFamDefltDecl GhcPs
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated (TyFamInstDecl' -> LTyFamDefltDecl GhcPs)
-> TyFamInstDecl' -> LTyFamDefltDecl GhcPs
forall a b. (a -> b) -> a -> b
$ TyFamInstDecl'
t | InstTyFam TyFamInstDecl'
t <- [RawInstDecl]
decls]
, cid_datafam_insts :: [LDataFamInstDecl GhcPs]
cid_datafam_insts = []
, cid_overlap_mode :: Maybe (Located OverlapMode)
cid_overlap_mode = Maybe (Located OverlapMode)
forall a. Maybe a
Nothing
}
class HasTyFamInst t where
tyFamInstD :: TyFamInstDecl' -> t
instance HasTyFamInst HsDecl' where
tyFamInstD :: TyFamInstDecl' -> HsDecl'
tyFamInstD = (NoExtField -> InstDecl GhcPs -> HsDecl')
-> InstDecl GhcPs -> HsDecl'
forall a. (NoExtField -> a) -> a
noExt NoExtField -> InstDecl GhcPs -> HsDecl'
forall p. XInstD p -> InstDecl p -> HsDecl p
InstD (InstDecl GhcPs -> HsDecl')
-> (TyFamInstDecl' -> InstDecl GhcPs) -> TyFamInstDecl' -> HsDecl'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (NoExtField -> TyFamInstDecl' -> InstDecl GhcPs)
-> TyFamInstDecl' -> InstDecl GhcPs
forall a. (NoExtField -> a) -> a
noExt NoExtField -> TyFamInstDecl' -> InstDecl GhcPs
forall pass.
XTyFamInstD pass -> TyFamInstDecl pass -> InstDecl pass
TyFamInstD
instance HasTyFamInst RawInstDecl where
tyFamInstD :: TyFamInstDecl' -> RawInstDecl
tyFamInstD = TyFamInstDecl' -> RawInstDecl
InstTyFam
tyFamInst :: HasTyFamInst t => RdrNameStr -> [HsType'] -> HsType' -> t
tyFamInst :: RdrNameStr -> [HsType'] -> HsType' -> t
tyFamInst RdrNameStr
name [HsType']
params HsType'
ty = TyFamInstDecl' -> t
forall t. HasTyFamInst t => TyFamInstDecl' -> t
tyFamInstD
(TyFamInstDecl' -> t) -> TyFamInstDecl' -> t
forall a b. (a -> b) -> a -> b
$ FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstDecl'
tyFamInstDecl
(FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstDecl')
-> FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstDecl'
forall a b. (a -> b) -> a -> b
$ Located (IdP GhcPs)
-> Maybe [LHsTyVarBndr GhcPs]
-> [GenLocated (SrcSpanAnn Any) HsType']
-> LexicalFixity
-> GenLocated (SrcSpanAnn Any) HsType'
-> FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
forall pass rhs.
(XCFamEqn pass rhs ~ NoExtField) =>
GenLocated (SrcSpanAnn Any) (IdP pass)
-> Maybe [LHsTyVarBndr pass]
-> [LHsType pass]
-> LexicalFixity
-> rhs
-> FamEqn pass rhs
famEqn
(RdrNameStr -> LocatedN RdrName
typeRdrName RdrNameStr
name)
Maybe [LHsTyVarBndr GhcPs]
forall a. Maybe a
eqn_bndrs
((HsType' -> GenLocated (SrcSpanAnn Any) HsType')
-> [HsType'] -> [GenLocated (SrcSpanAnn Any) HsType']
forall a b. (a -> b) -> [a] -> [b]
map HsType' -> GenLocated (SrcSpanAnn Any) HsType'
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated [HsType']
params)
LexicalFixity
Prefix
(HsType' -> GenLocated (SrcSpanAnn Any) HsType'
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated HsType'
ty)
where
#if MIN_VERSION_ghc(9,2,0)
tyFamInstDecl = withEpAnnNotUsed TyFamInstDecl
#else
tyFamInstDecl :: FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstDecl'
tyFamInstDecl = TyFamInstEqn GhcPs -> TyFamInstDecl'
forall pass. TyFamInstEqn pass -> TyFamInstDecl pass
TyFamInstDecl (TyFamInstEqn GhcPs -> TyFamInstDecl')
-> (FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstEqn GhcPs)
-> FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstDecl'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TyFamInstEqn GhcPs -> TyFamInstEqn GhcPs
forall a. a -> a
withPlaceHolder (TyFamInstEqn GhcPs -> TyFamInstEqn GhcPs)
-> (FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstEqn GhcPs)
-> FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstEqn GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (NoExtField
-> FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstEqn GhcPs)
-> FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstEqn GhcPs
forall a. (NoExtField -> a) -> a
noExt ((NoExtField
-> FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstEqn GhcPs)
-> NoExtField
-> FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstEqn GhcPs
forall a. a -> a
withPlaceHolder NoExtField
-> FamEqn GhcPs (GenLocated (SrcSpanAnn Any) HsType')
-> TyFamInstEqn GhcPs
forall pass thing.
XHsIB pass thing -> thing -> HsImplicitBndrs pass thing
HsIB)
#endif
#if MIN_VERSION_ghc(9,2,0)
famEqn tycon bndrs pats = withEpAnnNotUsed FamEqn tycon bndrs (map HsValArg pats)
#elif MIN_VERSION_ghc(8,8,0)
famEqn :: GenLocated (SrcSpanAnn Any) (IdP pass)
-> Maybe [LHsTyVarBndr pass]
-> [LHsType pass]
-> LexicalFixity
-> rhs
-> FamEqn pass rhs
famEqn GenLocated (SrcSpanAnn Any) (IdP pass)
tycon Maybe [LHsTyVarBndr pass]
bndrs [LHsType pass]
pats = (NoExtField
-> GenLocated (SrcSpanAnn Any) (IdP pass)
-> Maybe [LHsTyVarBndr pass]
-> [HsArg (LHsType pass) (LHsType pass)]
-> LexicalFixity
-> rhs
-> FamEqn pass rhs)
-> GenLocated (SrcSpanAnn Any) (IdP pass)
-> Maybe [LHsTyVarBndr pass]
-> [HsArg (LHsType pass) (LHsType pass)]
-> LexicalFixity
-> rhs
-> FamEqn pass rhs
forall a. (NoExtField -> a) -> a
noExt NoExtField
-> GenLocated (SrcSpanAnn Any) (IdP pass)
-> Maybe [LHsTyVarBndr pass]
-> [HsArg (LHsType pass) (LHsType pass)]
-> LexicalFixity
-> rhs
-> FamEqn pass rhs
forall pass rhs.
XCFamEqn pass rhs
-> Located (IdP pass)
-> Maybe [LHsTyVarBndr pass]
-> HsTyPats pass
-> LexicalFixity
-> rhs
-> FamEqn pass rhs
FamEqn GenLocated (SrcSpanAnn Any) (IdP pass)
tycon Maybe [LHsTyVarBndr pass]
bndrs ((LHsType pass -> HsArg (LHsType pass) (LHsType pass))
-> [LHsType pass] -> [HsArg (LHsType pass) (LHsType pass)]
forall a b. (a -> b) -> [a] -> [b]
map LHsType pass -> HsArg (LHsType pass) (LHsType pass)
forall tm ty. tm -> HsArg tm ty
HsValArg [LHsType pass]
pats)
#else
famEqn tycon _ = noExt FamEqn tycon
#endif
#if MIN_VERSION_ghc(9,2,0)
eqn_bndrs = noExt HsOuterImplicit
#else
eqn_bndrs :: Maybe a
eqn_bndrs = Maybe a
forall a. Maybe a
Nothing
#endif
type' :: OccNameStr -> [HsTyVarBndr'] -> HsType' -> HsDecl'
type' :: OccNameStr -> [HsTyVarBndr'] -> HsType' -> HsDecl'
type' OccNameStr
name [HsTyVarBndr']
vars HsType'
t =
(NoExtField -> TyClDecl GhcPs -> HsDecl')
-> TyClDecl GhcPs -> HsDecl'
forall a. (NoExtField -> a) -> a
noExt NoExtField -> TyClDecl GhcPs -> HsDecl'
forall p. XTyClD p -> TyClDecl p -> HsDecl p
TyClD (TyClDecl GhcPs -> HsDecl') -> TyClDecl GhcPs -> HsDecl'
forall a b. (a -> b) -> a -> b
$ TyClDecl GhcPs -> TyClDecl GhcPs
forall a. a -> a
withPlaceHolder (TyClDecl GhcPs -> TyClDecl GhcPs)
-> TyClDecl GhcPs -> TyClDecl GhcPs
forall a b. (a -> b) -> a -> b
$ (NoExtField
-> LocatedN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> GenLocated (SrcSpanAnn Any) HsType'
-> TyClDecl GhcPs)
-> LocatedN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> GenLocated (SrcSpanAnn Any) HsType'
-> TyClDecl GhcPs
forall a. (NoExtField -> a) -> a
withEpAnnNotUsed NoExtField
-> LocatedN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> GenLocated (SrcSpanAnn Any) HsType'
-> TyClDecl GhcPs
forall pass.
XSynDecl pass
-> Located (IdP pass)
-> LHsQTyVars pass
-> LexicalFixity
-> LHsType pass
-> TyClDecl pass
SynDecl (RdrNameStr -> LocatedN RdrName
typeRdrName (RdrNameStr -> LocatedN RdrName) -> RdrNameStr -> LocatedN RdrName
forall a b. (a -> b) -> a -> b
$ OccNameStr -> RdrNameStr
unqual OccNameStr
name)
([HsTyVarBndr'] -> LHsQTyVars GhcPs
mkQTyVars [HsTyVarBndr']
vars)
LexicalFixity
Prefix
(HsType' -> GenLocated (SrcSpanAnn Any) HsType'
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated HsType'
t)
newOrDataType
:: NewOrData
-> OccNameStr
-> [HsTyVarBndr']
-> [ConDecl']
-> [HsDerivingClause']
-> HsDecl'
newOrDataType :: NewOrData
-> OccNameStr
-> [HsTyVarBndr']
-> [ConDecl']
-> [HsDerivingClause']
-> HsDecl'
newOrDataType NewOrData
newOrData OccNameStr
name [HsTyVarBndr']
vars [ConDecl']
conDecls [HsDerivingClause']
derivs
= (NoExtField -> TyClDecl GhcPs -> HsDecl')
-> TyClDecl GhcPs -> HsDecl'
forall a. (NoExtField -> a) -> a
noExt NoExtField -> TyClDecl GhcPs -> HsDecl'
forall p. XTyClD p -> TyClDecl p -> HsDecl p
TyClD (TyClDecl GhcPs -> HsDecl') -> TyClDecl GhcPs -> HsDecl'
forall a b. (a -> b) -> a -> b
$ TyClDecl GhcPs -> TyClDecl GhcPs
forall a. a -> a
withPlaceHolder (TyClDecl GhcPs -> TyClDecl GhcPs)
-> TyClDecl GhcPs -> TyClDecl GhcPs
forall a b. (a -> b) -> a -> b
$ TyClDecl GhcPs -> TyClDecl GhcPs
forall a. a -> a
withPlaceHolder (TyClDecl GhcPs -> TyClDecl GhcPs)
-> TyClDecl GhcPs -> TyClDecl GhcPs
forall a b. (a -> b) -> a -> b
$
(NoExtField
-> LocatedN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> HsDataDefn GhcPs
-> TyClDecl GhcPs)
-> LocatedN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> HsDataDefn GhcPs
-> TyClDecl GhcPs
forall a. (NoExtField -> a) -> a
withEpAnnNotUsed NoExtField
-> LocatedN RdrName
-> LHsQTyVars GhcPs
-> LexicalFixity
-> HsDataDefn GhcPs
-> TyClDecl GhcPs
forall pass.
XDataDecl pass
-> Located (IdP pass)
-> LHsQTyVars pass
-> LexicalFixity
-> HsDataDefn pass
-> TyClDecl pass
DataDecl (RdrNameStr -> LocatedN RdrName
typeRdrName (RdrNameStr -> LocatedN RdrName) -> RdrNameStr -> LocatedN RdrName
forall a b. (a -> b) -> a -> b
$ OccNameStr -> RdrNameStr
unqual OccNameStr
name)
([HsTyVarBndr'] -> LHsQTyVars GhcPs
mkQTyVars [HsTyVarBndr']
vars)
LexicalFixity
Prefix
(HsDataDefn GhcPs -> TyClDecl GhcPs)
-> HsDataDefn GhcPs -> TyClDecl GhcPs
forall a b. (a -> b) -> a -> b
$ (NoExtField
-> NewOrData
-> LHsContext GhcPs
-> Maybe (Located CType)
-> Maybe (GenLocated (SrcSpanAnn Any) HsType')
-> [LConDecl GhcPs]
-> HsDeriving GhcPs
-> HsDataDefn GhcPs)
-> NewOrData
-> LHsContext GhcPs
-> Maybe (Located CType)
-> Maybe (GenLocated (SrcSpanAnn Any) HsType')
-> [LConDecl GhcPs]
-> HsDeriving GhcPs
-> HsDataDefn GhcPs
forall a. (NoExtField -> a) -> a
noExt NoExtField
-> NewOrData
-> LHsContext GhcPs
-> Maybe (Located CType)
-> Maybe (GenLocated (SrcSpanAnn Any) HsType')
-> [LConDecl GhcPs]
-> HsDeriving GhcPs
-> HsDataDefn GhcPs
forall pass.
XCHsDataDefn pass
-> NewOrData
-> LHsContext pass
-> Maybe (Located CType)
-> Maybe (LHsKind pass)
-> [LConDecl pass]
-> HsDeriving pass
-> HsDataDefn pass
HsDataDefn NewOrData
newOrData
LHsContext GhcPs
forall a. Located [a]
cxt
Maybe (Located CType)
forall a. Maybe a
Nothing
Maybe (GenLocated (SrcSpanAnn Any) HsType')
forall a. Maybe a
Nothing
((ConDecl' -> LConDecl GhcPs) -> [ConDecl'] -> [LConDecl GhcPs]
forall a b. (a -> b) -> [a] -> [b]
map ConDecl' -> LConDecl GhcPs
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated [ConDecl']
conDecls)
([Located HsDerivingClause'] -> HsDeriving GhcPs
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
toHsDeriving ([Located HsDerivingClause'] -> HsDeriving GhcPs)
-> [Located HsDerivingClause'] -> HsDeriving GhcPs
forall a b. (a -> b) -> a -> b
$ (HsDerivingClause' -> Located HsDerivingClause')
-> [HsDerivingClause'] -> [Located HsDerivingClause']
forall a b. (a -> b) -> [a] -> [b]
map HsDerivingClause' -> Located HsDerivingClause'
forall e. e -> Located e
builtLoc [HsDerivingClause']
derivs)
where
#if MIN_VERSION_ghc(9,2,0)
cxt = Nothing
#else
cxt :: Located [a]
cxt = [a] -> Located [a]
forall e. e -> Located e
builtLoc []
#endif
#if MIN_VERSION_ghc(9,2,0)
toHsDeriving = id
#else
toHsDeriving :: a -> GenLocated (SrcSpanAnn Any) a
toHsDeriving = a -> GenLocated (SrcSpanAnn Any) a
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated
#endif
newtype' :: OccNameStr -> [HsTyVarBndr'] -> ConDecl' -> [HsDerivingClause'] -> HsDecl'
newtype' :: OccNameStr
-> [HsTyVarBndr'] -> ConDecl' -> [HsDerivingClause'] -> HsDecl'
newtype' OccNameStr
name [HsTyVarBndr']
vars ConDecl'
conD = NewOrData
-> OccNameStr
-> [HsTyVarBndr']
-> [ConDecl']
-> [HsDerivingClause']
-> HsDecl'
newOrDataType NewOrData
NewType OccNameStr
name [HsTyVarBndr']
vars [ConDecl'
conD]
data' :: OccNameStr -> [HsTyVarBndr'] -> [ConDecl'] -> [HsDerivingClause'] -> HsDecl'
data' :: OccNameStr
-> [HsTyVarBndr'] -> [ConDecl'] -> [HsDerivingClause'] -> HsDecl'
data' = NewOrData
-> OccNameStr
-> [HsTyVarBndr']
-> [ConDecl']
-> [HsDerivingClause']
-> HsDecl'
newOrDataType NewOrData
DataType
prefixCon :: OccNameStr -> [Field] -> ConDecl'
prefixCon :: OccNameStr -> [Field] -> ConDecl'
prefixCon OccNameStr
name [Field]
fields = OccNameStr -> HsConDeclDetails' -> ConDecl'
renderCon98Decl OccNameStr
name
(HsConDeclDetails' -> ConDecl') -> HsConDeclDetails' -> ConDecl'
forall a b. (a -> b) -> a -> b
$ [GenLocated (SrcSpanAnn Any) HsType'] -> HsConDeclDetails'
forall arg rec. [arg] -> HsConDetails arg rec
prefixCon' ([GenLocated (SrcSpanAnn Any) HsType'] -> HsConDeclDetails')
-> [GenLocated (SrcSpanAnn Any) HsType'] -> HsConDeclDetails'
forall a b. (a -> b) -> a -> b
$ (Field -> GenLocated (SrcSpanAnn Any) HsType')
-> [Field] -> [GenLocated (SrcSpanAnn Any) HsType']
forall a b. (a -> b) -> [a] -> [b]
map (GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
forall a. a -> a
hsUnrestricted (GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType')
-> (Field -> GenLocated (SrcSpanAnn Any) HsType')
-> Field
-> GenLocated (SrcSpanAnn Any) HsType'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Field -> GenLocated (SrcSpanAnn Any) HsType'
renderField) [Field]
fields
where
#if MIN_VERSION_ghc(9,2,0)
prefixCon' = PrefixCon []
#else
prefixCon' :: [arg] -> HsConDetails arg rec
prefixCon' = [arg] -> HsConDetails arg rec
forall arg rec. [arg] -> HsConDetails arg rec
PrefixCon
#endif
infixCon :: Field -> OccNameStr -> Field -> ConDecl'
infixCon :: Field -> OccNameStr -> Field -> ConDecl'
infixCon Field
f OccNameStr
name Field
f' = OccNameStr -> HsConDeclDetails' -> ConDecl'
renderCon98Decl OccNameStr
name
(HsConDeclDetails' -> ConDecl') -> HsConDeclDetails' -> ConDecl'
forall a b. (a -> b) -> a -> b
$ GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType' -> HsConDeclDetails'
forall arg rec. arg -> arg -> HsConDetails arg rec
InfixCon (GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
forall a. a -> a
hsUnrestricted (GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType')
-> GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
forall a b. (a -> b) -> a -> b
$ Field -> GenLocated (SrcSpanAnn Any) HsType'
renderField Field
f) (GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
forall a. a -> a
hsUnrestricted (GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType')
-> GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
forall a b. (a -> b) -> a -> b
$ Field -> GenLocated (SrcSpanAnn Any) HsType'
renderField Field
f')
recordCon :: OccNameStr -> [(OccNameStr, Field)] -> ConDecl'
recordCon :: OccNameStr -> [(OccNameStr, Field)] -> ConDecl'
recordCon OccNameStr
name [(OccNameStr, Field)]
fields = OccNameStr -> HsConDeclDetails' -> ConDecl'
renderCon98Decl OccNameStr
name
(HsConDeclDetails' -> ConDecl') -> HsConDeclDetails' -> ConDecl'
forall a b. (a -> b) -> a -> b
$ GenLocated
(SrcSpanAnn Any) [GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)]
-> HsConDeclDetails'
forall arg rec. rec -> HsConDetails arg rec
RecCon (GenLocated
(SrcSpanAnn Any) [GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)]
-> HsConDeclDetails')
-> GenLocated
(SrcSpanAnn Any) [GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)]
-> HsConDeclDetails'
forall a b. (a -> b) -> a -> b
$ [GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)]
-> GenLocated
(SrcSpanAnn Any) [GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)]
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated ([GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)]
-> GenLocated
(SrcSpanAnn Any)
[GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)])
-> [GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)]
-> GenLocated
(SrcSpanAnn Any) [GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)]
forall a b. (a -> b) -> a -> b
$ ((OccNameStr, Field)
-> GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs))
-> [(OccNameStr, Field)]
-> [GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)]
forall a b. (a -> b) -> [a] -> [b]
map (OccNameStr, Field)
-> GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)
forall ann.
(OccNameStr, Field)
-> GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)
mkLConDeclField [(OccNameStr, Field)]
fields
where
mkLConDeclField :: (OccNameStr, Field)
-> GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)
mkLConDeclField (OccNameStr
n, Field
f) =
ConDeclField GhcPs
-> GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated (ConDeclField GhcPs
-> GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs))
-> ConDeclField GhcPs
-> GenLocated (SrcSpanAnn Any) (ConDeclField GhcPs)
forall a b. (a -> b) -> a -> b
$ (NoExtField
-> [LFieldOcc GhcPs]
-> GenLocated (SrcSpanAnn Any) HsType'
-> Maybe LHsDocString
-> ConDeclField GhcPs)
-> [LFieldOcc GhcPs]
-> GenLocated (SrcSpanAnn Any) HsType'
-> Maybe LHsDocString
-> ConDeclField GhcPs
forall a. (NoExtField -> a) -> a
withEpAnnNotUsed NoExtField
-> [LFieldOcc GhcPs]
-> GenLocated (SrcSpanAnn Any) HsType'
-> Maybe LHsDocString
-> ConDeclField GhcPs
forall pass.
XConDeclField pass
-> [LFieldOcc pass]
-> LBangType pass
-> Maybe LHsDocString
-> ConDeclField pass
ConDeclField
[FieldOcc GhcPs -> LFieldOcc GhcPs
forall e. e -> Located e
builtLoc (FieldOcc GhcPs -> LFieldOcc GhcPs)
-> FieldOcc GhcPs -> LFieldOcc GhcPs
forall a b. (a -> b) -> a -> b
$ FieldOcc GhcPs -> FieldOcc GhcPs
forall a. a -> a
withPlaceHolder (FieldOcc GhcPs -> FieldOcc GhcPs)
-> FieldOcc GhcPs -> FieldOcc GhcPs
forall a b. (a -> b) -> a -> b
$ (NoExtField -> LocatedN RdrName -> FieldOcc GhcPs)
-> LocatedN RdrName -> FieldOcc GhcPs
forall a. (NoExtField -> a) -> a
noExt NoExtField -> LocatedN RdrName -> FieldOcc GhcPs
forall pass. XCFieldOcc pass -> LocatedN RdrName -> FieldOcc pass
FieldOcc (LocatedN RdrName -> FieldOcc GhcPs)
-> LocatedN RdrName -> FieldOcc GhcPs
forall a b. (a -> b) -> a -> b
$ RdrNameStr -> LocatedN RdrName
valueRdrName (RdrNameStr -> LocatedN RdrName) -> RdrNameStr -> LocatedN RdrName
forall a b. (a -> b) -> a -> b
$ OccNameStr -> RdrNameStr
unqual OccNameStr
n]
(Field -> GenLocated (SrcSpanAnn Any) HsType'
renderField Field
f)
Maybe LHsDocString
forall a. Maybe a
Nothing
data Field = Field
{ Field -> HsType'
fieldType :: HsType'
, Field -> SrcStrictness
strictness :: SrcStrictness
}
field :: HsType' -> Field
field :: HsType' -> Field
field HsType'
t = HsType' -> SrcStrictness -> Field
Field HsType'
t SrcStrictness
NoSrcStrict
strict :: Field -> Field
strict :: Field -> Field
strict Field
f = Field
f { strictness :: SrcStrictness
strictness = SrcStrictness
SrcStrict }
lazy :: Field -> Field
lazy :: Field -> Field
lazy Field
f = Field
f { strictness :: SrcStrictness
strictness = SrcStrictness
SrcLazy }
#if !MIN_VERSION_ghc(9,0,0)
hsUnrestricted :: a -> a
hsUnrestricted :: a -> a
hsUnrestricted = a -> a
forall a. a -> a
id
#endif
renderField :: Field -> LHsType GhcPs
renderField :: Field -> GenLocated (SrcSpanAnn Any) HsType'
renderField Field
f = GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
wrap (GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType')
-> GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
forall a b. (a -> b) -> a -> b
$ GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
parenthesizeTypeForApp (GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType')
-> GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
forall a b. (a -> b) -> a -> b
$ HsType' -> GenLocated (SrcSpanAnn Any) HsType'
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated (HsType' -> GenLocated (SrcSpanAnn Any) HsType')
-> HsType' -> GenLocated (SrcSpanAnn Any) HsType'
forall a b. (a -> b) -> a -> b
$ Field -> HsType'
fieldType Field
f
where
wrap :: GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
wrap = case Field -> SrcStrictness
strictness Field
f of
SrcStrictness
NoSrcStrict -> GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
forall a. a -> a
id
SrcStrictness
s -> HsType' -> GenLocated (SrcSpanAnn Any) HsType'
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated (HsType' -> GenLocated (SrcSpanAnn Any) HsType')
-> (GenLocated (SrcSpanAnn Any) HsType' -> HsType')
-> GenLocated (SrcSpanAnn Any) HsType'
-> GenLocated (SrcSpanAnn Any) HsType'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((NoExtField
-> HsSrcBang -> GenLocated (SrcSpanAnn Any) HsType' -> HsType')
-> HsSrcBang -> GenLocated (SrcSpanAnn Any) HsType' -> HsType'
forall a. (NoExtField -> a) -> a
withEpAnnNotUsed NoExtField
-> HsSrcBang -> GenLocated (SrcSpanAnn Any) HsType' -> HsType'
forall pass.
XBangTy pass -> HsSrcBang -> LHsType pass -> HsType pass
HsBangTy (HsSrcBang -> GenLocated (SrcSpanAnn Any) HsType' -> HsType')
-> HsSrcBang -> GenLocated (SrcSpanAnn Any) HsType' -> HsType'
forall a b. (a -> b) -> a -> b
$ (SourceText -> SrcUnpackedness -> SrcStrictness -> HsSrcBang)
-> SrcUnpackedness -> SrcStrictness -> HsSrcBang
forall a. (SourceText -> a) -> a
noSourceText SourceText -> SrcUnpackedness -> SrcStrictness -> HsSrcBang
HsSrcBang SrcUnpackedness
NoSrcUnpack SrcStrictness
s)
renderCon98Decl :: OccNameStr -> HsConDeclDetails' -> ConDecl'
renderCon98Decl :: OccNameStr -> HsConDeclDetails' -> ConDecl'
renderCon98Decl OccNameStr
name HsConDeclDetails'
details =
Located (IdP GhcPs)
-> Bool
-> [LHsTyVarBndr GhcPs]
-> Maybe (LHsContext GhcPs)
-> HsConDeclDetails'
-> Maybe LHsDocString
-> ConDecl'
forall pass.
(XConDeclH98 pass ~ NoExtField) =>
GenLocated (SrcSpanAnn Any) (IdP pass)
-> Bool
-> [LHsTyVarBndr pass]
-> Maybe (LHsContext pass)
-> HsConDeclDetails pass
-> Maybe LHsDocString
-> ConDecl pass
conDeclH98 (RdrNameStr -> LocatedN RdrName
typeRdrName (RdrNameStr -> LocatedN RdrName) -> RdrNameStr -> LocatedN RdrName
forall a b. (a -> b) -> a -> b
$ OccNameStr -> RdrNameStr
unqual OccNameStr
name) Bool
False [] Maybe (LHsContext GhcPs)
forall a. Maybe a
Nothing HsConDeclDetails'
details Maybe LHsDocString
forall a. Maybe a
Nothing
where
#if MIN_VERSION_ghc(9,2,0)
conDeclH98 = withEpAnnNotUsed ConDeclH98
#elif MIN_VERSION_ghc(8,6,0)
conDeclH98 :: GenLocated (SrcSpanAnn Any) (IdP pass)
-> Bool
-> [LHsTyVarBndr pass]
-> Maybe (LHsContext pass)
-> HsConDeclDetails pass
-> Maybe LHsDocString
-> ConDecl pass
conDeclH98 GenLocated (SrcSpanAnn Any) (IdP pass)
n = (NoExtField
-> GenLocated (SrcSpanAnn Any) (IdP pass)
-> Located Bool
-> [LHsTyVarBndr pass]
-> Maybe (LHsContext pass)
-> HsConDeclDetails pass
-> Maybe LHsDocString
-> ConDecl pass)
-> GenLocated (SrcSpanAnn Any) (IdP pass)
-> Located Bool
-> [LHsTyVarBndr pass]
-> Maybe (LHsContext pass)
-> HsConDeclDetails pass
-> Maybe LHsDocString
-> ConDecl pass
forall a. (NoExtField -> a) -> a
noExt NoExtField
-> GenLocated (SrcSpanAnn Any) (IdP pass)
-> Located Bool
-> [LHsTyVarBndr pass]
-> Maybe (LHsContext pass)
-> HsConDeclDetails pass
-> Maybe LHsDocString
-> ConDecl pass
forall pass.
XConDeclH98 pass
-> Located (IdP pass)
-> Located Bool
-> [LHsTyVarBndr pass]
-> Maybe (LHsContext pass)
-> HsConDeclDetails pass
-> Maybe LHsDocString
-> ConDecl pass
ConDeclH98 GenLocated (SrcSpanAnn Any) (IdP pass)
n (Located Bool
-> [LHsTyVarBndr pass]
-> Maybe (LHsContext pass)
-> HsConDeclDetails pass
-> Maybe LHsDocString
-> ConDecl pass)
-> (Bool -> Located Bool)
-> Bool
-> [LHsTyVarBndr pass]
-> Maybe (LHsContext pass)
-> HsConDeclDetails pass
-> Maybe LHsDocString
-> ConDecl pass
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Located Bool
forall e. e -> Located e
builtLoc
#else
conDeclH98 n _ _ = ConDeclH98 n Nothing
#endif
deriving' :: [HsType'] -> HsDerivingClause'
deriving' :: [HsType'] -> HsDerivingClause'
deriving' = Maybe DerivStrategy' -> [HsType'] -> HsDerivingClause'
derivingWay Maybe DerivStrategy'
forall a. Maybe a
Nothing
derivingWay :: Maybe DerivStrategy' -> [HsType'] -> HsDerivingClause'
derivingWay :: Maybe DerivStrategy' -> [HsType'] -> HsDerivingClause'
derivingWay Maybe DerivStrategy'
way [HsType']
ts =
(NoExtField
-> Maybe (LDerivStrategy GhcPs)
-> Located [LHsSigType GhcPs]
-> HsDerivingClause')
-> Maybe (LDerivStrategy GhcPs)
-> Located [LHsSigType GhcPs]
-> HsDerivingClause'
forall a. (NoExtField -> a) -> a
withEpAnnNotUsed NoExtField
-> Maybe (LDerivStrategy GhcPs)
-> Located [LHsSigType GhcPs]
-> HsDerivingClause'
forall pass.
XCHsDerivingClause pass
-> Maybe (LDerivStrategy pass)
-> Located [LHsSigType pass]
-> HsDerivingClause pass
HsDerivingClause ((DerivStrategy' -> LDerivStrategy GhcPs)
-> Maybe DerivStrategy' -> Maybe (LDerivStrategy GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DerivStrategy' -> LDerivStrategy GhcPs
forall e. e -> Located e
builtLoc Maybe DerivStrategy'
way) (Located [LHsSigType GhcPs] -> HsDerivingClause')
-> Located [LHsSigType GhcPs] -> HsDerivingClause'
forall a b. (a -> b) -> a -> b
$ [LHsSigType GhcPs] -> Located [LHsSigType GhcPs]
forall a ann. a -> GenLocated (SrcSpanAnn Any) a
mkLocated ([LHsSigType GhcPs] -> Located [LHsSigType GhcPs])
-> [LHsSigType GhcPs] -> Located [LHsSigType GhcPs]
forall a b. (a -> b) -> a -> b
$ [LHsSigType GhcPs] -> [LHsSigType GhcPs]
forall a. a -> a
derivClauseTys ([LHsSigType GhcPs] -> [LHsSigType GhcPs])
-> [LHsSigType GhcPs] -> [LHsSigType GhcPs]
forall a b. (a -> b) -> a -> b
$ (HsType' -> LHsSigType GhcPs) -> [HsType'] -> [LHsSigType GhcPs]
forall a b. (a -> b) -> [a] -> [b]
map HsType' -> LHsSigType GhcPs
sigType [HsType']
ts
where
#if MIN_VERSION_ghc(9,2,0)
derivClauseTys [x] = noExt DctSingle x
derivClauseTys xs = noExt DctMulti xs
#else
derivClauseTys :: a -> a
derivClauseTys = a -> a
forall a. a -> a
id
#endif
derivingStock :: [HsType'] -> HsDerivingClause'
derivingStock :: [HsType'] -> HsDerivingClause'
derivingStock = Maybe DerivStrategy' -> [HsType'] -> HsDerivingClause'
derivingWay (DerivStrategy' -> Maybe DerivStrategy'
forall a. a -> Maybe a
Just DerivStrategy'
forall pass. DerivStrategy pass
strat)
where
#if MIN_VERSION_ghc(9,2,0)
strat = withEpAnnNotUsed StockStrategy
#else
strat :: DerivStrategy pass
strat = DerivStrategy pass
forall pass. DerivStrategy pass
StockStrategy
#endif
derivingNewtype :: [HsType'] -> HsDerivingClause'
derivingNewtype :: [HsType'] -> HsDerivingClause'
derivingNewtype = Maybe DerivStrategy' -> [HsType'] -> HsDerivingClause'
derivingWay (DerivStrategy' -> Maybe DerivStrategy'
forall a. a -> Maybe a
Just DerivStrategy'
forall pass. DerivStrategy pass
strat)
where
#if MIN_VERSION_ghc(9,2,0)
strat = withEpAnnNotUsed NewtypeStrategy
#else
strat :: DerivStrategy pass
strat = DerivStrategy pass
forall pass. DerivStrategy pass
NewtypeStrategy
#endif
derivingAnyclass :: [HsType'] -> HsDerivingClause'
derivingAnyclass :: [HsType'] -> HsDerivingClause'
derivingAnyclass = Maybe DerivStrategy' -> [HsType'] -> HsDerivingClause'
derivingWay (DerivStrategy' -> Maybe DerivStrategy'
forall a. a -> Maybe a
Just DerivStrategy'
forall pass. DerivStrategy pass
strat)
where
#if MIN_VERSION_ghc(9,2,0)
strat = withEpAnnNotUsed AnyclassStrategy
#else
strat :: DerivStrategy pass
strat = DerivStrategy pass
forall pass. DerivStrategy pass
AnyclassStrategy
#endif
#if MIN_VERSION_ghc(8,6,0)
derivingVia :: HsType' -> [HsType'] -> HsDerivingClause'
derivingVia :: HsType' -> [HsType'] -> HsDerivingClause'
derivingVia HsType'
t = Maybe DerivStrategy' -> [HsType'] -> HsDerivingClause'
derivingWay (DerivStrategy' -> Maybe DerivStrategy'
forall a. a -> Maybe a
Just (DerivStrategy' -> Maybe DerivStrategy')
-> DerivStrategy' -> Maybe DerivStrategy'
forall a b. (a -> b) -> a -> b
$ XViaStrategy GhcPs -> DerivStrategy'
forall pass. XViaStrategy pass -> DerivStrategy pass
strat (XViaStrategy GhcPs -> DerivStrategy')
-> XViaStrategy GhcPs -> DerivStrategy'
forall a b. (a -> b) -> a -> b
$ HsType' -> LHsSigType GhcPs
sigType HsType'
t)
where
#if MIN_VERSION_ghc(9,2,0)
strat = ViaStrategy . withEpAnnNotUsed XViaStrategyPs
#else
strat :: XViaStrategy pass -> DerivStrategy pass
strat = XViaStrategy pass -> DerivStrategy pass
forall pass. XViaStrategy pass -> DerivStrategy pass
ViaStrategy
#endif
#endif
standaloneDeriving :: HsType' -> HsDecl'
standaloneDeriving :: HsType' -> HsDecl'
standaloneDeriving = Maybe DerivStrategy' -> HsType' -> HsDecl'
standaloneDerivingWay Maybe DerivStrategy'
forall a. Maybe a
Nothing
standaloneDerivingStock :: HsType' -> HsDecl'
standaloneDerivingStock :: HsType' -> HsDecl'
standaloneDerivingStock = Maybe DerivStrategy' -> HsType' -> HsDecl'
standaloneDerivingWay (DerivStrategy' -> Maybe DerivStrategy'
forall a. a -> Maybe a
Just DerivStrategy'
forall pass. DerivStrategy pass
strat)
where
#if MIN_VERSION_ghc(9,2,0)
strat = withEpAnnNotUsed StockStrategy
#else
strat :: DerivStrategy pass
strat = DerivStrategy pass
forall pass. DerivStrategy pass
StockStrategy
#endif
standaloneDerivingNewtype :: HsType' -> HsDecl'
standaloneDerivingNewtype :: HsType' -> HsDecl'
standaloneDerivingNewtype = Maybe DerivStrategy' -> HsType' -> HsDecl'
standaloneDerivingWay (DerivStrategy' -> Maybe DerivStrategy'
forall a. a -> Maybe a
Just DerivStrategy'
forall pass. DerivStrategy pass
strat)
where
#if MIN_VERSION_ghc(9,2,0)
strat = withEpAnnNotUsed NewtypeStrategy
#else
strat :: DerivStrategy pass
strat = DerivStrategy pass
forall pass. DerivStrategy pass
NewtypeStrategy
#endif
standaloneDerivingAnyclass :: HsType' -> HsDecl'
standaloneDerivingAnyclass :: HsType' -> HsDecl'
standaloneDerivingAnyclass = Maybe DerivStrategy' -> HsType' -> HsDecl'
standaloneDerivingWay (DerivStrategy' -> Maybe DerivStrategy'
forall a. a -> Maybe a
Just DerivStrategy'
forall pass. DerivStrategy pass
strat)
where
#if MIN_VERSION_ghc(9,2,0)
strat = withEpAnnNotUsed AnyclassStrategy
#else
strat :: DerivStrategy pass
strat = DerivStrategy pass
forall pass. DerivStrategy pass
AnyclassStrategy
#endif
standaloneDerivingWay :: Maybe DerivStrategy' -> HsType' -> HsDecl'
standaloneDerivingWay :: Maybe DerivStrategy' -> HsType' -> HsDecl'
standaloneDerivingWay Maybe DerivStrategy'
way HsType'
ty = (NoExtField -> DerivDecl GhcPs -> HsDecl')
-> DerivDecl GhcPs -> HsDecl'
forall a. (NoExtField -> a) -> a
noExt NoExtField -> DerivDecl GhcPs -> HsDecl'
forall p. XDerivD p -> DerivDecl p -> HsDecl p
DerivD DerivDecl GhcPs
derivDecl
where derivDecl :: DerivDecl GhcPs
derivDecl =
(NoExtField
-> LHsSigWcType GhcPs
-> Maybe (LDerivStrategy GhcPs)
-> Maybe (Located OverlapMode)
-> DerivDecl GhcPs)
-> LHsSigWcType GhcPs
-> Maybe (LDerivStrategy GhcPs)
-> Maybe (Located OverlapMode)
-> DerivDecl GhcPs
forall a. (NoExtField -> a) -> a
withEpAnnNotUsed NoExtField
-> LHsSigWcType GhcPs
-> Maybe (LDerivStrategy GhcPs)
-> Maybe (Located OverlapMode)
-> DerivDecl GhcPs
forall pass.
XCDerivDecl pass
-> LHsSigWcType pass
-> Maybe (LDerivStrategy pass)
-> Maybe (Located OverlapMode)
-> DerivDecl pass
DerivDecl (LHsSigType GhcPs -> LHsSigWcType GhcPs
hsWC (LHsSigType GhcPs -> LHsSigWcType GhcPs)
-> LHsSigType GhcPs -> LHsSigWcType GhcPs
forall a b. (a -> b) -> a -> b
$ HsType' -> LHsSigType GhcPs
sigType HsType'
ty) ((DerivStrategy' -> LDerivStrategy GhcPs)
-> Maybe DerivStrategy' -> Maybe (LDerivStrategy GhcPs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DerivStrategy' -> LDerivStrategy GhcPs
forall e. e -> Located e
builtLoc Maybe DerivStrategy'
way) Maybe (Located OverlapMode)
forall a. Maybe a
Nothing
hsWC :: LHsSigType GhcPs -> LHsSigWcType GhcPs
hsWC =
#if MIN_VERSION_ghc(8,6,0)
(NoExtField -> LHsSigType GhcPs -> LHsSigWcType GhcPs)
-> LHsSigType GhcPs -> LHsSigWcType GhcPs
forall a. (NoExtField -> a) -> a
noExt NoExtField -> LHsSigType GhcPs -> LHsSigWcType GhcPs
forall pass thing.
XHsWC pass thing -> thing -> HsWildCardBndrs pass thing
HsWC
#else
id
#endif
patSynSigs :: [OccNameStr] -> HsType' -> HsDecl'
patSynSigs :: [OccNameStr] -> HsType' -> HsDecl'
patSynSigs [OccNameStr]
names HsType'
t =
Sig' -> HsDecl'
forall t. HasValBind t => Sig' -> t
sigB (Sig' -> HsDecl') -> Sig' -> HsDecl'
forall a b. (a -> b) -> a -> b
$ (NoExtField -> [LocatedN RdrName] -> LHsSigType GhcPs -> Sig')
-> [LocatedN RdrName] -> LHsSigType GhcPs -> Sig'
forall a. (NoExtField -> a) -> a
withEpAnnNotUsed NoExtField -> [LocatedN RdrName] -> LHsSigType GhcPs -> Sig'
forall pass.
XPatSynSig pass
-> [Located (IdP pass)] -> LHsSigType pass -> Sig pass
PatSynSig ((OccNameStr -> LocatedN RdrName)
-> [OccNameStr] -> [LocatedN RdrName]
forall a b. (a -> b) -> [a] -> [b]
map (RdrNameStr -> LocatedN RdrName
typeRdrName (RdrNameStr -> LocatedN RdrName)
-> (OccNameStr -> RdrNameStr) -> OccNameStr -> LocatedN RdrName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OccNameStr -> RdrNameStr
unqual) [OccNameStr]
names)
(LHsSigType GhcPs -> Sig') -> LHsSigType GhcPs -> Sig'
forall a b. (a -> b) -> a -> b
$ HsType' -> LHsSigType GhcPs
sigType HsType'
t
patSynSig :: OccNameStr -> HsType' -> HsDecl'
patSynSig :: OccNameStr -> HsType' -> HsDecl'
patSynSig OccNameStr
n = [OccNameStr] -> HsType' -> HsDecl'
patSynSigs [OccNameStr
n]
patSynBind :: OccNameStr -> [OccNameStr] -> Pat' -> HsDecl'
patSynBind :: OccNameStr -> [OccNameStr] -> Pat' -> HsDecl'
patSynBind OccNameStr
n [OccNameStr]
ns Pat'
p = HsBind' -> HsDecl'
forall t. HasValBind t => HsBind' -> t
bindB (HsBind' -> HsDecl') -> HsBind' -> HsDecl'
forall a b. (a -> b) -> a -> b
$ (NoExtField -> PatSynBind GhcPs GhcPs -> HsBind')
-> PatSynBind GhcPs GhcPs -> HsBind'
forall a. (NoExtField -> a) -> a
noExt NoExtField -> PatSynBind GhcPs GhcPs -> HsBind'
forall idL idR.
XPatSynBind idL idR -> PatSynBind idL idR -> HsBindLR idL idR
PatSynBind
(PatSynBind GhcPs GhcPs -> HsBind')
-> PatSynBind GhcPs GhcPs -> HsBind'
forall a b. (a -> b) -> a -> b
$ (HsConDetails
(LocatedN RdrName) [RecordPatSynField (LocatedN RdrName)]
-> GenLocated (SrcSpanAnn Any) Pat'
-> HsPatSynDir GhcPs
-> PatSynBind GhcPs GhcPs)
-> HsConDetails
(LocatedN RdrName) [RecordPatSynField (LocatedN RdrName)]
-> GenLocated (SrcSpanAnn Any) Pat'
-> HsPatSynDir GhcPs
-> PatSynBind GhcPs GhcPs
forall a. a -> a
withPlaceHolder ((NoExtField
-> LocatedN RdrName
-> HsConDetails
(LocatedN RdrName) [RecordPatSynField (LocatedN RdrName)]
-> GenLocated (SrcSpanAnn Any) Pat'
-> HsPatSynDir GhcPs
-> PatSynBind GhcPs GhcPs)
-> LocatedN RdrName
-> HsConDetails
(LocatedN RdrName) [RecordPatSynField (LocatedN RdrName)]
-> GenLocated (SrcSpanAnn Any) Pat'
-> HsPatSynDir GhcPs
-> PatSynBind GhcPs GhcPs
forall a. (NoExtField -> a) -> a
withEpAnnNotUsed NoExtField
-> LocatedN RdrName
-> HsConDetails
(LocatedN RdrName) [RecordPatSynField (LocatedN RdrName)]
-> GenLocated (SrcSpanAnn Any) Pat'
-> HsPatSynDir GhcPs
-> PatSynBind GhcPs GhcPs
forall idL idR.
XPSB idL idR
-> Located (IdP idL)
-> HsPatSynDetails (Located (IdP idR))
-> LPat idR
-> HsPatSynDir idR
-> PatSynBind idL idR
PSB (RdrNameStr -> LocatedN RdrName
valueRdrName (RdrNameStr -> LocatedN RdrName) -> RdrNameStr -> LocatedN RdrName
forall a b. (a -> b) -> a -> b
$ OccNameStr -> RdrNameStr
unqual OccNameStr
n))
([LocatedN RdrName]
-> HsConDetails
(LocatedN RdrName) [RecordPatSynField (LocatedN RdrName)]
forall arg rec. [arg] -> HsConDetails arg rec
prefixCon' ((OccNameStr -> LocatedN RdrName)
-> [OccNameStr] -> [LocatedN RdrName]
forall a b. (a -> b) -> [a] -> [b]
map (RdrNameStr -> LocatedN RdrName
valueRdrName (RdrNameStr -> LocatedN RdrName)
-> (OccNameStr -> RdrNameStr) -> OccNameStr -> LocatedN RdrName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OccNameStr -> RdrNameStr
unqual) [OccNameStr]
ns))
(Pat' -> LPat'
builtPat Pat'
p)
HsPatSynDir GhcPs
forall id. HsPatSynDir id
ImplicitBidirectional
where
#if MIN_VERSION_ghc(9,2,0)
prefixCon' = PrefixCon []
#else
prefixCon' :: [arg] -> HsConDetails arg rec
prefixCon' = [arg] -> HsConDetails arg rec
forall arg rec. [arg] -> HsConDetails arg rec
PrefixCon
#endif