-- |
-- Language.Haskell.TH.Lib.Internal exposes some additional functionality that
-- is used internally in GHC's integration with Template Haskell. This is not a
-- part of the public API, and as such, there are no API guarantees for this
-- module from version to version.

-- Why do we have both Language.Haskell.TH.Lib.Internal and
-- Language.Haskell.TH.Lib? Ultimately, it's because the functions in the
-- former (which are tailored for GHC's use) need different type signatures
-- than the ones in the latter. Syncing up the Internal type signatures would
-- involve a massive amount of breaking changes, so for the time being, we
-- relegate as many changes as we can to just the Internal module, where it
-- is safe to break things.

module Language.Haskell.TH.Lib.Internal where

import Language.Haskell.TH.Syntax hiding (Role, InjectivityAnn)
import qualified Language.Haskell.TH.Syntax as TH
import Control.Monad( liftM, liftM2 )
import Data.Word( Word8 )
import Prelude

----------------------------------------------------------
-- * Type synonyms
----------------------------------------------------------

type InfoQ               = Q Info
type PatQ                = Q Pat
type FieldPatQ           = Q FieldPat
type ExpQ                = Q Exp
type TExpQ a             = Q (TExp a)
type DecQ                = Q Dec
type DecsQ               = Q [Dec]
type ConQ                = Q Con
type TypeQ               = Q Type
type KindQ               = Q Kind
type TyVarBndrQ          = Q TyVarBndr
type TyLitQ              = Q TyLit
type CxtQ                = Q Cxt
type PredQ               = Q Pred
type DerivClauseQ        = Q DerivClause
type MatchQ              = Q Match
type ClauseQ             = Q Clause
type BodyQ               = Q Body
type GuardQ              = Q Guard
type StmtQ               = Q Stmt
type RangeQ              = Q Range
type SourceStrictnessQ   = Q SourceStrictness
type SourceUnpackednessQ = Q SourceUnpackedness
type BangQ               = Q Bang
type BangTypeQ           = Q BangType
type VarBangTypeQ        = Q VarBangType
type StrictTypeQ         = Q StrictType
type VarStrictTypeQ      = Q VarStrictType
type FieldExpQ           = Q FieldExp
type RuleBndrQ           = Q RuleBndr
type TySynEqnQ           = Q TySynEqn
type PatSynDirQ          = Q PatSynDir
type PatSynArgsQ         = Q PatSynArgs
type FamilyResultSigQ    = Q FamilyResultSig
type DerivStrategyQ      = Q DerivStrategy

-- must be defined here for DsMeta to find it
type Role                = TH.Role
type InjectivityAnn      = TH.InjectivityAnn

----------------------------------------------------------
-- * Lowercase pattern syntax functions
----------------------------------------------------------

intPrimL    :: Integer -> Lit
intPrimL :: Integer -> Lit
intPrimL    = Integer -> Lit
IntPrimL
wordPrimL    :: Integer -> Lit
wordPrimL :: Integer -> Lit
wordPrimL    = Integer -> Lit
WordPrimL
floatPrimL  :: Rational -> Lit
floatPrimL :: Rational -> Lit
floatPrimL  = Rational -> Lit
FloatPrimL
doublePrimL :: Rational -> Lit
doublePrimL :: Rational -> Lit
doublePrimL = Rational -> Lit
DoublePrimL
integerL    :: Integer -> Lit
integerL :: Integer -> Lit
integerL    = Integer -> Lit
IntegerL
charL       :: Char -> Lit
charL :: Char -> Lit
charL       = Char -> Lit
CharL
charPrimL   :: Char -> Lit
charPrimL :: Char -> Lit
charPrimL   = Char -> Lit
CharPrimL
stringL     :: String -> Lit
stringL :: String -> Lit
stringL     = String -> Lit
StringL
stringPrimL :: [Word8] -> Lit
stringPrimL :: [Word8] -> Lit
stringPrimL = [Word8] -> Lit
StringPrimL
rationalL   :: Rational -> Lit
rationalL :: Rational -> Lit
rationalL   = Rational -> Lit
RationalL

litP :: Lit -> PatQ
litP :: Lit -> PatQ
litP l :: Lit
l = Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Lit -> Pat
LitP Lit
l)

varP :: Name -> PatQ
varP :: Name -> PatQ
varP v :: Name
v = Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> Pat
VarP Name
v)

tupP :: [PatQ] -> PatQ
tupP :: [PatQ] -> PatQ
tupP ps :: [PatQ]
ps = do { [Pat]
ps1 <- [PatQ] -> Q [Pat]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [PatQ]
ps; Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Pat] -> Pat
TupP [Pat]
ps1)}

unboxedTupP :: [PatQ] -> PatQ
unboxedTupP :: [PatQ] -> PatQ
unboxedTupP ps :: [PatQ]
ps = do { [Pat]
ps1 <- [PatQ] -> Q [Pat]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [PatQ]
ps; Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Pat] -> Pat
UnboxedTupP [Pat]
ps1)}

unboxedSumP :: PatQ -> SumAlt -> SumArity -> PatQ
unboxedSumP :: PatQ -> SumAlt -> SumAlt -> PatQ
unboxedSumP p :: PatQ
p alt :: SumAlt
alt arity :: SumAlt
arity = do { Pat
p1 <- PatQ
p; Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat -> SumAlt -> SumAlt -> Pat
UnboxedSumP Pat
p1 SumAlt
alt SumAlt
arity) }

conP :: Name -> [PatQ] -> PatQ
conP :: Name -> [PatQ] -> PatQ
conP n :: Name
n ps :: [PatQ]
ps = do [Pat]
ps' <- [PatQ] -> Q [Pat]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [PatQ]
ps
               Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> [Pat] -> Pat
ConP Name
n [Pat]
ps')
infixP :: PatQ -> Name -> PatQ -> PatQ
infixP :: PatQ -> Name -> PatQ -> PatQ
infixP p1 :: PatQ
p1 n :: Name
n p2 :: PatQ
p2 = do Pat
p1' <- PatQ
p1
                    Pat
p2' <- PatQ
p2
                    Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat -> Name -> Pat -> Pat
InfixP Pat
p1' Name
n Pat
p2')
uInfixP :: PatQ -> Name -> PatQ -> PatQ
uInfixP :: PatQ -> Name -> PatQ -> PatQ
uInfixP p1 :: PatQ
p1 n :: Name
n p2 :: PatQ
p2 = do Pat
p1' <- PatQ
p1
                     Pat
p2' <- PatQ
p2
                     Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat -> Name -> Pat -> Pat
UInfixP Pat
p1' Name
n Pat
p2')
parensP :: PatQ -> PatQ
parensP :: PatQ -> PatQ
parensP p :: PatQ
p = do Pat
p' <- PatQ
p
               Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat -> Pat
ParensP Pat
p')

tildeP :: PatQ -> PatQ
tildeP :: PatQ -> PatQ
tildeP p :: PatQ
p = do Pat
p' <- PatQ
p
              Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat -> Pat
TildeP Pat
p')
bangP :: PatQ -> PatQ
bangP :: PatQ -> PatQ
bangP p :: PatQ
p = do Pat
p' <- PatQ
p
             Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat -> Pat
BangP Pat
p')
asP :: Name -> PatQ -> PatQ
asP :: Name -> PatQ -> PatQ
asP n :: Name
n p :: PatQ
p = do Pat
p' <- PatQ
p
             Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> Pat -> Pat
AsP Name
n Pat
p')
wildP :: PatQ
wildP :: PatQ
wildP = Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return Pat
WildP
recP :: Name -> [FieldPatQ] -> PatQ
recP :: Name -> [FieldPatQ] -> PatQ
recP n :: Name
n fps :: [FieldPatQ]
fps = do [FieldPat]
fps' <- [FieldPatQ] -> Q [FieldPat]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [FieldPatQ]
fps
                Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> [FieldPat] -> Pat
RecP Name
n [FieldPat]
fps')
listP :: [PatQ] -> PatQ
listP :: [PatQ] -> PatQ
listP ps :: [PatQ]
ps = do [Pat]
ps' <- [PatQ] -> Q [Pat]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [PatQ]
ps
              Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Pat] -> Pat
ListP [Pat]
ps')
sigP :: PatQ -> TypeQ -> PatQ
sigP :: PatQ -> TypeQ -> PatQ
sigP p :: PatQ
p t :: TypeQ
t = do Pat
p' <- PatQ
p
              Type
t' <- TypeQ
t
              Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat -> Type -> Pat
SigP Pat
p' Type
t')
viewP :: ExpQ -> PatQ -> PatQ
viewP :: ExpQ -> PatQ -> PatQ
viewP e :: ExpQ
e p :: PatQ
p = do Exp
e' <- ExpQ
e
               Pat
p' <- PatQ
p
               Pat -> PatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Pat -> Pat
ViewP Exp
e' Pat
p')

fieldPat :: Name -> PatQ -> FieldPatQ
fieldPat :: Name -> PatQ -> FieldPatQ
fieldPat n :: Name
n p :: PatQ
p = do Pat
p' <- PatQ
p
                  FieldPat -> FieldPatQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name
n, Pat
p')


-------------------------------------------------------------------------------
-- *   Stmt

bindS :: PatQ -> ExpQ -> StmtQ
bindS :: PatQ -> ExpQ -> StmtQ
bindS p :: PatQ
p e :: ExpQ
e = (Pat -> Exp -> Stmt) -> PatQ -> ExpQ -> StmtQ
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Pat -> Exp -> Stmt
BindS PatQ
p ExpQ
e

letS :: [DecQ] -> StmtQ
letS :: [DecQ] -> StmtQ
letS ds :: [DecQ]
ds = do { [Dec]
ds1 <- [DecQ] -> Q [Dec]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [DecQ]
ds; Stmt -> StmtQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Dec] -> Stmt
LetS [Dec]
ds1) }

noBindS :: ExpQ -> StmtQ
noBindS :: ExpQ -> StmtQ
noBindS e :: ExpQ
e = do { Exp
e1 <- ExpQ
e; Stmt -> StmtQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Stmt
NoBindS Exp
e1) }

parS :: [[StmtQ]] -> StmtQ
parS :: [[StmtQ]] -> StmtQ
parS sss :: [[StmtQ]]
sss = do { [[Stmt]]
sss1 <- ([StmtQ] -> Q [Stmt]) -> [[StmtQ]] -> Q [[Stmt]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM [StmtQ] -> Q [Stmt]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [[StmtQ]]
sss; Stmt -> StmtQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([[Stmt]] -> Stmt
ParS [[Stmt]]
sss1) }

recS :: [StmtQ] -> StmtQ
recS :: [StmtQ] -> StmtQ
recS ss :: [StmtQ]
ss = do { [Stmt]
ss1 <- [StmtQ] -> Q [Stmt]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [StmtQ]
ss; Stmt -> StmtQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Stmt] -> Stmt
RecS [Stmt]
ss1) }

-------------------------------------------------------------------------------
-- *   Range

fromR :: ExpQ -> RangeQ
fromR :: ExpQ -> RangeQ
fromR x :: ExpQ
x = do { Exp
a <- ExpQ
x; Range -> RangeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Range
FromR Exp
a) }

fromThenR :: ExpQ -> ExpQ -> RangeQ
fromThenR :: ExpQ -> ExpQ -> RangeQ
fromThenR x :: ExpQ
x y :: ExpQ
y = do { Exp
a <- ExpQ
x; Exp
b <- ExpQ
y; Range -> RangeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Exp -> Range
FromThenR Exp
a Exp
b) }

fromToR :: ExpQ -> ExpQ -> RangeQ
fromToR :: ExpQ -> ExpQ -> RangeQ
fromToR x :: ExpQ
x y :: ExpQ
y = do { Exp
a <- ExpQ
x; Exp
b <- ExpQ
y; Range -> RangeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Exp -> Range
FromToR Exp
a Exp
b) }

fromThenToR :: ExpQ -> ExpQ -> ExpQ -> RangeQ
fromThenToR :: ExpQ -> ExpQ -> ExpQ -> RangeQ
fromThenToR x :: ExpQ
x y :: ExpQ
y z :: ExpQ
z = do { Exp
a <- ExpQ
x; Exp
b <- ExpQ
y; Exp
c <- ExpQ
z;
                         Range -> RangeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Exp -> Exp -> Range
FromThenToR Exp
a Exp
b Exp
c) }
-------------------------------------------------------------------------------
-- *   Body

normalB :: ExpQ -> BodyQ
normalB :: ExpQ -> BodyQ
normalB e :: ExpQ
e = do { Exp
e1 <- ExpQ
e; Body -> BodyQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Body
NormalB Exp
e1) }

guardedB :: [Q (Guard,Exp)] -> BodyQ
guardedB :: [Q (Guard, Exp)] -> BodyQ
guardedB ges :: [Q (Guard, Exp)]
ges = do { [(Guard, Exp)]
ges' <- [Q (Guard, Exp)] -> Q [(Guard, Exp)]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [Q (Guard, Exp)]
ges; Body -> BodyQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([(Guard, Exp)] -> Body
GuardedB [(Guard, Exp)]
ges') }

-------------------------------------------------------------------------------
-- *   Guard

normalG :: ExpQ -> GuardQ
normalG :: ExpQ -> GuardQ
normalG e :: ExpQ
e = do { Exp
e1 <- ExpQ
e; Guard -> GuardQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Guard
NormalG Exp
e1) }

normalGE :: ExpQ -> ExpQ -> Q (Guard, Exp)
normalGE :: ExpQ -> ExpQ -> Q (Guard, Exp)
normalGE g :: ExpQ
g e :: ExpQ
e = do { Exp
g1 <- ExpQ
g; Exp
e1 <- ExpQ
e; (Guard, Exp) -> Q (Guard, Exp)
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Guard
NormalG Exp
g1, Exp
e1) }

patG :: [StmtQ] -> GuardQ
patG :: [StmtQ] -> GuardQ
patG ss :: [StmtQ]
ss = do { [Stmt]
ss' <- [StmtQ] -> Q [Stmt]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [StmtQ]
ss; Guard -> GuardQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Stmt] -> Guard
PatG [Stmt]
ss') }

patGE :: [StmtQ] -> ExpQ -> Q (Guard, Exp)
patGE :: [StmtQ] -> ExpQ -> Q (Guard, Exp)
patGE ss :: [StmtQ]
ss e :: ExpQ
e = do { [Stmt]
ss' <- [StmtQ] -> Q [Stmt]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [StmtQ]
ss;
                  Exp
e'  <- ExpQ
e;
                  (Guard, Exp) -> Q (Guard, Exp)
forall (m :: * -> *) a. Monad m => a -> m a
return ([Stmt] -> Guard
PatG [Stmt]
ss', Exp
e') }

-------------------------------------------------------------------------------
-- *   Match and Clause

-- | Use with 'caseE'
match :: PatQ -> BodyQ -> [DecQ] -> MatchQ
match :: PatQ -> BodyQ -> [DecQ] -> MatchQ
match p :: PatQ
p rhs :: BodyQ
rhs ds :: [DecQ]
ds = do { Pat
p' <- PatQ
p;
                      Body
r' <- BodyQ
rhs;
                      [Dec]
ds' <- [DecQ] -> Q [Dec]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [DecQ]
ds;
                      Match -> MatchQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat -> Body -> [Dec] -> Match
Match Pat
p' Body
r' [Dec]
ds') }

-- | Use with 'funD'
clause :: [PatQ] -> BodyQ -> [DecQ] -> ClauseQ
clause :: [PatQ] -> BodyQ -> [DecQ] -> ClauseQ
clause ps :: [PatQ]
ps r :: BodyQ
r ds :: [DecQ]
ds = do { [Pat]
ps' <- [PatQ] -> Q [Pat]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [PatQ]
ps;
                      Body
r' <- BodyQ
r;
                      [Dec]
ds' <- [DecQ] -> Q [Dec]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [DecQ]
ds;
                      Clause -> ClauseQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Pat] -> Body -> [Dec] -> Clause
Clause [Pat]
ps' Body
r' [Dec]
ds') }


---------------------------------------------------------------------------
-- *   Exp

-- | Dynamically binding a variable (unhygenic)
dyn :: String -> ExpQ
dyn :: String -> ExpQ
dyn s :: String
s = Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> Exp
VarE (String -> Name
mkName String
s))

varE :: Name -> ExpQ
varE :: Name -> ExpQ
varE s :: Name
s = Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> Exp
VarE Name
s)

conE :: Name -> ExpQ
conE :: Name -> ExpQ
conE s :: Name
s =  Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> Exp
ConE Name
s)

litE :: Lit -> ExpQ
litE :: Lit -> ExpQ
litE c :: Lit
c = Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Lit -> Exp
LitE Lit
c)

appE :: ExpQ -> ExpQ -> ExpQ
appE :: ExpQ -> ExpQ -> ExpQ
appE x :: ExpQ
x y :: ExpQ
y = do { Exp
a <- ExpQ
x; Exp
b <- ExpQ
y; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Exp -> Exp
AppE Exp
a Exp
b)}

appTypeE :: ExpQ -> TypeQ -> ExpQ
appTypeE :: ExpQ -> TypeQ -> ExpQ
appTypeE x :: ExpQ
x t :: TypeQ
t = do { Exp
a <- ExpQ
x; Type
s <- TypeQ
t; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Type -> Exp
AppTypeE Exp
a Type
s) }

parensE :: ExpQ -> ExpQ
parensE :: ExpQ -> ExpQ
parensE x :: ExpQ
x = do { Exp
x' <- ExpQ
x; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Exp
ParensE Exp
x') }

uInfixE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
uInfixE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
uInfixE x :: ExpQ
x s :: ExpQ
s y :: ExpQ
y = do { Exp
x' <- ExpQ
x; Exp
s' <- ExpQ
s; Exp
y' <- ExpQ
y;
                     Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Exp -> Exp -> Exp
UInfixE Exp
x' Exp
s' Exp
y') }

infixE :: Maybe ExpQ -> ExpQ -> Maybe ExpQ -> ExpQ
infixE :: Maybe ExpQ -> ExpQ -> Maybe ExpQ -> ExpQ
infixE (Just x :: ExpQ
x) s :: ExpQ
s (Just y :: ExpQ
y) = do { Exp
a <- ExpQ
x; Exp
s' <- ExpQ
s; Exp
b <- ExpQ
y;
                                  Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Exp -> Exp -> Maybe Exp -> Exp
InfixE (Exp -> Maybe Exp
forall a. a -> Maybe a
Just Exp
a) Exp
s' (Exp -> Maybe Exp
forall a. a -> Maybe a
Just Exp
b))}
infixE Nothing  s :: ExpQ
s (Just y :: ExpQ
y) = do { Exp
s' <- ExpQ
s; Exp
b <- ExpQ
y;
                                  Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Exp -> Exp -> Maybe Exp -> Exp
InfixE Maybe Exp
forall a. Maybe a
Nothing Exp
s' (Exp -> Maybe Exp
forall a. a -> Maybe a
Just Exp
b))}
infixE (Just x :: ExpQ
x) s :: ExpQ
s Nothing  = do { Exp
a <- ExpQ
x; Exp
s' <- ExpQ
s;
                                  Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Exp -> Exp -> Maybe Exp -> Exp
InfixE (Exp -> Maybe Exp
forall a. a -> Maybe a
Just Exp
a) Exp
s' Maybe Exp
forall a. Maybe a
Nothing)}
infixE Nothing  s :: ExpQ
s Nothing  = do { Exp
s' <- ExpQ
s; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Exp -> Exp -> Maybe Exp -> Exp
InfixE Maybe Exp
forall a. Maybe a
Nothing Exp
s' Maybe Exp
forall a. Maybe a
Nothing) }

infixApp :: ExpQ -> ExpQ -> ExpQ -> ExpQ
infixApp :: ExpQ -> ExpQ -> ExpQ -> ExpQ
infixApp x :: ExpQ
x y :: ExpQ
y z :: ExpQ
z = Maybe ExpQ -> ExpQ -> Maybe ExpQ -> ExpQ
infixE (ExpQ -> Maybe ExpQ
forall a. a -> Maybe a
Just ExpQ
x) ExpQ
y (ExpQ -> Maybe ExpQ
forall a. a -> Maybe a
Just ExpQ
z)
sectionL :: ExpQ -> ExpQ -> ExpQ
sectionL :: ExpQ -> ExpQ -> ExpQ
sectionL x :: ExpQ
x y :: ExpQ
y = Maybe ExpQ -> ExpQ -> Maybe ExpQ -> ExpQ
infixE (ExpQ -> Maybe ExpQ
forall a. a -> Maybe a
Just ExpQ
x) ExpQ
y Maybe ExpQ
forall a. Maybe a
Nothing
sectionR :: ExpQ -> ExpQ -> ExpQ
sectionR :: ExpQ -> ExpQ -> ExpQ
sectionR x :: ExpQ
x y :: ExpQ
y = Maybe ExpQ -> ExpQ -> Maybe ExpQ -> ExpQ
infixE Maybe ExpQ
forall a. Maybe a
Nothing ExpQ
x (ExpQ -> Maybe ExpQ
forall a. a -> Maybe a
Just ExpQ
y)

lamE :: [PatQ] -> ExpQ -> ExpQ
lamE :: [PatQ] -> ExpQ -> ExpQ
lamE ps :: [PatQ]
ps e :: ExpQ
e = do [Pat]
ps' <- [PatQ] -> Q [Pat]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [PatQ]
ps
               Exp
e' <- ExpQ
e
               Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Pat] -> Exp -> Exp
LamE [Pat]
ps' Exp
e')

-- | Single-arg lambda
lam1E :: PatQ -> ExpQ -> ExpQ
lam1E :: PatQ -> ExpQ -> ExpQ
lam1E p :: PatQ
p e :: ExpQ
e = [PatQ] -> ExpQ -> ExpQ
lamE [PatQ
p] ExpQ
e

lamCaseE :: [MatchQ] -> ExpQ
lamCaseE :: [MatchQ] -> ExpQ
lamCaseE ms :: [MatchQ]
ms = [MatchQ] -> Q [Match]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [MatchQ]
ms Q [Match] -> ([Match] -> ExpQ) -> ExpQ
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> ExpQ) -> ([Match] -> Exp) -> [Match] -> ExpQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Match] -> Exp
LamCaseE

tupE :: [ExpQ] -> ExpQ
tupE :: [ExpQ] -> ExpQ
tupE es :: [ExpQ]
es = do { [Exp]
es1 <- [ExpQ] -> Q [Exp]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [ExpQ]
es; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Exp] -> Exp
TupE [Exp]
es1)}

unboxedTupE :: [ExpQ] -> ExpQ
unboxedTupE :: [ExpQ] -> ExpQ
unboxedTupE es :: [ExpQ]
es = do { [Exp]
es1 <- [ExpQ] -> Q [Exp]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [ExpQ]
es; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Exp] -> Exp
UnboxedTupE [Exp]
es1)}

unboxedSumE :: ExpQ -> SumAlt -> SumArity -> ExpQ
unboxedSumE :: ExpQ -> SumAlt -> SumAlt -> ExpQ
unboxedSumE e :: ExpQ
e alt :: SumAlt
alt arity :: SumAlt
arity = do { Exp
e1 <- ExpQ
e; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> SumAlt -> SumAlt -> Exp
UnboxedSumE Exp
e1 SumAlt
alt SumAlt
arity) }

condE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
condE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
condE x :: ExpQ
x y :: ExpQ
y z :: ExpQ
z =  do { Exp
a <- ExpQ
x; Exp
b <- ExpQ
y; Exp
c <- ExpQ
z; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Exp -> Exp -> Exp
CondE Exp
a Exp
b Exp
c)}

multiIfE :: [Q (Guard, Exp)] -> ExpQ
multiIfE :: [Q (Guard, Exp)] -> ExpQ
multiIfE alts :: [Q (Guard, Exp)]
alts = [Q (Guard, Exp)] -> Q [(Guard, Exp)]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [Q (Guard, Exp)]
alts Q [(Guard, Exp)] -> ([(Guard, Exp)] -> ExpQ) -> ExpQ
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> ExpQ) -> ([(Guard, Exp)] -> Exp) -> [(Guard, Exp)] -> ExpQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Guard, Exp)] -> Exp
MultiIfE

letE :: [DecQ] -> ExpQ -> ExpQ
letE :: [DecQ] -> ExpQ -> ExpQ
letE ds :: [DecQ]
ds e :: ExpQ
e = do { [Dec]
ds2 <- [DecQ] -> Q [Dec]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [DecQ]
ds; Exp
e2 <- ExpQ
e; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Dec] -> Exp -> Exp
LetE [Dec]
ds2 Exp
e2) }

caseE :: ExpQ -> [MatchQ] -> ExpQ
caseE :: ExpQ -> [MatchQ] -> ExpQ
caseE e :: ExpQ
e ms :: [MatchQ]
ms = do { Exp
e1 <- ExpQ
e; [Match]
ms1 <- [MatchQ] -> Q [Match]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [MatchQ]
ms; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> [Match] -> Exp
CaseE Exp
e1 [Match]
ms1) }

doE :: [StmtQ] -> ExpQ
doE :: [StmtQ] -> ExpQ
doE ss :: [StmtQ]
ss = do { [Stmt]
ss1 <- [StmtQ] -> Q [Stmt]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [StmtQ]
ss; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Stmt] -> Exp
DoE [Stmt]
ss1) }

mdoE :: [StmtQ] -> ExpQ
mdoE :: [StmtQ] -> ExpQ
mdoE ss :: [StmtQ]
ss = do { [Stmt]
ss1 <- [StmtQ] -> Q [Stmt]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [StmtQ]
ss; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Stmt] -> Exp
MDoE [Stmt]
ss1) }

compE :: [StmtQ] -> ExpQ
compE :: [StmtQ] -> ExpQ
compE ss :: [StmtQ]
ss = do { [Stmt]
ss1 <- [StmtQ] -> Q [Stmt]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [StmtQ]
ss; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Stmt] -> Exp
CompE [Stmt]
ss1) }

arithSeqE :: RangeQ -> ExpQ
arithSeqE :: RangeQ -> ExpQ
arithSeqE r :: RangeQ
r = do { Range
r' <- RangeQ
r; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Range -> Exp
ArithSeqE Range
r') }

listE :: [ExpQ] -> ExpQ
listE :: [ExpQ] -> ExpQ
listE es :: [ExpQ]
es = do { [Exp]
es1 <- [ExpQ] -> Q [Exp]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [ExpQ]
es; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Exp] -> Exp
ListE [Exp]
es1) }

sigE :: ExpQ -> TypeQ -> ExpQ
sigE :: ExpQ -> TypeQ -> ExpQ
sigE e :: ExpQ
e t :: TypeQ
t = do { Exp
e1 <- ExpQ
e; Type
t1 <- TypeQ
t; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Type -> Exp
SigE Exp
e1 Type
t1) }

recConE :: Name -> [Q (Name,Exp)] -> ExpQ
recConE :: Name -> [Q (Name, Exp)] -> ExpQ
recConE c :: Name
c fs :: [Q (Name, Exp)]
fs = do { [(Name, Exp)]
flds <- [Q (Name, Exp)] -> Q [(Name, Exp)]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [Q (Name, Exp)]
fs; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> [(Name, Exp)] -> Exp
RecConE Name
c [(Name, Exp)]
flds) }

recUpdE :: ExpQ -> [Q (Name,Exp)] -> ExpQ
recUpdE :: ExpQ -> [Q (Name, Exp)] -> ExpQ
recUpdE e :: ExpQ
e fs :: [Q (Name, Exp)]
fs = do { Exp
e1 <- ExpQ
e; [(Name, Exp)]
flds <- [Q (Name, Exp)] -> Q [(Name, Exp)]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [Q (Name, Exp)]
fs; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> [(Name, Exp)] -> Exp
RecUpdE Exp
e1 [(Name, Exp)]
flds) }

stringE :: String -> ExpQ
stringE :: String -> ExpQ
stringE = Lit -> ExpQ
litE (Lit -> ExpQ) -> (String -> Lit) -> String -> ExpQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Lit
stringL

fieldExp :: Name -> ExpQ -> Q (Name, Exp)
fieldExp :: Name -> ExpQ -> Q (Name, Exp)
fieldExp s :: Name
s e :: ExpQ
e = do { Exp
e' <- ExpQ
e; (Name, Exp) -> Q (Name, Exp)
forall (m :: * -> *) a. Monad m => a -> m a
return (Name
s,Exp
e') }

-- | @staticE x = [| static x |]@
staticE :: ExpQ -> ExpQ
staticE :: ExpQ -> ExpQ
staticE = (Exp -> Exp) -> ExpQ -> ExpQ
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Exp -> Exp
StaticE

unboundVarE :: Name -> ExpQ
unboundVarE :: Name -> ExpQ
unboundVarE s :: Name
s = Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> Exp
UnboundVarE Name
s)

labelE :: String -> ExpQ
labelE :: String -> ExpQ
labelE s :: String
s = Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Exp
LabelE String
s)

implicitParamVarE :: String -> ExpQ
implicitParamVarE :: String -> ExpQ
implicitParamVarE n :: String
n = Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Exp
ImplicitParamVarE String
n)

-- ** 'arithSeqE' Shortcuts
fromE :: ExpQ -> ExpQ
fromE :: ExpQ -> ExpQ
fromE x :: ExpQ
x = do { Exp
a <- ExpQ
x; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Range -> Exp
ArithSeqE (Exp -> Range
FromR Exp
a)) }

fromThenE :: ExpQ -> ExpQ -> ExpQ
fromThenE :: ExpQ -> ExpQ -> ExpQ
fromThenE x :: ExpQ
x y :: ExpQ
y = do { Exp
a <- ExpQ
x; Exp
b <- ExpQ
y; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Range -> Exp
ArithSeqE (Exp -> Exp -> Range
FromThenR Exp
a Exp
b)) }

fromToE :: ExpQ -> ExpQ -> ExpQ
fromToE :: ExpQ -> ExpQ -> ExpQ
fromToE x :: ExpQ
x y :: ExpQ
y = do { Exp
a <- ExpQ
x; Exp
b <- ExpQ
y; Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Range -> Exp
ArithSeqE (Exp -> Exp -> Range
FromToR Exp
a Exp
b)) }

fromThenToE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
fromThenToE :: ExpQ -> ExpQ -> ExpQ -> ExpQ
fromThenToE x :: ExpQ
x y :: ExpQ
y z :: ExpQ
z = do { Exp
a <- ExpQ
x; Exp
b <- ExpQ
y; Exp
c <- ExpQ
z;
                         Exp -> ExpQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Range -> Exp
ArithSeqE (Exp -> Exp -> Exp -> Range
FromThenToR Exp
a Exp
b Exp
c)) }


-------------------------------------------------------------------------------
-- *   Dec

valD :: PatQ -> BodyQ -> [DecQ] -> DecQ
valD :: PatQ -> BodyQ -> [DecQ] -> DecQ
valD p :: PatQ
p b :: BodyQ
b ds :: [DecQ]
ds =
  do { Pat
p' <- PatQ
p
     ; [Dec]
ds' <- [DecQ] -> Q [Dec]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [DecQ]
ds
     ; Body
b' <- BodyQ
b
     ; Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat -> Body -> [Dec] -> Dec
ValD Pat
p' Body
b' [Dec]
ds')
     }

funD :: Name -> [ClauseQ] -> DecQ
funD :: Name -> [ClauseQ] -> DecQ
funD nm :: Name
nm cs :: [ClauseQ]
cs =
 do { [Clause]
cs1 <- [ClauseQ] -> Q [Clause]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [ClauseQ]
cs
    ; Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> [Clause] -> Dec
FunD Name
nm [Clause]
cs1)
    }

tySynD :: Name -> [TyVarBndrQ] -> TypeQ -> DecQ
tySynD :: Name -> [TyVarBndrQ] -> TypeQ -> DecQ
tySynD tc :: Name
tc tvs :: [TyVarBndrQ]
tvs rhs :: TypeQ
rhs =
  do { [TyVarBndr]
tvs1 <- [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TyVarBndrQ]
tvs
     ; Type
rhs1 <- TypeQ
rhs
     ; Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> [TyVarBndr] -> Type -> Dec
TySynD Name
tc [TyVarBndr]
tvs1 Type
rhs1)
     }

dataD :: CxtQ -> Name -> [TyVarBndrQ] -> Maybe KindQ -> [ConQ]
      -> [DerivClauseQ] -> DecQ
dataD :: CxtQ
-> Name
-> [TyVarBndrQ]
-> Maybe TypeQ
-> [ConQ]
-> [DerivClauseQ]
-> DecQ
dataD ctxt :: CxtQ
ctxt tc :: Name
tc tvs :: [TyVarBndrQ]
tvs ksig :: Maybe TypeQ
ksig cons :: [ConQ]
cons derivs :: [DerivClauseQ]
derivs =
  do
    Cxt
ctxt1   <- CxtQ
ctxt
    [TyVarBndr]
tvs1    <- [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TyVarBndrQ]
tvs
    Maybe Type
ksig1   <- Maybe TypeQ -> Q (Maybe Type)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA Maybe TypeQ
ksig
    [Con]
cons1   <- [ConQ] -> Q [Con]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [ConQ]
cons
    [DerivClause]
derivs1 <- [DerivClauseQ] -> Q [DerivClause]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [DerivClauseQ]
derivs
    Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Cxt
-> Name
-> [TyVarBndr]
-> Maybe Type
-> [Con]
-> [DerivClause]
-> Dec
DataD Cxt
ctxt1 Name
tc [TyVarBndr]
tvs1 Maybe Type
ksig1 [Con]
cons1 [DerivClause]
derivs1)

newtypeD :: CxtQ -> Name -> [TyVarBndrQ] -> Maybe KindQ -> ConQ
         -> [DerivClauseQ] -> DecQ
newtypeD :: CxtQ
-> Name
-> [TyVarBndrQ]
-> Maybe TypeQ
-> ConQ
-> [DerivClauseQ]
-> DecQ
newtypeD ctxt :: CxtQ
ctxt tc :: Name
tc tvs :: [TyVarBndrQ]
tvs ksig :: Maybe TypeQ
ksig con :: ConQ
con derivs :: [DerivClauseQ]
derivs =
  do
    Cxt
ctxt1   <- CxtQ
ctxt
    [TyVarBndr]
tvs1    <- [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TyVarBndrQ]
tvs
    Maybe Type
ksig1   <- Maybe TypeQ -> Q (Maybe Type)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA Maybe TypeQ
ksig
    Con
con1    <- ConQ
con
    [DerivClause]
derivs1 <- [DerivClauseQ] -> Q [DerivClause]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [DerivClauseQ]
derivs
    Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Cxt
-> Name -> [TyVarBndr] -> Maybe Type -> Con -> [DerivClause] -> Dec
NewtypeD Cxt
ctxt1 Name
tc [TyVarBndr]
tvs1 Maybe Type
ksig1 Con
con1 [DerivClause]
derivs1)

classD :: CxtQ -> Name -> [TyVarBndrQ] -> [FunDep] -> [DecQ] -> DecQ
classD :: CxtQ -> Name -> [TyVarBndrQ] -> [FunDep] -> [DecQ] -> DecQ
classD ctxt :: CxtQ
ctxt cls :: Name
cls tvs :: [TyVarBndrQ]
tvs fds :: [FunDep]
fds decs :: [DecQ]
decs =
  do
    [TyVarBndr]
tvs1  <- [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TyVarBndrQ]
tvs
    [Dec]
decs1 <- [DecQ] -> Q [Dec]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [DecQ]
decs
    Cxt
ctxt1 <- CxtQ
ctxt
    Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Cxt -> Name -> [TyVarBndr] -> [FunDep] -> [Dec] -> Dec
ClassD Cxt
ctxt1 Name
cls [TyVarBndr]
tvs1 [FunDep]
fds [Dec]
decs1

instanceD :: CxtQ -> TypeQ -> [DecQ] -> DecQ
instanceD :: CxtQ -> TypeQ -> [DecQ] -> DecQ
instanceD = Maybe Overlap -> CxtQ -> TypeQ -> [DecQ] -> DecQ
instanceWithOverlapD Maybe Overlap
forall a. Maybe a
Nothing

instanceWithOverlapD :: Maybe Overlap -> CxtQ -> TypeQ -> [DecQ] -> DecQ
instanceWithOverlapD :: Maybe Overlap -> CxtQ -> TypeQ -> [DecQ] -> DecQ
instanceWithOverlapD o :: Maybe Overlap
o ctxt :: CxtQ
ctxt ty :: TypeQ
ty decs :: [DecQ]
decs =
  do
    Cxt
ctxt1 <- CxtQ
ctxt
    [Dec]
decs1 <- [DecQ] -> Q [Dec]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [DecQ]
decs
    Type
ty1   <- TypeQ
ty
    Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Maybe Overlap -> Cxt -> Type -> [Dec] -> Dec
InstanceD Maybe Overlap
o Cxt
ctxt1 Type
ty1 [Dec]
decs1



sigD :: Name -> TypeQ -> DecQ
sigD :: Name -> TypeQ -> DecQ
sigD fun :: Name
fun ty :: TypeQ
ty = (Type -> Dec) -> TypeQ -> DecQ
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Name -> Type -> Dec
SigD Name
fun) (TypeQ -> DecQ) -> TypeQ -> DecQ
forall a b. (a -> b) -> a -> b
$ TypeQ
ty

forImpD :: Callconv -> Safety -> String -> Name -> TypeQ -> DecQ
forImpD :: Callconv -> Safety -> String -> Name -> TypeQ -> DecQ
forImpD cc :: Callconv
cc s :: Safety
s str :: String
str n :: Name
n ty :: TypeQ
ty
 = do Type
ty' <- TypeQ
ty
      Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Foreign -> Dec
ForeignD (Callconv -> Safety -> String -> Name -> Type -> Foreign
ImportF Callconv
cc Safety
s String
str Name
n Type
ty')

infixLD :: Int -> Name -> DecQ
infixLD :: SumAlt -> Name -> DecQ
infixLD prec :: SumAlt
prec nm :: Name
nm = Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Fixity -> Name -> Dec
InfixD (SumAlt -> FixityDirection -> Fixity
Fixity SumAlt
prec FixityDirection
InfixL) Name
nm)

infixRD :: Int -> Name -> DecQ
infixRD :: SumAlt -> Name -> DecQ
infixRD prec :: SumAlt
prec nm :: Name
nm = Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Fixity -> Name -> Dec
InfixD (SumAlt -> FixityDirection -> Fixity
Fixity SumAlt
prec FixityDirection
InfixR) Name
nm)

infixND :: Int -> Name -> DecQ
infixND :: SumAlt -> Name -> DecQ
infixND prec :: SumAlt
prec nm :: Name
nm = Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Fixity -> Name -> Dec
InfixD (SumAlt -> FixityDirection -> Fixity
Fixity SumAlt
prec FixityDirection
InfixN) Name
nm)

pragInlD :: Name -> Inline -> RuleMatch -> Phases -> DecQ
pragInlD :: Name -> Inline -> RuleMatch -> Phases -> DecQ
pragInlD name :: Name
name inline :: Inline
inline rm :: RuleMatch
rm phases :: Phases
phases
  = Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Pragma -> Dec
PragmaD (Pragma -> Dec) -> Pragma -> Dec
forall a b. (a -> b) -> a -> b
$ Name -> Inline -> RuleMatch -> Phases -> Pragma
InlineP Name
name Inline
inline RuleMatch
rm Phases
phases

pragSpecD :: Name -> TypeQ -> Phases -> DecQ
pragSpecD :: Name -> TypeQ -> Phases -> DecQ
pragSpecD n :: Name
n ty :: TypeQ
ty phases :: Phases
phases
  = do
      Type
ty1    <- TypeQ
ty
      Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Pragma -> Dec
PragmaD (Pragma -> Dec) -> Pragma -> Dec
forall a b. (a -> b) -> a -> b
$ Name -> Type -> Maybe Inline -> Phases -> Pragma
SpecialiseP Name
n Type
ty1 Maybe Inline
forall a. Maybe a
Nothing Phases
phases

pragSpecInlD :: Name -> TypeQ -> Inline -> Phases -> DecQ
pragSpecInlD :: Name -> TypeQ -> Inline -> Phases -> DecQ
pragSpecInlD n :: Name
n ty :: TypeQ
ty inline :: Inline
inline phases :: Phases
phases
  = do
      Type
ty1    <- TypeQ
ty
      Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Pragma -> Dec
PragmaD (Pragma -> Dec) -> Pragma -> Dec
forall a b. (a -> b) -> a -> b
$ Name -> Type -> Maybe Inline -> Phases -> Pragma
SpecialiseP Name
n Type
ty1 (Inline -> Maybe Inline
forall a. a -> Maybe a
Just Inline
inline) Phases
phases

pragSpecInstD :: TypeQ -> DecQ
pragSpecInstD :: TypeQ -> DecQ
pragSpecInstD ty :: TypeQ
ty
  = do
      Type
ty1    <- TypeQ
ty
      Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Pragma -> Dec
PragmaD (Pragma -> Dec) -> Pragma -> Dec
forall a b. (a -> b) -> a -> b
$ Type -> Pragma
SpecialiseInstP Type
ty1

pragRuleD :: String -> Maybe [TyVarBndrQ] -> [RuleBndrQ] -> ExpQ -> ExpQ
          -> Phases -> DecQ
pragRuleD :: String
-> Maybe [TyVarBndrQ]
-> [RuleBndrQ]
-> ExpQ
-> ExpQ
-> Phases
-> DecQ
pragRuleD n :: String
n ty_bndrs :: Maybe [TyVarBndrQ]
ty_bndrs tm_bndrs :: [RuleBndrQ]
tm_bndrs lhs :: ExpQ
lhs rhs :: ExpQ
rhs phases :: Phases
phases
  = do
      Maybe [TyVarBndr]
ty_bndrs1 <- ([TyVarBndrQ] -> Q [TyVarBndr])
-> Maybe [TyVarBndrQ] -> Q (Maybe [TyVarBndr])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence Maybe [TyVarBndrQ]
ty_bndrs
      [RuleBndr]
tm_bndrs1 <- [RuleBndrQ] -> Q [RuleBndr]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [RuleBndrQ]
tm_bndrs
      Exp
lhs1   <- ExpQ
lhs
      Exp
rhs1   <- ExpQ
rhs
      Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Pragma -> Dec
PragmaD (Pragma -> Dec) -> Pragma -> Dec
forall a b. (a -> b) -> a -> b
$ String
-> Maybe [TyVarBndr]
-> [RuleBndr]
-> Exp
-> Exp
-> Phases
-> Pragma
RuleP String
n Maybe [TyVarBndr]
ty_bndrs1 [RuleBndr]
tm_bndrs1 Exp
lhs1 Exp
rhs1 Phases
phases

pragAnnD :: AnnTarget -> ExpQ -> DecQ
pragAnnD :: AnnTarget -> ExpQ -> DecQ
pragAnnD target :: AnnTarget
target expr :: ExpQ
expr
  = do
      Exp
exp1 <- ExpQ
expr
      Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Pragma -> Dec
PragmaD (Pragma -> Dec) -> Pragma -> Dec
forall a b. (a -> b) -> a -> b
$ AnnTarget -> Exp -> Pragma
AnnP AnnTarget
target Exp
exp1

pragLineD :: Int -> String -> DecQ
pragLineD :: SumAlt -> String -> DecQ
pragLineD line :: SumAlt
line file :: String
file = Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Pragma -> Dec
PragmaD (Pragma -> Dec) -> Pragma -> Dec
forall a b. (a -> b) -> a -> b
$ SumAlt -> String -> Pragma
LineP SumAlt
line String
file

pragCompleteD :: [Name] -> Maybe Name -> DecQ
pragCompleteD :: [Name] -> Maybe Name -> DecQ
pragCompleteD cls :: [Name]
cls mty :: Maybe Name
mty = Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Pragma -> Dec
PragmaD (Pragma -> Dec) -> Pragma -> Dec
forall a b. (a -> b) -> a -> b
$ [Name] -> Maybe Name -> Pragma
CompleteP [Name]
cls Maybe Name
mty

dataInstD :: CxtQ -> (Maybe [TyVarBndrQ]) -> TypeQ -> Maybe KindQ -> [ConQ]
          -> [DerivClauseQ] -> DecQ
dataInstD :: CxtQ
-> Maybe [TyVarBndrQ]
-> TypeQ
-> Maybe TypeQ
-> [ConQ]
-> [DerivClauseQ]
-> DecQ
dataInstD ctxt :: CxtQ
ctxt mb_bndrs :: Maybe [TyVarBndrQ]
mb_bndrs ty :: TypeQ
ty ksig :: Maybe TypeQ
ksig cons :: [ConQ]
cons derivs :: [DerivClauseQ]
derivs =
  do
    Cxt
ctxt1   <- CxtQ
ctxt
    Maybe [TyVarBndr]
mb_bndrs1 <- ([TyVarBndrQ] -> Q [TyVarBndr])
-> Maybe [TyVarBndrQ] -> Q (Maybe [TyVarBndr])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence Maybe [TyVarBndrQ]
mb_bndrs
    Type
ty1    <- TypeQ
ty
    Maybe Type
ksig1   <- Maybe TypeQ -> Q (Maybe Type)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA Maybe TypeQ
ksig
    [Con]
cons1   <- [ConQ] -> Q [Con]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [ConQ]
cons
    [DerivClause]
derivs1 <- [DerivClauseQ] -> Q [DerivClause]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [DerivClauseQ]
derivs
    Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Cxt
-> Maybe [TyVarBndr]
-> Type
-> Maybe Type
-> [Con]
-> [DerivClause]
-> Dec
DataInstD Cxt
ctxt1 Maybe [TyVarBndr]
mb_bndrs1 Type
ty1 Maybe Type
ksig1 [Con]
cons1 [DerivClause]
derivs1)

newtypeInstD :: CxtQ -> (Maybe [TyVarBndrQ]) -> TypeQ -> Maybe KindQ -> ConQ
             -> [DerivClauseQ] -> DecQ
newtypeInstD :: CxtQ
-> Maybe [TyVarBndrQ]
-> TypeQ
-> Maybe TypeQ
-> ConQ
-> [DerivClauseQ]
-> DecQ
newtypeInstD ctxt :: CxtQ
ctxt mb_bndrs :: Maybe [TyVarBndrQ]
mb_bndrs ty :: TypeQ
ty ksig :: Maybe TypeQ
ksig con :: ConQ
con derivs :: [DerivClauseQ]
derivs =
  do
    Cxt
ctxt1   <- CxtQ
ctxt
    Maybe [TyVarBndr]
mb_bndrs1 <- ([TyVarBndrQ] -> Q [TyVarBndr])
-> Maybe [TyVarBndrQ] -> Q (Maybe [TyVarBndr])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence Maybe [TyVarBndrQ]
mb_bndrs
    Type
ty1    <- TypeQ
ty
    Maybe Type
ksig1   <- Maybe TypeQ -> Q (Maybe Type)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA Maybe TypeQ
ksig
    Con
con1    <- ConQ
con
    [DerivClause]
derivs1 <- [DerivClauseQ] -> Q [DerivClause]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [DerivClauseQ]
derivs
    Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Cxt
-> Maybe [TyVarBndr]
-> Type
-> Maybe Type
-> Con
-> [DerivClause]
-> Dec
NewtypeInstD Cxt
ctxt1 Maybe [TyVarBndr]
mb_bndrs1 Type
ty1 Maybe Type
ksig1 Con
con1 [DerivClause]
derivs1)

tySynInstD :: TySynEqnQ -> DecQ
tySynInstD :: TySynEqnQ -> DecQ
tySynInstD eqn :: TySynEqnQ
eqn =
  do
    TySynEqn
eqn1 <- TySynEqnQ
eqn
    Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (TySynEqn -> Dec
TySynInstD TySynEqn
eqn1)

dataFamilyD :: Name -> [TyVarBndrQ] -> Maybe KindQ -> DecQ
dataFamilyD :: Name -> [TyVarBndrQ] -> Maybe TypeQ -> DecQ
dataFamilyD tc :: Name
tc tvs :: [TyVarBndrQ]
tvs kind :: Maybe TypeQ
kind =
  do [TyVarBndr]
tvs'  <- [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TyVarBndrQ]
tvs
     Maybe Type
kind' <- Maybe TypeQ -> Q (Maybe Type)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA Maybe TypeQ
kind
     Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Name -> [TyVarBndr] -> Maybe Type -> Dec
DataFamilyD Name
tc [TyVarBndr]
tvs' Maybe Type
kind'

openTypeFamilyD :: Name -> [TyVarBndrQ] -> FamilyResultSigQ
                -> Maybe InjectivityAnn -> DecQ
openTypeFamilyD :: Name
-> [TyVarBndrQ] -> FamilyResultSigQ -> Maybe InjectivityAnn -> DecQ
openTypeFamilyD tc :: Name
tc tvs :: [TyVarBndrQ]
tvs res :: FamilyResultSigQ
res inj :: Maybe InjectivityAnn
inj =
  do [TyVarBndr]
tvs' <- [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TyVarBndrQ]
tvs
     FamilyResultSig
res' <- FamilyResultSigQ
res
     Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ TypeFamilyHead -> Dec
OpenTypeFamilyD (Name
-> [TyVarBndr]
-> FamilyResultSig
-> Maybe InjectivityAnn
-> TypeFamilyHead
TypeFamilyHead Name
tc [TyVarBndr]
tvs' FamilyResultSig
res' Maybe InjectivityAnn
inj)

closedTypeFamilyD :: Name -> [TyVarBndrQ] -> FamilyResultSigQ
                  -> Maybe InjectivityAnn -> [TySynEqnQ] -> DecQ
closedTypeFamilyD :: Name
-> [TyVarBndrQ]
-> FamilyResultSigQ
-> Maybe InjectivityAnn
-> [TySynEqnQ]
-> DecQ
closedTypeFamilyD tc :: Name
tc tvs :: [TyVarBndrQ]
tvs result :: FamilyResultSigQ
result injectivity :: Maybe InjectivityAnn
injectivity eqns :: [TySynEqnQ]
eqns =
  do [TyVarBndr]
tvs1    <- [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TyVarBndrQ]
tvs
     FamilyResultSig
result1 <- FamilyResultSigQ
result
     [TySynEqn]
eqns1   <- [TySynEqnQ] -> Q [TySynEqn]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TySynEqnQ]
eqns
     Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (TypeFamilyHead -> [TySynEqn] -> Dec
ClosedTypeFamilyD (Name
-> [TyVarBndr]
-> FamilyResultSig
-> Maybe InjectivityAnn
-> TypeFamilyHead
TypeFamilyHead Name
tc [TyVarBndr]
tvs1 FamilyResultSig
result1 Maybe InjectivityAnn
injectivity) [TySynEqn]
eqns1)

roleAnnotD :: Name -> [Role] -> DecQ
roleAnnotD :: Name -> [Role] -> DecQ
roleAnnotD name :: Name
name roles :: [Role]
roles = Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Name -> [Role] -> Dec
RoleAnnotD Name
name [Role]
roles

standaloneDerivD :: CxtQ -> TypeQ -> DecQ
standaloneDerivD :: CxtQ -> TypeQ -> DecQ
standaloneDerivD = Maybe DerivStrategyQ -> CxtQ -> TypeQ -> DecQ
standaloneDerivWithStrategyD Maybe DerivStrategyQ
forall a. Maybe a
Nothing

standaloneDerivWithStrategyD :: Maybe DerivStrategyQ -> CxtQ -> TypeQ -> DecQ
standaloneDerivWithStrategyD :: Maybe DerivStrategyQ -> CxtQ -> TypeQ -> DecQ
standaloneDerivWithStrategyD mdsq :: Maybe DerivStrategyQ
mdsq ctxtq :: CxtQ
ctxtq tyq :: TypeQ
tyq =
  do
    Maybe DerivStrategy
mds  <- Maybe DerivStrategyQ -> Q (Maybe DerivStrategy)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA Maybe DerivStrategyQ
mdsq
    Cxt
ctxt <- CxtQ
ctxtq
    Type
ty   <- TypeQ
tyq
    Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Maybe DerivStrategy -> Cxt -> Type -> Dec
StandaloneDerivD Maybe DerivStrategy
mds Cxt
ctxt Type
ty

defaultSigD :: Name -> TypeQ -> DecQ
defaultSigD :: Name -> TypeQ -> DecQ
defaultSigD n :: Name
n tyq :: TypeQ
tyq =
  do
    Type
ty <- TypeQ
tyq
    Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Name -> Type -> Dec
DefaultSigD Name
n Type
ty

-- | Pattern synonym declaration
patSynD :: Name -> PatSynArgsQ -> PatSynDirQ -> PatQ -> DecQ
patSynD :: Name -> PatSynArgsQ -> PatSynDirQ -> PatQ -> DecQ
patSynD name :: Name
name args :: PatSynArgsQ
args dir :: PatSynDirQ
dir pat :: PatQ
pat = do
  PatSynArgs
args'    <- PatSynArgsQ
args
  PatSynDir
dir'     <- PatSynDirQ
dir
  Pat
pat'     <- PatQ
pat
  Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name -> PatSynArgs -> PatSynDir -> Pat -> Dec
PatSynD Name
name PatSynArgs
args' PatSynDir
dir' Pat
pat')

-- | Pattern synonym type signature
patSynSigD :: Name -> TypeQ -> DecQ
patSynSigD :: Name -> TypeQ -> DecQ
patSynSigD nm :: Name
nm ty :: TypeQ
ty =
  do Type
ty' <- TypeQ
ty
     Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ Name -> Type -> Dec
PatSynSigD Name
nm Type
ty'

-- | Implicit parameter binding declaration. Can only be used in let
-- and where clauses which consist entirely of implicit bindings.
implicitParamBindD :: String -> ExpQ -> DecQ
implicitParamBindD :: String -> ExpQ -> DecQ
implicitParamBindD n :: String
n e :: ExpQ
e =
  do
    Exp
e' <- ExpQ
e
    Dec -> DecQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Dec -> DecQ) -> Dec -> DecQ
forall a b. (a -> b) -> a -> b
$ String -> Exp -> Dec
ImplicitParamBindD String
n Exp
e'

tySynEqn :: (Maybe [TyVarBndrQ]) -> TypeQ -> TypeQ -> TySynEqnQ
tySynEqn :: Maybe [TyVarBndrQ] -> TypeQ -> TypeQ -> TySynEqnQ
tySynEqn mb_bndrs :: Maybe [TyVarBndrQ]
mb_bndrs lhs :: TypeQ
lhs rhs :: TypeQ
rhs =
  do
    Maybe [TyVarBndr]
mb_bndrs1 <- ([TyVarBndrQ] -> Q [TyVarBndr])
-> Maybe [TyVarBndrQ] -> Q (Maybe [TyVarBndr])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence Maybe [TyVarBndrQ]
mb_bndrs
    Type
lhs1 <- TypeQ
lhs
    Type
rhs1 <- TypeQ
rhs
    TySynEqn -> TySynEqnQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe [TyVarBndr] -> Type -> Type -> TySynEqn
TySynEqn Maybe [TyVarBndr]
mb_bndrs1 Type
lhs1 Type
rhs1)

cxt :: [PredQ] -> CxtQ
cxt :: [TypeQ] -> CxtQ
cxt = [TypeQ] -> CxtQ
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence

derivClause :: Maybe DerivStrategyQ -> [PredQ] -> DerivClauseQ
derivClause :: Maybe DerivStrategyQ -> [TypeQ] -> DerivClauseQ
derivClause mds :: Maybe DerivStrategyQ
mds p :: [TypeQ]
p = do Maybe DerivStrategy
mds' <- Maybe DerivStrategyQ -> Q (Maybe DerivStrategy)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA Maybe DerivStrategyQ
mds
                       Cxt
p'   <- [TypeQ] -> CxtQ
cxt [TypeQ]
p
                       DerivClause -> DerivClauseQ
forall (m :: * -> *) a. Monad m => a -> m a
return (DerivClause -> DerivClauseQ) -> DerivClause -> DerivClauseQ
forall a b. (a -> b) -> a -> b
$ Maybe DerivStrategy -> Cxt -> DerivClause
DerivClause Maybe DerivStrategy
mds' Cxt
p'

stockStrategy :: DerivStrategyQ
stockStrategy :: DerivStrategyQ
stockStrategy = DerivStrategy -> DerivStrategyQ
forall (f :: * -> *) a. Applicative f => a -> f a
pure DerivStrategy
StockStrategy

anyclassStrategy :: DerivStrategyQ
anyclassStrategy :: DerivStrategyQ
anyclassStrategy = DerivStrategy -> DerivStrategyQ
forall (f :: * -> *) a. Applicative f => a -> f a
pure DerivStrategy
AnyclassStrategy

newtypeStrategy :: DerivStrategyQ
newtypeStrategy :: DerivStrategyQ
newtypeStrategy = DerivStrategy -> DerivStrategyQ
forall (f :: * -> *) a. Applicative f => a -> f a
pure DerivStrategy
NewtypeStrategy

viaStrategy :: TypeQ -> DerivStrategyQ
viaStrategy :: TypeQ -> DerivStrategyQ
viaStrategy = (Type -> DerivStrategy) -> TypeQ -> DerivStrategyQ
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Type -> DerivStrategy
ViaStrategy

normalC :: Name -> [BangTypeQ] -> ConQ
normalC :: Name -> [BangTypeQ] -> ConQ
normalC con :: Name
con strtys :: [BangTypeQ]
strtys = ([BangType] -> Con) -> Q [BangType] -> ConQ
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Name -> [BangType] -> Con
NormalC Name
con) (Q [BangType] -> ConQ) -> Q [BangType] -> ConQ
forall a b. (a -> b) -> a -> b
$ [BangTypeQ] -> Q [BangType]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [BangTypeQ]
strtys

recC :: Name -> [VarBangTypeQ] -> ConQ
recC :: Name -> [VarBangTypeQ] -> ConQ
recC con :: Name
con varstrtys :: [VarBangTypeQ]
varstrtys = ([VarBangType] -> Con) -> Q [VarBangType] -> ConQ
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Name -> [VarBangType] -> Con
RecC Name
con) (Q [VarBangType] -> ConQ) -> Q [VarBangType] -> ConQ
forall a b. (a -> b) -> a -> b
$ [VarBangTypeQ] -> Q [VarBangType]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [VarBangTypeQ]
varstrtys

infixC :: Q (Bang, Type) -> Name -> Q (Bang, Type) -> ConQ
infixC :: BangTypeQ -> Name -> BangTypeQ -> ConQ
infixC st1 :: BangTypeQ
st1 con :: Name
con st2 :: BangTypeQ
st2 = do BangType
st1' <- BangTypeQ
st1
                        BangType
st2' <- BangTypeQ
st2
                        Con -> ConQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Con -> ConQ) -> Con -> ConQ
forall a b. (a -> b) -> a -> b
$ BangType -> Name -> BangType -> Con
InfixC BangType
st1' Name
con BangType
st2'

forallC :: [TyVarBndrQ] -> CxtQ -> ConQ -> ConQ
forallC :: [TyVarBndrQ] -> CxtQ -> ConQ -> ConQ
forallC ns :: [TyVarBndrQ]
ns ctxt :: CxtQ
ctxt con :: ConQ
con = do
  [TyVarBndr]
ns'   <- [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TyVarBndrQ]
ns
  Cxt
ctxt' <- CxtQ
ctxt
  Con
con'  <- ConQ
con
  Con -> ConQ
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Con -> ConQ) -> Con -> ConQ
forall a b. (a -> b) -> a -> b
$ [TyVarBndr] -> Cxt -> Con -> Con
ForallC [TyVarBndr]
ns' Cxt
ctxt' Con
con'

gadtC :: [Name] -> [StrictTypeQ] -> TypeQ -> ConQ
gadtC :: [Name] -> [BangTypeQ] -> TypeQ -> ConQ
gadtC cons :: [Name]
cons strtys :: [BangTypeQ]
strtys ty :: TypeQ
ty = ([BangType] -> Type -> Con) -> Q [BangType] -> TypeQ -> ConQ
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 ([Name] -> [BangType] -> Type -> Con
GadtC [Name]
cons) ([BangTypeQ] -> Q [BangType]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [BangTypeQ]
strtys) TypeQ
ty

recGadtC :: [Name] -> [VarStrictTypeQ] -> TypeQ -> ConQ
recGadtC :: [Name] -> [VarBangTypeQ] -> TypeQ -> ConQ
recGadtC cons :: [Name]
cons varstrtys :: [VarBangTypeQ]
varstrtys ty :: TypeQ
ty = ([VarBangType] -> Type -> Con) -> Q [VarBangType] -> TypeQ -> ConQ
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 ([Name] -> [VarBangType] -> Type -> Con
RecGadtC [Name]
cons) ([VarBangTypeQ] -> Q [VarBangType]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [VarBangTypeQ]
varstrtys) TypeQ
ty

-------------------------------------------------------------------------------
-- *   Type

forallT :: [TyVarBndrQ] -> CxtQ -> TypeQ -> TypeQ
forallT :: [TyVarBndrQ] -> CxtQ -> TypeQ -> TypeQ
forallT tvars :: [TyVarBndrQ]
tvars ctxt :: CxtQ
ctxt ty :: TypeQ
ty = do
    [TyVarBndr]
tvars1 <- [TyVarBndrQ] -> Q [TyVarBndr]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [TyVarBndrQ]
tvars
    Cxt
ctxt1  <- CxtQ
ctxt
    Type
ty1    <- TypeQ
ty
    Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> TypeQ) -> Type -> TypeQ
forall a b. (a -> b) -> a -> b
$ [TyVarBndr] -> Cxt -> Type -> Type
ForallT [TyVarBndr]
tvars1 Cxt
ctxt1 Type
ty1

varT :: Name -> TypeQ
varT :: Name -> TypeQ
varT = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> TypeQ) -> (Name -> Type) -> Name -> TypeQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Type
VarT

conT :: Name -> TypeQ
conT :: Name -> TypeQ
conT = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> TypeQ) -> (Name -> Type) -> Name -> TypeQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Type
ConT

infixT :: TypeQ -> Name -> TypeQ -> TypeQ
infixT :: TypeQ -> Name -> TypeQ -> TypeQ
infixT t1 :: TypeQ
t1 n :: Name
n t2 :: TypeQ
t2 = do Type
t1' <- TypeQ
t1
                    Type
t2' <- TypeQ
t2
                    Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Name -> Type -> Type
InfixT Type
t1' Name
n Type
t2')

uInfixT :: TypeQ -> Name -> TypeQ -> TypeQ
uInfixT :: TypeQ -> Name -> TypeQ -> TypeQ
uInfixT t1 :: TypeQ
t1 n :: Name
n t2 :: TypeQ
t2 = do Type
t1' <- TypeQ
t1
                     Type
t2' <- TypeQ
t2
                     Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Name -> Type -> Type
UInfixT Type
t1' Name
n Type
t2')

parensT :: TypeQ -> TypeQ
parensT :: TypeQ -> TypeQ
parensT t :: TypeQ
t = do Type
t' <- TypeQ
t
               Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Type
ParensT Type
t')

appT :: TypeQ -> TypeQ -> TypeQ
appT :: TypeQ -> TypeQ -> TypeQ
appT t1 :: TypeQ
t1 t2 :: TypeQ
t2 = do
           Type
t1' <- TypeQ
t1
           Type
t2' <- TypeQ
t2
           Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> TypeQ) -> Type -> TypeQ
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
AppT Type
t1' Type
t2'

appKindT :: TypeQ -> KindQ -> TypeQ
appKindT :: TypeQ -> TypeQ -> TypeQ
appKindT ty :: TypeQ
ty ki :: TypeQ
ki = do
               Type
ty' <- TypeQ
ty
               Type
ki' <- TypeQ
ki
               Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> TypeQ) -> Type -> TypeQ
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
AppKindT Type
ty' Type
ki'

arrowT :: TypeQ
arrowT :: TypeQ
arrowT = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return Type
ArrowT

listT :: TypeQ
listT :: TypeQ
listT = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return Type
ListT

litT :: TyLitQ -> TypeQ
litT :: TyLitQ -> TypeQ
litT l :: TyLitQ
l = (TyLit -> Type) -> TyLitQ -> TypeQ
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TyLit -> Type
LitT TyLitQ
l

tupleT :: Int -> TypeQ
tupleT :: SumAlt -> TypeQ
tupleT i :: SumAlt
i = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (SumAlt -> Type
TupleT SumAlt
i)

unboxedTupleT :: Int -> TypeQ
unboxedTupleT :: SumAlt -> TypeQ
unboxedTupleT i :: SumAlt
i = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (SumAlt -> Type
UnboxedTupleT SumAlt
i)

unboxedSumT :: SumArity -> TypeQ
unboxedSumT :: SumAlt -> TypeQ
unboxedSumT arity :: SumAlt
arity = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (SumAlt -> Type
UnboxedSumT SumAlt
arity)

sigT :: TypeQ -> KindQ -> TypeQ
sigT :: TypeQ -> TypeQ -> TypeQ
sigT t :: TypeQ
t k :: TypeQ
k
  = do
      Type
t' <- TypeQ
t
      Type
k' <- TypeQ
k
      Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> TypeQ) -> Type -> TypeQ
forall a b. (a -> b) -> a -> b
$ Type -> Type -> Type
SigT Type
t' Type
k'

equalityT :: TypeQ
equalityT :: TypeQ
equalityT = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return Type
EqualityT

wildCardT :: TypeQ
wildCardT :: TypeQ
wildCardT = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return Type
WildCardT

implicitParamT :: String -> TypeQ -> TypeQ
implicitParamT :: String -> TypeQ -> TypeQ
implicitParamT n :: String
n t :: TypeQ
t
  = do
      Type
t' <- TypeQ
t
      Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> TypeQ) -> Type -> TypeQ
forall a b. (a -> b) -> a -> b
$ String -> Type -> Type
ImplicitParamT String
n Type
t'

{-# DEPRECATED classP "As of template-haskell-2.10, constraint predicates (Pred) are just types (Type), in keeping with ConstraintKinds. Please use 'conT' and 'appT'." #-}
classP :: Name -> [Q Type] -> Q Pred
classP :: Name -> [TypeQ] -> TypeQ
classP cla :: Name
cla tys :: [TypeQ]
tys
  = do
      Cxt
tysl <- [TypeQ] -> CxtQ
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [TypeQ]
tys
      Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return ((Type -> Type -> Type) -> Type -> Cxt -> Type
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl Type -> Type -> Type
AppT (Name -> Type
ConT Name
cla) Cxt
tysl)

{-# DEPRECATED equalP "As of template-haskell-2.10, constraint predicates (Pred) are just types (Type), in keeping with ConstraintKinds. Please see 'equalityT'." #-}
equalP :: TypeQ -> TypeQ -> PredQ
equalP :: TypeQ -> TypeQ -> TypeQ
equalP tleft :: TypeQ
tleft tright :: TypeQ
tright
  = do
      Type
tleft1  <- TypeQ
tleft
      Type
tright1 <- TypeQ
tright
      Type
eqT <- TypeQ
equalityT
      Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return ((Type -> Type -> Type) -> Type -> Cxt -> Type
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl Type -> Type -> Type
AppT Type
eqT [Type
tleft1, Type
tright1])

promotedT :: Name -> TypeQ
promotedT :: Name -> TypeQ
promotedT = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> TypeQ) -> (Name -> Type) -> Name -> TypeQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Type
PromotedT

promotedTupleT :: Int -> TypeQ
promotedTupleT :: SumAlt -> TypeQ
promotedTupleT i :: SumAlt
i = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (SumAlt -> Type
PromotedTupleT SumAlt
i)

promotedNilT :: TypeQ
promotedNilT :: TypeQ
promotedNilT = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return Type
PromotedNilT

promotedConsT :: TypeQ
promotedConsT :: TypeQ
promotedConsT = Type -> TypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return Type
PromotedConsT

noSourceUnpackedness, sourceNoUnpack, sourceUnpack :: SourceUnpackednessQ
noSourceUnpackedness :: SourceUnpackednessQ
noSourceUnpackedness = SourceUnpackedness -> SourceUnpackednessQ
forall (m :: * -> *) a. Monad m => a -> m a
return SourceUnpackedness
NoSourceUnpackedness
sourceNoUnpack :: SourceUnpackednessQ
sourceNoUnpack       = SourceUnpackedness -> SourceUnpackednessQ
forall (m :: * -> *) a. Monad m => a -> m a
return SourceUnpackedness
SourceNoUnpack
sourceUnpack :: SourceUnpackednessQ
sourceUnpack         = SourceUnpackedness -> SourceUnpackednessQ
forall (m :: * -> *) a. Monad m => a -> m a
return SourceUnpackedness
SourceUnpack

noSourceStrictness, sourceLazy, sourceStrict :: SourceStrictnessQ
noSourceStrictness :: SourceStrictnessQ
noSourceStrictness = SourceStrictness -> SourceStrictnessQ
forall (m :: * -> *) a. Monad m => a -> m a
return SourceStrictness
NoSourceStrictness
sourceLazy :: SourceStrictnessQ
sourceLazy         = SourceStrictness -> SourceStrictnessQ
forall (m :: * -> *) a. Monad m => a -> m a
return SourceStrictness
SourceLazy
sourceStrict :: SourceStrictnessQ
sourceStrict       = SourceStrictness -> SourceStrictnessQ
forall (m :: * -> *) a. Monad m => a -> m a
return SourceStrictness
SourceStrict

{-# DEPRECATED isStrict
    ["Use 'bang'. See https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0. ",
     "Example usage: 'bang noSourceUnpackedness sourceStrict'"] #-}
{-# DEPRECATED notStrict
    ["Use 'bang'. See https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0. ",
     "Example usage: 'bang noSourceUnpackedness noSourceStrictness'"] #-}
{-# DEPRECATED unpacked
    ["Use 'bang'. See https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0. ",
     "Example usage: 'bang sourceUnpack sourceStrict'"] #-}
isStrict, notStrict, unpacked :: Q Strict
isStrict :: Q Strict
isStrict = SourceUnpackednessQ -> SourceStrictnessQ -> Q Strict
bang SourceUnpackednessQ
noSourceUnpackedness SourceStrictnessQ
sourceStrict
notStrict :: Q Strict
notStrict = SourceUnpackednessQ -> SourceStrictnessQ -> Q Strict
bang SourceUnpackednessQ
noSourceUnpackedness SourceStrictnessQ
noSourceStrictness
unpacked :: Q Strict
unpacked = SourceUnpackednessQ -> SourceStrictnessQ -> Q Strict
bang SourceUnpackednessQ
sourceUnpack SourceStrictnessQ
sourceStrict

bang :: SourceUnpackednessQ -> SourceStrictnessQ -> BangQ
bang :: SourceUnpackednessQ -> SourceStrictnessQ -> Q Strict
bang u :: SourceUnpackednessQ
u s :: SourceStrictnessQ
s = do SourceUnpackedness
u' <- SourceUnpackednessQ
u
              SourceStrictness
s' <- SourceStrictnessQ
s
              Strict -> Q Strict
forall (m :: * -> *) a. Monad m => a -> m a
return (SourceUnpackedness -> SourceStrictness -> Strict
Bang SourceUnpackedness
u' SourceStrictness
s')

bangType :: BangQ -> TypeQ -> BangTypeQ
bangType :: Q Strict -> TypeQ -> BangTypeQ
bangType = (Strict -> Type -> BangType) -> Q Strict -> TypeQ -> BangTypeQ
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (,)

varBangType :: Name -> BangTypeQ -> VarBangTypeQ
varBangType :: Name -> BangTypeQ -> VarBangTypeQ
varBangType v :: Name
v bt :: BangTypeQ
bt = do (b :: Strict
b, t :: Type
t) <- BangTypeQ
bt
                      VarBangType -> VarBangTypeQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Name
v, Strict
b, Type
t)

{-# DEPRECATED strictType
               "As of @template-haskell-2.11.0.0@, 'StrictType' has been replaced by 'BangType'. Please use 'bangType' instead." #-}
strictType :: Q Strict -> TypeQ -> StrictTypeQ
strictType :: Q Strict -> TypeQ -> BangTypeQ
strictType = Q Strict -> TypeQ -> BangTypeQ
bangType

{-# DEPRECATED varStrictType
               "As of @template-haskell-2.11.0.0@, 'VarStrictType' has been replaced by 'VarBangType'. Please use 'varBangType' instead." #-}
varStrictType :: Name -> StrictTypeQ -> VarStrictTypeQ
varStrictType :: Name -> BangTypeQ -> VarBangTypeQ
varStrictType = Name -> BangTypeQ -> VarBangTypeQ
varBangType

-- * Type Literals

numTyLit :: Integer -> TyLitQ
numTyLit :: Integer -> TyLitQ
numTyLit n :: Integer
n = if Integer
n Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= 0 then TyLit -> TyLitQ
forall (m :: * -> *) a. Monad m => a -> m a
return (Integer -> TyLit
NumTyLit Integer
n)
                       else String -> TyLitQ
forall (m :: * -> *) a. MonadFail m => String -> m a
fail ("Negative type-level number: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
n)

strTyLit :: String -> TyLitQ
strTyLit :: String -> TyLitQ
strTyLit s :: String
s = TyLit -> TyLitQ
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> TyLit
StrTyLit String
s)

-------------------------------------------------------------------------------
-- *   Kind

plainTV :: Name -> TyVarBndrQ
plainTV :: Name -> TyVarBndrQ
plainTV = TyVarBndr -> TyVarBndrQ
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TyVarBndr -> TyVarBndrQ)
-> (Name -> TyVarBndr) -> Name -> TyVarBndrQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> TyVarBndr
PlainTV

kindedTV :: Name -> KindQ -> TyVarBndrQ
kindedTV :: Name -> TypeQ -> TyVarBndrQ
kindedTV n :: Name
n = (Type -> TyVarBndr) -> TypeQ -> TyVarBndrQ
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Name -> Type -> TyVarBndr
KindedTV Name
n)

varK :: Name -> Kind
varK :: Name -> Type
varK = Name -> Type
VarT

conK :: Name -> Kind
conK :: Name -> Type
conK = Name -> Type
ConT

tupleK :: Int -> Kind
tupleK :: SumAlt -> Type
tupleK = SumAlt -> Type
TupleT

arrowK :: Kind
arrowK :: Type
arrowK = Type
ArrowT

listK :: Kind
listK :: Type
listK = Type
ListT

appK :: Kind -> Kind -> Kind
appK :: Type -> Type -> Type
appK = Type -> Type -> Type
AppT

starK :: KindQ
starK :: TypeQ
starK = Type -> TypeQ
forall (f :: * -> *) a. Applicative f => a -> f a
pure Type
StarT

constraintK :: KindQ
constraintK :: TypeQ
constraintK = Type -> TypeQ
forall (f :: * -> *) a. Applicative f => a -> f a
pure Type
ConstraintT

-------------------------------------------------------------------------------
-- *   Type family result

noSig :: FamilyResultSigQ
noSig :: FamilyResultSigQ
noSig = FamilyResultSig -> FamilyResultSigQ
forall (f :: * -> *) a. Applicative f => a -> f a
pure FamilyResultSig
NoSig

kindSig :: KindQ -> FamilyResultSigQ
kindSig :: TypeQ -> FamilyResultSigQ
kindSig = (Type -> FamilyResultSig) -> TypeQ -> FamilyResultSigQ
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Type -> FamilyResultSig
KindSig

tyVarSig :: TyVarBndrQ -> FamilyResultSigQ
tyVarSig :: TyVarBndrQ -> FamilyResultSigQ
tyVarSig = (TyVarBndr -> FamilyResultSig) -> TyVarBndrQ -> FamilyResultSigQ
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TyVarBndr -> FamilyResultSig
TyVarSig

-------------------------------------------------------------------------------
-- *   Injectivity annotation

injectivityAnn :: Name -> [Name] -> InjectivityAnn
injectivityAnn :: Name -> [Name] -> InjectivityAnn
injectivityAnn = Name -> [Name] -> InjectivityAnn
TH.InjectivityAnn

-------------------------------------------------------------------------------
-- *   Role

nominalR, representationalR, phantomR, inferR :: Role
nominalR :: Role
nominalR          = Role
NominalR
representationalR :: Role
representationalR = Role
RepresentationalR
phantomR :: Role
phantomR          = Role
PhantomR
inferR :: Role
inferR            = Role
InferR

-------------------------------------------------------------------------------
-- *   Callconv

cCall, stdCall, cApi, prim, javaScript :: Callconv
cCall :: Callconv
cCall      = Callconv
CCall
stdCall :: Callconv
stdCall    = Callconv
StdCall
cApi :: Callconv
cApi       = Callconv
CApi
prim :: Callconv
prim       = Callconv
Prim
javaScript :: Callconv
javaScript = Callconv
JavaScript

-------------------------------------------------------------------------------
-- *   Safety

unsafe, safe, interruptible :: Safety
unsafe :: Safety
unsafe = Safety
Unsafe
safe :: Safety
safe = Safety
Safe
interruptible :: Safety
interruptible = Safety
Interruptible

-------------------------------------------------------------------------------
-- *   FunDep

funDep :: [Name] -> [Name] -> FunDep
funDep :: [Name] -> [Name] -> FunDep
funDep = [Name] -> [Name] -> FunDep
FunDep

-------------------------------------------------------------------------------
-- *   RuleBndr
ruleVar :: Name -> RuleBndrQ
ruleVar :: Name -> RuleBndrQ
ruleVar = RuleBndr -> RuleBndrQ
forall (m :: * -> *) a. Monad m => a -> m a
return (RuleBndr -> RuleBndrQ) -> (Name -> RuleBndr) -> Name -> RuleBndrQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> RuleBndr
RuleVar

typedRuleVar :: Name -> TypeQ -> RuleBndrQ
typedRuleVar :: Name -> TypeQ -> RuleBndrQ
typedRuleVar n :: Name
n ty :: TypeQ
ty = TypeQ
ty TypeQ -> (Type -> RuleBndrQ) -> RuleBndrQ
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= RuleBndr -> RuleBndrQ
forall (m :: * -> *) a. Monad m => a -> m a
return (RuleBndr -> RuleBndrQ) -> (Type -> RuleBndr) -> Type -> RuleBndrQ
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Type -> RuleBndr
TypedRuleVar Name
n

-------------------------------------------------------------------------------
-- *   AnnTarget
valueAnnotation :: Name -> AnnTarget
valueAnnotation :: Name -> AnnTarget
valueAnnotation = Name -> AnnTarget
ValueAnnotation

typeAnnotation :: Name -> AnnTarget
typeAnnotation :: Name -> AnnTarget
typeAnnotation = Name -> AnnTarget
TypeAnnotation

moduleAnnotation :: AnnTarget
moduleAnnotation :: AnnTarget
moduleAnnotation = AnnTarget
ModuleAnnotation

-------------------------------------------------------------------------------
-- * Pattern Synonyms (sub constructs)

unidir, implBidir :: PatSynDirQ
unidir :: PatSynDirQ
unidir    = PatSynDir -> PatSynDirQ
forall (m :: * -> *) a. Monad m => a -> m a
return PatSynDir
Unidir
implBidir :: PatSynDirQ
implBidir = PatSynDir -> PatSynDirQ
forall (m :: * -> *) a. Monad m => a -> m a
return PatSynDir
ImplBidir

explBidir :: [ClauseQ] -> PatSynDirQ
explBidir :: [ClauseQ] -> PatSynDirQ
explBidir cls :: [ClauseQ]
cls = do
  [Clause]
cls' <- [ClauseQ] -> Q [Clause]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [ClauseQ]
cls
  PatSynDir -> PatSynDirQ
forall (m :: * -> *) a. Monad m => a -> m a
return ([Clause] -> PatSynDir
ExplBidir [Clause]
cls')

prefixPatSyn :: [Name] -> PatSynArgsQ
prefixPatSyn :: [Name] -> PatSynArgsQ
prefixPatSyn args :: [Name]
args = PatSynArgs -> PatSynArgsQ
forall (m :: * -> *) a. Monad m => a -> m a
return (PatSynArgs -> PatSynArgsQ) -> PatSynArgs -> PatSynArgsQ
forall a b. (a -> b) -> a -> b
$ [Name] -> PatSynArgs
PrefixPatSyn [Name]
args

recordPatSyn :: [Name] -> PatSynArgsQ
recordPatSyn :: [Name] -> PatSynArgsQ
recordPatSyn sels :: [Name]
sels = PatSynArgs -> PatSynArgsQ
forall (m :: * -> *) a. Monad m => a -> m a
return (PatSynArgs -> PatSynArgsQ) -> PatSynArgs -> PatSynArgsQ
forall a b. (a -> b) -> a -> b
$ [Name] -> PatSynArgs
RecordPatSyn [Name]
sels

infixPatSyn :: Name -> Name -> PatSynArgsQ
infixPatSyn :: Name -> Name -> PatSynArgsQ
infixPatSyn arg1 :: Name
arg1 arg2 :: Name
arg2 = PatSynArgs -> PatSynArgsQ
forall (m :: * -> *) a. Monad m => a -> m a
return (PatSynArgs -> PatSynArgsQ) -> PatSynArgs -> PatSynArgsQ
forall a b. (a -> b) -> a -> b
$ Name -> Name -> PatSynArgs
InfixPatSyn Name
arg1 Name
arg2

--------------------------------------------------------------
-- * Useful helper function

appsE :: [ExpQ] -> ExpQ
appsE :: [ExpQ] -> ExpQ
appsE [] = String -> ExpQ
forall a. HasCallStack => String -> a
error "appsE []"
appsE [x :: ExpQ
x] = ExpQ
x
appsE (x :: ExpQ
x:y :: ExpQ
y:zs :: [ExpQ]
zs) = [ExpQ] -> ExpQ
appsE ( (ExpQ -> ExpQ -> ExpQ
appE ExpQ
x ExpQ
y) ExpQ -> [ExpQ] -> [ExpQ]
forall a. a -> [a] -> [a]
: [ExpQ]
zs )

-- | Return the Module at the place of splicing.  Can be used as an
-- input for 'reifyModule'.
thisModule :: Q Module
thisModule :: Q Module
thisModule = do
  Loc
loc <- Q Loc
location
  Module -> Q Module
forall (m :: * -> *) a. Monad m => a -> m a
return (Module -> Q Module) -> Module -> Q Module
forall a b. (a -> b) -> a -> b
$ PkgName -> ModName -> Module
Module (String -> PkgName
mkPkgName (String -> PkgName) -> String -> PkgName
forall a b. (a -> b) -> a -> b
$ Loc -> String
loc_package Loc
loc) (String -> ModName
mkModName (String -> ModName) -> String -> ModName
forall a b. (a -> b) -> a -> b
$ Loc -> String
loc_module Loc
loc)