-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Facilities for manipulating Haskell source code using Template -- Haskell. @package template-haskell -- | Abstract syntax definitions for Template Haskell. module Language.Haskell.TH.Syntax class (Monad m, Applicative m) => Quasi m qNewName :: Quasi m => String -> m Name qReport :: Quasi m => Bool -> String -> m () qRecover :: Quasi m => m a -> m a -> m a qLookupName :: Quasi m => Bool -> String -> m (Maybe Name) qReify :: Quasi m => Name -> m Info qReifyInstances :: Quasi m => Name -> [Type] -> m [Dec] qLocation :: Quasi m => m Loc qRunIO :: Quasi m => IO a -> m a qAddDependentFile :: Quasi m => FilePath -> m () badIO :: String -> IO a counter :: IORef Int newtype Q a Q :: (forall m. Quasi m => m a) -> Q a unQ :: Q a -> forall m. Quasi m => m a runQ :: Quasi m => Q a -> m a -- | Generate a fresh name, which cannot be captured. -- -- For example, this: -- --
-- f = $(do -- nm1 <- newName "x" -- let nm2 = mkName "x" -- return (LamE [VarP nm1] (LamE [VarP nm2] (VarE nm1))) -- ) ---- -- will produce the splice -- --
-- f = \x0 -> \x -> x0 ---- -- In particular, the occurrence VarE nm1 refers to the binding -- VarP nm1, and is not captured by the binding VarP -- nm2. -- -- Although names generated by newName cannot be -- captured, they can capture other names. For example, this: -- --
-- g = $(do -- nm1 <- newName "x" -- let nm2 = mkName "x" -- return (LamE [VarP nm2] (LamE [VarP nm1] (VarE nm2))) -- ) ---- -- will produce the splice -- --
-- g = \x -> \x0 -> x0 ---- -- since the occurrence VarE nm2 is captured by the innermost -- binding of x, namely VarP nm1. newName :: String -> Q Name -- | Report an error (True) or warning (False), but carry on; use -- fail to stop. report :: Bool -> String -> Q () -- | Report an error to the user, but allow the current splice's -- computation to carry on. To abort the computation, use fail. reportError :: String -> Q () -- | Report a warning to the user, and carry on. reportWarning :: String -> Q () -- | Recover from errors raised by reportError or fail. recover :: Q a -> Q a -> Q a lookupName :: Bool -> String -> Q (Maybe Name) -- | Look up the given name in the (type namespace of the) current splice's -- scope. See Language.Haskell.TH.Syntax#namelookup for more -- details. lookupTypeName :: String -> Q (Maybe Name) -- | Look up the given name in the (value namespace of the) current -- splice's scope. See Language.Haskell.TH.Syntax#namelookup for -- more details. lookupValueName :: String -> Q (Maybe Name) -- | reify looks up information about the Name. -- -- It is sometimes useful to construct the argument name using -- lookupTypeName or lookupValueName to ensure that we are -- reifying from the right namespace. For instance, in this context: -- --
-- data D = D ---- -- which D does reify (mkName "D") return information -- about? (Answer: D-the-type, but don't rely on it.) To ensure -- we get information about D-the-value, use -- lookupValueName: -- --
-- do -- Just nm <- lookupValueName "D" -- reify nm ---- -- and to get information about D-the-type, use -- lookupTypeName. reify :: Name -> Q Info -- | reifyInstances nm tys returns a list of visible instances of -- nm tys. That is, if nm is the name of a type class, -- then all instances of this class at the types tys are -- returned. Alternatively, if nm is the name of a data family -- or type family, all instances of this family at the types tys -- are returned. reifyInstances :: Name -> [Type] -> Q [InstanceDec] -- | Is the list of instances returned by reifyInstances nonempty? isInstance :: Name -> [Type] -> Q Bool -- | The location at which this computation is spliced. location :: Q Loc -- | The runIO function lets you run an I/O computation in the -- Q monad. Take care: you are guaranteed the ordering of calls to -- runIO within a single Q computation, but not about the -- order in which splices are run. -- -- Note: for various murky reasons, stdout and stderr handles are not -- necesarily flushed when the compiler finishes running, so you should -- flush them yourself. runIO :: IO a -> Q a -- | Record external files that runIO is using (dependent upon). The -- compiler can then recognize that it should re-compile the file using -- this TH when the external file changes. Note that ghc -M will still -- not know about these dependencies - it does not execute TH. Expects an -- absolute file path. addDependentFile :: FilePath -> Q () returnQ :: a -> Q a bindQ :: Q a -> (a -> Q b) -> Q b sequenceQ :: [Q a] -> Q [a] class Lift t lift :: Lift t => t -> Q Exp liftString :: String -> Q Exp trueName, falseName :: Name nothingName, justName :: Name leftName, rightName :: Name newtype ModName ModName :: String -> ModName newtype PkgName PkgName :: String -> PkgName newtype OccName OccName :: String -> OccName mkModName :: String -> ModName modString :: ModName -> String mkPkgName :: String -> PkgName pkgString :: PkgName -> String mkOccName :: String -> OccName occString :: OccName -> String -- | An abstract type representing names in the syntax tree. -- -- Names can be constructed in several ways, which come with -- different name-capture guarantees (see -- Language.Haskell.TH.Syntax#namecapture for an explanation of -- name capture): -- --
-- f = [| pi + $(varE (mkName "pi")) |] -- ... -- g = let pi = 3 in $f ---- -- In this case, g is desugared to -- --
-- g = Prelude.pi + 3 ---- -- Note that mkName may be used with qualified names: -- --
-- mkName "Prelude.pi" ---- -- See also dyn for a useful combinator. The above example could -- be rewritten using dyn as -- --
-- f = [| pi + $(dyn "pi") |] --mkName :: String -> Name -- | Only used internally mkNameU :: String -> Uniq -> Name -- | Only used internally mkNameL :: String -> Uniq -> Name -- | Used for 'x etc, but not available to the programmer mkNameG :: NameSpace -> String -> String -> String -> Name mkNameG_v, mkNameG_d, mkNameG_tc :: String -> String -> String -> Name data NameIs Alone :: NameIs Applied :: NameIs Infix :: NameIs showName :: Name -> String showName' :: NameIs -> Name -> String -- | Tuple data constructor tupleDataName :: Int -> Name -- | Tuple type constructor tupleTypeName :: Int -> Name mk_tup_name :: Int -> NameSpace -> Name -- | Unboxed tuple data constructor unboxedTupleDataName :: Int -> Name -- | Unboxed tuple type constructor unboxedTupleTypeName :: Int -> Name mk_unboxed_tup_name :: Int -> NameSpace -> Name data Loc Loc :: String -> String -> String -> CharPos -> CharPos -> Loc loc_filename :: Loc -> String loc_package :: Loc -> String loc_module :: Loc -> String loc_start :: Loc -> CharPos loc_end :: Loc -> CharPos type CharPos = (Int, Int) -- | Obtained from reify in the Q Monad. data Info -- | A class, with a list of its visible instances ClassI :: Dec -> [InstanceDec] -> Info -- | A class method ClassOpI :: Name -> Type -> ParentName -> Fixity -> Info -- | A "plain" type constructor. "Fancier" type constructors are returned -- using PrimTyConI or FamilyI as appropriate TyConI :: Dec -> Info -- | A type or data family, with a list of its visible instances FamilyI :: Dec -> [InstanceDec] -> Info -- | A "primitive" type constructor, which can't be expressed with a -- Dec. Examples: (->), Int#. PrimTyConI :: Name -> Arity -> Unlifted -> Info -- | A data constructor DataConI :: Name -> Type -> ParentName -> Fixity -> Info -- | A "value" variable (as opposed to a type variable, see TyVarI). -- -- The Maybe Dec field contains Just the declaration -- which defined the variable -- including the RHS of the declaration -- -- or else Nothing, in the case where the RHS is unavailable to -- the compiler. At present, this value is _always_ Nothing: -- returning the RHS has not yet been implemented because of lack of -- interest. VarI :: Name -> Type -> (Maybe Dec) -> Fixity -> Info -- | A type variable. -- -- The Type field contains the type which underlies the -- variable. At present, this is always VarT theName, but -- future changes may permit refinement of this. TyVarI :: Name -> Type -> Info -- | In ClassOpI and DataConI, name of the parent class or -- type type ParentName = Name -- | In PrimTyConI, arity of the type constructor type Arity = Int -- | In PrimTyConI, is the type constructor unlifted? type Unlifted = Bool -- | InstanceDec desribes a single instance of a class or type -- function. It is just a Dec, but guaranteed to be one of the -- following: -- --
-- { 5 or c }
--
LitP :: Lit -> Pat
-- |
-- { x }
--
VarP :: Name -> Pat
-- |
-- { (p1,p2) }
--
TupP :: [Pat] -> Pat
-- |
-- { () }
--
UnboxedTupP :: [Pat] -> Pat
-- |
-- data T1 = C1 t1 t2; {C1 p1 p1} = e
--
ConP :: Name -> [Pat] -> Pat
-- |
-- foo ({x :+ y}) = e
--
InfixP :: Pat -> Name -> Pat -> Pat
-- |
-- foo ({x :+ y}) = e
--
--
-- See Language.Haskell.TH.Syntax#infix
UInfixP :: Pat -> Name -> Pat -> Pat
-- |
-- {(p)}
--
--
-- See Language.Haskell.TH.Syntax#infix
ParensP :: Pat -> Pat
-- |
-- { ~p }
--
TildeP :: Pat -> Pat
-- |
-- { !p }
--
BangP :: Pat -> Pat
-- |
-- { x @ p }
--
AsP :: Name -> Pat -> Pat
-- |
-- { _ }
--
WildP :: Pat
-- |
-- f (Pt { pointx = x }) = g x
--
RecP :: Name -> [FieldPat] -> Pat
-- |
-- { [1,2,3] }
--
ListP :: [Pat] -> Pat
-- |
-- { p :: t }
--
SigP :: Pat -> Type -> Pat
-- |
-- { e -> p }
--
ViewP :: Exp -> Pat -> Pat
type FieldPat = (Name, Pat)
data Match
-- |
-- case e of { pat -> body where decs }
--
Match :: Pat -> Body -> [Dec] -> Match
data Clause
-- |
-- f { p1 p2 = body where decs }
--
Clause :: [Pat] -> Body -> [Dec] -> Clause
data Exp
-- |
-- { x }
--
VarE :: Name -> Exp
-- |
-- data T1 = C1 t1 t2; p = {C1} e1 e2
--
ConE :: Name -> Exp
-- |
-- { 5 or c}
--
LitE :: Lit -> Exp
-- |
-- { f x }
--
AppE :: Exp -> Exp -> Exp
-- |
-- {x + y} or {(x+)} or {(+ x)} or {(+)}
--
InfixE :: (Maybe Exp) -> Exp -> (Maybe Exp) -> Exp
-- |
-- {x + y}
--
--
-- See Language.Haskell.TH.Syntax#infix
UInfixE :: Exp -> Exp -> Exp -> Exp
-- |
-- { (e) }
--
--
-- See Language.Haskell.TH.Syntax#infix
ParensE :: Exp -> Exp
-- |
-- { p1 p2 -> e }
--
LamE :: [Pat] -> Exp -> Exp
-- |
-- { case m1; m2 }
--
LamCaseE :: [Match] -> Exp
-- |
-- { (e1,e2) }
--
TupE :: [Exp] -> Exp
-- |
-- { () }
--
UnboxedTupE :: [Exp] -> Exp
-- |
-- { if e1 then e2 else e3 }
--
CondE :: Exp -> Exp -> Exp -> Exp
-- |
-- { if | g1 -> e1 | g2 -> e2 }
--
MultiIfE :: [(Guard, Exp)] -> Exp
-- |
-- { let x=e1; y=e2 in e3 }
--
LetE :: [Dec] -> Exp -> Exp
-- |
-- { case e of m1; m2 }
--
CaseE :: Exp -> [Match] -> Exp
-- |
-- { do { p <- e1; e2 } }
--
DoE :: [Stmt] -> Exp
-- |
-- { [ (x,y) | x <- xs, y <- ys ] }
--
--
-- The result expression of the comprehension is the last of the
-- Stmts, and should be a NoBindS.
--
-- E.g. translation:
--
-- -- [ f x | x <- xs ] ---- --
-- CompE [BindS (VarP x) (VarE xs), NoBindS (AppE (VarE f) (VarE x))] --CompE :: [Stmt] -> Exp -- |
-- { [ 1 ,2 .. 10 ] }
--
ArithSeqE :: Range -> Exp
-- |
-- { [1,2,3] }
--
ListE :: [Exp] -> Exp
-- |
-- { e :: t }
--
SigE :: Exp -> Type -> Exp
-- |
-- { T { x = y, z = w } }
--
RecConE :: Name -> [FieldExp] -> Exp
-- |
-- { (f x) { z = w } }
--
RecUpdE :: Exp -> [FieldExp] -> Exp
type FieldExp = (Name, Exp)
data Body
-- |
-- f p { | e1 = e2
-- | e3 = e4 }
-- where ds
--
GuardedB :: [(Guard, Exp)] -> Body
-- |
-- f p { = e } where ds
--
NormalB :: Exp -> Body
data Guard
-- |
-- f x { | odd x } = x
--
NormalG :: Exp -> Guard
-- |
-- f x { | Just y <- x, Just z <- y } = z
--
PatG :: [Stmt] -> Guard
data Stmt
BindS :: Pat -> Exp -> Stmt
LetS :: [Dec] -> Stmt
NoBindS :: Exp -> Stmt
ParS :: [[Stmt]] -> Stmt
data Range
FromR :: Exp -> Range
FromThenR :: Exp -> Exp -> Range
FromToR :: Exp -> Exp -> Range
FromThenToR :: Exp -> Exp -> Exp -> Range
data Dec
-- |
-- { f p1 p2 = b where decs }
--
FunD :: Name -> [Clause] -> Dec
-- |
-- { p = b where decs }
--
ValD :: Pat -> Body -> [Dec] -> Dec
-- |
-- { data Cxt x => T x = A x | B (T x)
-- deriving (Z,W)}
--
DataD :: Cxt -> Name -> [TyVarBndr] -> [Con] -> [Name] -> Dec
-- |
-- { newtype Cxt x => T x = A (B x)
-- deriving (Z,W)}
--
NewtypeD :: Cxt -> Name -> [TyVarBndr] -> Con -> [Name] -> Dec
-- |
-- { type T x = (x,x) }
--
TySynD :: Name -> [TyVarBndr] -> Type -> Dec
-- |
-- { class Eq a => Ord a where ds }
--
ClassD :: Cxt -> Name -> [TyVarBndr] -> [FunDep] -> [Dec] -> Dec
-- |
-- { instance Show w => Show [w]
-- where ds }
--
InstanceD :: Cxt -> Type -> [Dec] -> Dec
-- |
-- { length :: [a] -> Int }
--
SigD :: Name -> Type -> Dec
-- |
-- { foreign import ... }
-- { foreign export ... }
--
ForeignD :: Foreign -> Dec
-- |
-- { infix 3 foo }
--
InfixD :: Fixity -> Name -> Dec
-- |
-- { {--} }
--
PragmaD :: Pragma -> Dec
-- |
-- { type family T a b c :: * }
--
FamilyD :: FamFlavour -> Name -> [TyVarBndr] -> (Maybe Kind) -> Dec
-- |
-- { data instance Cxt x => T [x] = A x
-- | B (T x)
-- deriving (Z,W)}
--
DataInstD :: Cxt -> Name -> [Type] -> [Con] -> [Name] -> Dec
-- |
-- { newtype instance Cxt x => T [x] = A (B x)
-- deriving (Z,W)}
--
NewtypeInstD :: Cxt -> Name -> [Type] -> Con -> [Name] -> Dec
-- |
-- { type instance T (Maybe x) = (x,x) }
--
TySynInstD :: Name -> [Type] -> Type -> Dec
data FunDep
FunDep :: [Name] -> [Name] -> FunDep
data FamFlavour
TypeFam :: FamFlavour
DataFam :: FamFlavour
data Foreign
ImportF :: Callconv -> Safety -> String -> Name -> Type -> Foreign
ExportF :: Callconv -> String -> Name -> Type -> Foreign
data Callconv
CCall :: Callconv
StdCall :: Callconv
data Safety
Unsafe :: Safety
Safe :: Safety
Interruptible :: Safety
data Pragma
InlineP :: Name -> Inline -> RuleMatch -> Phases -> Pragma
SpecialiseP :: Name -> Type -> (Maybe Inline) -> Phases -> Pragma
SpecialiseInstP :: Type -> Pragma
RuleP :: String -> [RuleBndr] -> Exp -> Exp -> Phases -> Pragma
data Inline
NoInline :: Inline
Inline :: Inline
Inlinable :: Inline
data RuleMatch
ConLike :: RuleMatch
FunLike :: RuleMatch
data Phases
AllPhases :: Phases
FromPhase :: Int -> Phases
BeforePhase :: Int -> Phases
data RuleBndr
RuleVar :: Name -> RuleBndr
TypedRuleVar :: Name -> Type -> RuleBndr
type Cxt = [Pred]
data Pred
-- | -- Eq (Int, a) --ClassP :: Name -> [Type] -> Pred -- |
-- F a ~ Bool --EqualP :: Type -> Type -> Pred data Strict IsStrict :: Strict NotStrict :: Strict Unpacked :: Strict data Con -- |
-- C Int a --NormalC :: Name -> [StrictType] -> Con -- |
-- C { v :: Int, w :: a }
--
RecC :: Name -> [VarStrictType] -> Con
-- | -- Int :+ a --InfixC :: StrictType -> Name -> StrictType -> Con -- |
-- forall a. Eq a => C [a] --ForallC :: [TyVarBndr] -> Cxt -> Con -> Con type StrictType = (Strict, Type) type VarStrictType = (Name, Strict, Type) data Type -- |
-- forall <vars>. <ctxt> -> <type> --ForallT :: [TyVarBndr] -> Cxt -> Type -> Type -- |
-- T a b --AppT :: Type -> Type -> Type -- |
-- t :: k --SigT :: Type -> Kind -> Type -- |
-- a --VarT :: Name -> Type -- |
-- T --ConT :: Name -> Type -- |
-- 'T --PromotedT :: Name -> Type -- |
-- (,), (,,), etc. --TupleT :: Int -> Type -- |
-- (), (), etc. --UnboxedTupleT :: Int -> Type -- |
-- -> --ArrowT :: Type -- |
-- [] --ListT :: Type -- |
-- '(), '(,), '(,,), etc. --PromotedTupleT :: Int -> Type -- |
-- '[] --PromotedNilT :: Type -- |
-- (':)
--
PromotedConsT :: Type
-- | -- * --StarT :: Type -- |
-- Constraint --ConstraintT :: Type -- |
-- 0,1,2, etc. --LitT :: TyLit -> Type data TyVarBndr -- |
-- a --PlainTV :: Name -> TyVarBndr -- |
-- (a :: k) --KindedTV :: Name -> Kind -> TyVarBndr data TyLit -- |
-- 2 --NumTyLit :: Integer -> TyLit -- |
-- Hello --StrTyLit :: String -> TyLit -- | To avoid duplication between kinds and types, they are defined to be -- the same. Naturally, you would never have a type be StarT and -- you would never have a kind be SigT, but many of the other -- constructors are shared. Note that the kind Bool is denoted -- with ConT, not PromotedT. Similarly, tuple kinds are -- made with TupleT, not PromotedTupleT. type Kind = Type cmpEq :: Ordering -> Bool thenCmp :: Ordering -> Ordering -> Ordering instance Typeable ModName instance Typeable PkgName instance Typeable OccName instance Typeable NameSpace instance Typeable NameFlavour instance Typeable FixityDirection instance Typeable Fixity instance Typeable Lit instance Typeable FamFlavour instance Typeable Callconv instance Typeable Safety instance Typeable Inline instance Typeable RuleMatch instance Typeable Phases instance Typeable Strict instance Typeable TyLit instance Typeable Name instance Typeable FunDep instance Typeable Type instance Typeable TyVarBndr instance Typeable Pred instance Typeable Con instance Typeable RuleBndr instance Typeable Foreign instance Typeable Exp instance Typeable Match instance Typeable Pat instance Typeable Dec instance Typeable Clause instance Typeable Body instance Typeable Guard instance Typeable Stmt instance Typeable Pragma instance Typeable Range instance Typeable Info instance Eq ModName instance Ord ModName instance Data ModName instance Eq PkgName instance Ord PkgName instance Data PkgName instance Eq OccName instance Ord OccName instance Data OccName instance Eq NameSpace instance Ord NameSpace instance Data NameSpace instance Eq FixityDirection instance Show FixityDirection instance Data FixityDirection instance Eq Fixity instance Show Fixity instance Data Fixity instance Show Lit instance Eq Lit instance Data Lit instance Show FamFlavour instance Eq FamFlavour instance Data FamFlavour instance Show Callconv instance Eq Callconv instance Data Callconv instance Show Safety instance Eq Safety instance Data Safety instance Show Inline instance Eq Inline instance Data Inline instance Show RuleMatch instance Eq RuleMatch instance Data RuleMatch instance Show Phases instance Eq Phases instance Data Phases instance Show Strict instance Eq Strict instance Data Strict instance Show TyLit instance Eq TyLit instance Data TyLit instance Data Name instance Show FunDep instance Eq FunDep instance Data FunDep instance Show Type instance Eq Type instance Data Type instance Show TyVarBndr instance Eq TyVarBndr instance Data TyVarBndr instance Show Pred instance Eq Pred instance Data Pred instance Show Con instance Eq Con instance Data Con instance Show RuleBndr instance Eq RuleBndr instance Data RuleBndr instance Show Foreign instance Eq Foreign instance Data Foreign instance Show Exp instance Eq Exp instance Data Exp instance Show Match instance Eq Match instance Data Match instance Show Pat instance Eq Pat instance Data Pat instance Show Dec instance Eq Dec instance Data Dec instance Show Clause instance Eq Clause instance Data Clause instance Show Body instance Eq Body instance Data Body instance Show Guard instance Eq Guard instance Data Guard instance Show Stmt instance Eq Stmt instance Data Stmt instance Show Pragma instance Eq Pragma instance Data Pragma instance Show Range instance Eq Range instance Data Range instance Show Info instance Data Info instance Show Name instance Ord NameFlavour instance Eq NameFlavour instance Ord Name instance Eq Name instance Data NameFlavour instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g) => Lift (a, b, c, d, e, f, g) instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f) => Lift (a, b, c, d, e, f) instance (Lift a, Lift b, Lift c, Lift d, Lift e) => Lift (a, b, c, d, e) instance (Lift a, Lift b, Lift c, Lift d) => Lift (a, b, c, d) instance (Lift a, Lift b, Lift c) => Lift (a, b, c) instance (Lift a, Lift b) => Lift (a, b) instance Lift a => Lift [a] instance (Lift a, Lift b) => Lift (Either a b) instance Lift a => Lift (Maybe a) instance Lift Bool instance Lift Char instance Lift Int instance Lift Integer instance Quasi Q instance Applicative Q instance Functor Q instance Monad Q instance Quasi IO -- | TH.Lib contains lots of useful helper functions for generating and -- manipulating Template Haskell terms module Language.Haskell.TH.Lib type InfoQ = Q Info type PatQ = Q Pat type FieldPatQ = Q FieldPat type ExpQ = Q Exp type DecQ = Q Dec type DecsQ = Q [Dec] type ConQ = Q Con type TypeQ = Q Type type TyLitQ = Q TyLit type CxtQ = Q Cxt type PredQ = Q Pred 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 StrictTypeQ = Q StrictType type VarStrictTypeQ = Q VarStrictType type FieldExpQ = Q FieldExp type RuleBndrQ = Q RuleBndr intPrimL :: Integer -> Lit wordPrimL :: Integer -> Lit floatPrimL :: Rational -> Lit doublePrimL :: Rational -> Lit integerL :: Integer -> Lit charL :: Char -> Lit stringL :: String -> Lit stringPrimL :: [Word8] -> Lit rationalL :: Rational -> Lit litP :: Lit -> PatQ varP :: Name -> PatQ tupP :: [PatQ] -> PatQ unboxedTupP :: [PatQ] -> PatQ conP :: Name -> [PatQ] -> PatQ infixP :: PatQ -> Name -> PatQ -> PatQ uInfixP :: PatQ -> Name -> PatQ -> PatQ parensP :: PatQ -> PatQ tildeP :: PatQ -> PatQ bangP :: PatQ -> PatQ asP :: Name -> PatQ -> PatQ wildP :: PatQ recP :: Name -> [FieldPatQ] -> PatQ listP :: [PatQ] -> PatQ sigP :: PatQ -> TypeQ -> PatQ viewP :: ExpQ -> PatQ -> PatQ fieldPat :: Name -> PatQ -> FieldPatQ bindS :: PatQ -> ExpQ -> StmtQ letS :: [DecQ] -> StmtQ noBindS :: ExpQ -> StmtQ parS :: [[StmtQ]] -> StmtQ fromR :: ExpQ -> RangeQ fromThenR :: ExpQ -> ExpQ -> RangeQ fromToR :: ExpQ -> ExpQ -> RangeQ fromThenToR :: ExpQ -> ExpQ -> ExpQ -> RangeQ normalB :: ExpQ -> BodyQ guardedB :: [Q (Guard, Exp)] -> BodyQ normalG :: ExpQ -> GuardQ normalGE :: ExpQ -> ExpQ -> Q (Guard, Exp) patG :: [StmtQ] -> GuardQ patGE :: [StmtQ] -> ExpQ -> Q (Guard, Exp) -- | Use with caseE match :: PatQ -> BodyQ -> [DecQ] -> MatchQ -- | Use with funD clause :: [PatQ] -> BodyQ -> [DecQ] -> ClauseQ -- | Dynamically binding a variable (unhygenic) dyn :: String -> Q Exp global :: Name -> ExpQ varE :: Name -> ExpQ conE :: Name -> ExpQ litE :: Lit -> ExpQ appE :: ExpQ -> ExpQ -> ExpQ parensE :: ExpQ -> ExpQ uInfixE :: ExpQ -> ExpQ -> ExpQ -> ExpQ infixE :: Maybe ExpQ -> ExpQ -> Maybe ExpQ -> ExpQ infixApp :: ExpQ -> ExpQ -> ExpQ -> ExpQ sectionL :: ExpQ -> ExpQ -> ExpQ sectionR :: ExpQ -> ExpQ -> ExpQ lamE :: [PatQ] -> ExpQ -> ExpQ -- | Single-arg lambda lam1E :: PatQ -> ExpQ -> ExpQ lamCaseE :: [MatchQ] -> ExpQ tupE :: [ExpQ] -> ExpQ unboxedTupE :: [ExpQ] -> ExpQ condE :: ExpQ -> ExpQ -> ExpQ -> ExpQ multiIfE :: [Q (Guard, Exp)] -> ExpQ letE :: [DecQ] -> ExpQ -> ExpQ caseE :: ExpQ -> [MatchQ] -> ExpQ doE :: [StmtQ] -> ExpQ compE :: [StmtQ] -> ExpQ arithSeqE :: RangeQ -> ExpQ listE :: [ExpQ] -> ExpQ sigE :: ExpQ -> TypeQ -> ExpQ recConE :: Name -> [Q (Name, Exp)] -> ExpQ recUpdE :: ExpQ -> [Q (Name, Exp)] -> ExpQ stringE :: String -> ExpQ fieldExp :: Name -> ExpQ -> Q (Name, Exp) fromE :: ExpQ -> ExpQ fromThenE :: ExpQ -> ExpQ -> ExpQ fromToE :: ExpQ -> ExpQ -> ExpQ fromThenToE :: ExpQ -> ExpQ -> ExpQ -> ExpQ valD :: PatQ -> BodyQ -> [DecQ] -> DecQ funD :: Name -> [ClauseQ] -> DecQ tySynD :: Name -> [TyVarBndr] -> TypeQ -> DecQ dataD :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ newtypeD :: CxtQ -> Name -> [TyVarBndr] -> ConQ -> [Name] -> DecQ classD :: CxtQ -> Name -> [TyVarBndr] -> [FunDep] -> [DecQ] -> DecQ instanceD :: CxtQ -> TypeQ -> [DecQ] -> DecQ sigD :: Name -> TypeQ -> DecQ forImpD :: Callconv -> Safety -> String -> Name -> TypeQ -> DecQ infixLD :: Int -> Name -> DecQ infixRD :: Int -> Name -> DecQ infixND :: Int -> Name -> DecQ pragInlD :: Name -> Inline -> RuleMatch -> Phases -> DecQ pragSpecD :: Name -> TypeQ -> Phases -> DecQ pragSpecInlD :: Name -> TypeQ -> Inline -> Phases -> DecQ pragSpecInstD :: TypeQ -> DecQ pragRuleD :: String -> [RuleBndrQ] -> ExpQ -> ExpQ -> Phases -> DecQ familyNoKindD :: FamFlavour -> Name -> [TyVarBndr] -> DecQ familyKindD :: FamFlavour -> Name -> [TyVarBndr] -> Kind -> DecQ dataInstD :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ newtypeInstD :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ tySynInstD :: Name -> [TypeQ] -> TypeQ -> DecQ cxt :: [PredQ] -> CxtQ classP :: Name -> [TypeQ] -> PredQ equalP :: TypeQ -> TypeQ -> PredQ normalC :: Name -> [StrictTypeQ] -> ConQ recC :: Name -> [VarStrictTypeQ] -> ConQ infixC :: Q (Strict, Type) -> Name -> Q (Strict, Type) -> ConQ forallC :: [TyVarBndr] -> CxtQ -> ConQ -> ConQ forallT :: [TyVarBndr] -> CxtQ -> TypeQ -> TypeQ varT :: Name -> TypeQ conT :: Name -> TypeQ appT :: TypeQ -> TypeQ -> TypeQ arrowT :: TypeQ listT :: TypeQ litT :: TyLitQ -> TypeQ tupleT :: Int -> TypeQ unboxedTupleT :: Int -> TypeQ sigT :: TypeQ -> Kind -> TypeQ promotedT :: Name -> TypeQ promotedTupleT :: Int -> TypeQ promotedNilT :: TypeQ promotedConsT :: TypeQ isStrict, unpacked, notStrict :: Q Strict strictType :: Q Strict -> TypeQ -> StrictTypeQ varStrictType :: Name -> StrictTypeQ -> VarStrictTypeQ numTyLit :: Integer -> TyLitQ strTyLit :: String -> TyLitQ plainTV :: Name -> TyVarBndr kindedTV :: Name -> Kind -> TyVarBndr varK :: Name -> Kind conK :: Name -> Kind tupleK :: Int -> Kind arrowK :: Kind listK :: Kind appK :: Kind -> Kind -> Kind starK :: Kind constraintK :: Kind cCall, stdCall :: Callconv unsafe, interruptible, safe :: Safety funDep :: [Name] -> [Name] -> FunDep typeFam, dataFam :: FamFlavour ruleVar :: Name -> RuleBndrQ typedRuleVar :: Name -> TypeQ -> RuleBndrQ appsE :: [ExpQ] -> ExpQ module Language.Haskell.TH.Quote data QuasiQuoter QuasiQuoter :: (String -> Q Exp) -> (String -> Q Pat) -> (String -> Q Type) -> (String -> Q [Dec]) -> QuasiQuoter quoteExp :: QuasiQuoter -> String -> Q Exp quotePat :: QuasiQuoter -> String -> Q Pat quoteType :: QuasiQuoter -> String -> Q Type quoteDec :: QuasiQuoter -> String -> Q [Dec] dataToQa :: Data a => (Name -> k) -> (Lit -> Q q) -> (k -> [Q q] -> Q q) -> (forall b. Data b => b -> Maybe (Q q)) -> a -> Q q -- | dataToExpQ converts a value to a 'Q Exp' representation of the -- same value. It takes a function to handle type-specific cases. dataToExpQ :: Data a => (forall b. Data b => b -> Maybe (Q Exp)) -> a -> Q Exp -- | dataToPatQ converts a value to a 'Q Pat' representation of the -- same value. It takes a function to handle type-specific cases. dataToPatQ :: Data a => (forall b. Data b => b -> Maybe (Q Pat)) -> a -> Q Pat -- | quoteFile takes a QuasiQuoter and lifts it into one that -- read the data out of a file. For example, suppose asmq is an -- assembly-language quoter, so that you can write [asmq| ld r1, r2 |] as -- an expression. Then if you define asmq_f = quoteFile asmq, -- then the quote [asmq_f| foo.s |] will take input from file -- foo.s instead of the inline text quoteFile :: QuasiQuoter -> QuasiQuoter -- | Monadic front-end to Text.PrettyPrint module Language.Haskell.TH.PprLib type Doc = PprM Doc data PprM a -- | An empty document empty :: Doc -- | A ';' character semi :: Doc -- | A ',' character comma :: Doc -- | A : character colon :: Doc -- | A space character space :: Doc -- | A '=' character equals :: Doc -- | A -> string arrow :: Doc -- | A '(' character lparen :: Doc -- | A ')' character rparen :: Doc -- | A '[' character lbrack :: Doc -- | A ']' character rbrack :: Doc -- | A '{' character lbrace :: Doc -- | A '}' character rbrace :: Doc text :: String -> Doc char :: Char -> Doc ptext :: String -> Doc int :: Int -> Doc integer :: Integer -> Doc float :: Float -> Doc double :: Double -> Doc rational :: Rational -> Doc -- | Wrap document in (...) parens :: Doc -> Doc -- | Wrap document in [...] brackets :: Doc -> Doc -- | Wrap document in {...} braces :: Doc -> Doc -- | Wrap document in '...' quotes :: Doc -> Doc -- | Wrap document in "..." doubleQuotes :: Doc -> Doc -- | Beside (<>) :: Doc -> Doc -> Doc -- | Beside, separated by space (<+>) :: Doc -> Doc -> Doc -- | List version of <> hcat :: [Doc] -> Doc -- | List version of <+> hsep :: [Doc] -> Doc -- | Above; if there is no overlap it "dovetails" the two ($$) :: Doc -> Doc -> Doc -- | Above, without dovetailing. ($+$) :: Doc -> Doc -> Doc -- | List version of $$ vcat :: [Doc] -> Doc -- | Either hsep or vcat sep :: [Doc] -> Doc -- | Either hcat or vcat cat :: [Doc] -> Doc -- | "Paragraph fill" version of sep fsep :: [Doc] -> Doc -- | "Paragraph fill" version of cat fcat :: [Doc] -> Doc -- | Nested nest :: Int -> Doc -> Doc -- |
-- hang d1 n d2 = sep [d1, nest n d2] --hang :: Doc -> Int -> Doc -> Doc -- |
-- punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn] --punctuate :: Doc -> [Doc] -> [Doc] -- | Returns True if the document is empty isEmpty :: Doc -> PprM Bool to_HPJ_Doc :: Doc -> Doc pprName :: Name -> Doc pprName' :: NameIs -> Name -> Doc instance Monad PprM instance Show Doc -- | contains a prettyprinter for the Template Haskell datatypes module Language.Haskell.TH.Ppr nestDepth :: Int type Precedence = Int appPrec, noPrec, opPrec, unopPrec :: Precedence parensIf :: Bool -> Doc -> Doc pprint :: Ppr a => a -> String class Ppr a where ppr_list = vcat . map ppr ppr :: Ppr a => a -> Doc ppr_list :: Ppr a => [a] -> Doc ppr_sig :: Name -> Type -> Doc pprFixity :: Name -> Fixity -> Doc pprInfixExp :: Exp -> Doc pprExp :: Precedence -> Exp -> Doc pprFields :: [(Name, Exp)] -> Doc pprMaybeExp :: Precedence -> Maybe Exp -> Doc pprGuarded :: Doc -> (Guard, Exp) -> Doc pprBody :: Bool -> Body -> Doc pprLit :: Precedence -> Lit -> Doc bytesToString :: [Word8] -> String pprString :: String -> Doc pprPat :: Precedence -> Pat -> Doc ppr_dec :: Bool -> Dec -> Doc ppr_data :: Doc -> Cxt -> Name -> Doc -> [Con] -> [Name] -> Doc ppr_newtype :: Doc -> Cxt -> Name -> Doc -> Con -> [Name] -> Doc ppr_tySyn :: Doc -> Name -> Doc -> Type -> Doc pprVarStrictType :: (Name, Strict, Type) -> Doc pprStrictType :: (Strict, Type) -> Doc pprParendType :: Type -> Doc pprTyApp :: (Type, [Type]) -> Doc pprFunArgType :: Type -> Doc split :: Type -> (Type, [Type]) pprTyLit :: TyLit -> Doc pprCxt :: Cxt -> Doc where_clause :: [Dec] -> Doc showtextl :: Show a => a -> Doc hashParens :: Doc -> Doc quoteParens :: Doc -> Doc instance Ppr Range instance Ppr Pred instance Ppr TyVarBndr instance Ppr TyLit instance Ppr Type instance Ppr Con instance Ppr Clause instance Ppr RuleBndr instance Ppr Phases instance Ppr RuleMatch instance Ppr Inline instance Ppr Pragma instance Ppr Foreign instance Ppr FamFlavour instance Ppr FunDep instance Ppr Dec instance Ppr Pat instance Ppr Match instance Ppr Stmt instance Ppr Exp instance Ppr Info instance Ppr Name instance Ppr a => Ppr [a] -- | The public face of Template Haskell -- -- For other documentation, refer to: -- http://www.haskell.org/haskellwiki/Template_Haskell module Language.Haskell.TH data Q a runQ :: Quasi m => Q a -> m a -- | Report an error to the user, but allow the current splice's -- computation to carry on. To abort the computation, use fail. reportError :: String -> Q () -- | Report a warning to the user, and carry on. reportWarning :: String -> Q () -- | Report an error (True) or warning (False), but carry on; use -- fail to stop. report :: Bool -> String -> Q () -- | Recover from errors raised by reportError or fail. recover :: Q a -> Q a -> Q a -- | The location at which this computation is spliced. location :: Q Loc data Loc Loc :: String -> String -> String -> CharPos -> CharPos -> Loc loc_filename :: Loc -> String loc_package :: Loc -> String loc_module :: Loc -> String loc_start :: Loc -> CharPos loc_end :: Loc -> CharPos -- | The runIO function lets you run an I/O computation in the -- Q monad. Take care: you are guaranteed the ordering of calls to -- runIO within a single Q computation, but not about the -- order in which splices are run. -- -- Note: for various murky reasons, stdout and stderr handles are not -- necesarily flushed when the compiler finishes running, so you should -- flush them yourself. runIO :: IO a -> Q a -- | reify looks up information about the Name. -- -- It is sometimes useful to construct the argument name using -- lookupTypeName or lookupValueName to ensure that we are -- reifying from the right namespace. For instance, in this context: -- --
-- data D = D ---- -- which D does reify (mkName "D") return information -- about? (Answer: D-the-type, but don't rely on it.) To ensure -- we get information about D-the-value, use -- lookupValueName: -- --
-- do -- Just nm <- lookupValueName "D" -- reify nm ---- -- and to get information about D-the-type, use -- lookupTypeName. reify :: Name -> Q Info -- | Obtained from reify in the Q Monad. data Info -- | A class, with a list of its visible instances ClassI :: Dec -> [InstanceDec] -> Info -- | A class method ClassOpI :: Name -> Type -> ParentName -> Fixity -> Info -- | A "plain" type constructor. "Fancier" type constructors are returned -- using PrimTyConI or FamilyI as appropriate TyConI :: Dec -> Info -- | A type or data family, with a list of its visible instances FamilyI :: Dec -> [InstanceDec] -> Info -- | A "primitive" type constructor, which can't be expressed with a -- Dec. Examples: (->), Int#. PrimTyConI :: Name -> Arity -> Unlifted -> Info -- | A data constructor DataConI :: Name -> Type -> ParentName -> Fixity -> Info -- | A "value" variable (as opposed to a type variable, see TyVarI). -- -- The Maybe Dec field contains Just the declaration -- which defined the variable -- including the RHS of the declaration -- -- or else Nothing, in the case where the RHS is unavailable to -- the compiler. At present, this value is _always_ Nothing: -- returning the RHS has not yet been implemented because of lack of -- interest. VarI :: Name -> Type -> (Maybe Dec) -> Fixity -> Info -- | A type variable. -- -- The Type field contains the type which underlies the -- variable. At present, this is always VarT theName, but -- future changes may permit refinement of this. TyVarI :: Name -> Type -> Info -- | InstanceDec desribes a single instance of a class or type -- function. It is just a Dec, but guaranteed to be one of the -- following: -- --
-- f = [| pi + $(varE (mkName "pi")) |] -- ... -- g = let pi = 3 in $f ---- -- In this case, g is desugared to -- --
-- g = Prelude.pi + 3 ---- -- Note that mkName may be used with qualified names: -- --
-- mkName "Prelude.pi" ---- -- See also dyn for a useful combinator. The above example could -- be rewritten using dyn as -- --
-- f = [| pi + $(dyn "pi") |] --mkName :: String -> Name -- | Generate a fresh name, which cannot be captured. -- -- For example, this: -- --
-- f = $(do -- nm1 <- newName "x" -- let nm2 = mkName "x" -- return (LamE [VarP nm1] (LamE [VarP nm2] (VarE nm1))) -- ) ---- -- will produce the splice -- --
-- f = \x0 -> \x -> x0 ---- -- In particular, the occurrence VarE nm1 refers to the binding -- VarP nm1, and is not captured by the binding VarP -- nm2. -- -- Although names generated by newName cannot be -- captured, they can capture other names. For example, this: -- --
-- g = $(do -- nm1 <- newName "x" -- let nm2 = mkName "x" -- return (LamE [VarP nm2] (LamE [VarP nm1] (VarE nm2))) -- ) ---- -- will produce the splice -- --
-- g = \x -> \x0 -> x0 ---- -- since the occurrence VarE nm2 is captured by the innermost -- binding of x, namely VarP nm1. newName :: String -> Q Name -- | The name without its module prefix nameBase :: Name -> String -- | Module prefix of a name, if it exists nameModule :: Name -> Maybe String -- | Tuple type constructor tupleTypeName :: Int -> Name -- | Tuple data constructor tupleDataName :: Int -> Name -- | Unboxed tuple type constructor unboxedTupleTypeName :: Int -> Name -- | Unboxed tuple data constructor unboxedTupleDataName :: Int -> Name data Dec -- |
-- { f p1 p2 = b where decs }
--
FunD :: Name -> [Clause] -> Dec
-- |
-- { p = b where decs }
--
ValD :: Pat -> Body -> [Dec] -> Dec
-- |
-- { data Cxt x => T x = A x | B (T x)
-- deriving (Z,W)}
--
DataD :: Cxt -> Name -> [TyVarBndr] -> [Con] -> [Name] -> Dec
-- |
-- { newtype Cxt x => T x = A (B x)
-- deriving (Z,W)}
--
NewtypeD :: Cxt -> Name -> [TyVarBndr] -> Con -> [Name] -> Dec
-- |
-- { type T x = (x,x) }
--
TySynD :: Name -> [TyVarBndr] -> Type -> Dec
-- |
-- { class Eq a => Ord a where ds }
--
ClassD :: Cxt -> Name -> [TyVarBndr] -> [FunDep] -> [Dec] -> Dec
-- |
-- { instance Show w => Show [w]
-- where ds }
--
InstanceD :: Cxt -> Type -> [Dec] -> Dec
-- |
-- { length :: [a] -> Int }
--
SigD :: Name -> Type -> Dec
-- |
-- { foreign import ... }
-- { foreign export ... }
--
ForeignD :: Foreign -> Dec
-- |
-- { infix 3 foo }
--
InfixD :: Fixity -> Name -> Dec
-- |
-- { {--} }
--
PragmaD :: Pragma -> Dec
-- |
-- { type family T a b c :: * }
--
FamilyD :: FamFlavour -> Name -> [TyVarBndr] -> (Maybe Kind) -> Dec
-- |
-- { data instance Cxt x => T [x] = A x
-- | B (T x)
-- deriving (Z,W)}
--
DataInstD :: Cxt -> Name -> [Type] -> [Con] -> [Name] -> Dec
-- |
-- { newtype instance Cxt x => T [x] = A (B x)
-- deriving (Z,W)}
--
NewtypeInstD :: Cxt -> Name -> [Type] -> Con -> [Name] -> Dec
-- |
-- { type instance T (Maybe x) = (x,x) }
--
TySynInstD :: Name -> [Type] -> Type -> Dec
data Con
-- | -- C Int a --NormalC :: Name -> [StrictType] -> Con -- |
-- C { v :: Int, w :: a }
--
RecC :: Name -> [VarStrictType] -> Con
-- | -- Int :+ a --InfixC :: StrictType -> Name -> StrictType -> Con -- |
-- forall a. Eq a => C [a] --ForallC :: [TyVarBndr] -> Cxt -> Con -> Con data Clause -- |
-- f { p1 p2 = body where decs }
--
Clause :: [Pat] -> Body -> [Dec] -> Clause
data Strict
IsStrict :: Strict
NotStrict :: Strict
Unpacked :: Strict
data Foreign
ImportF :: Callconv -> Safety -> String -> Name -> Type -> Foreign
ExportF :: Callconv -> String -> Name -> Type -> Foreign
data Callconv
CCall :: Callconv
StdCall :: Callconv
data Safety
Unsafe :: Safety
Safe :: Safety
Interruptible :: Safety
data Pragma
InlineP :: Name -> Inline -> RuleMatch -> Phases -> Pragma
SpecialiseP :: Name -> Type -> (Maybe Inline) -> Phases -> Pragma
SpecialiseInstP :: Type -> Pragma
RuleP :: String -> [RuleBndr] -> Exp -> Exp -> Phases -> Pragma
data Inline
NoInline :: Inline
Inline :: Inline
Inlinable :: Inline
data RuleMatch
ConLike :: RuleMatch
FunLike :: RuleMatch
data Phases
AllPhases :: Phases
FromPhase :: Int -> Phases
BeforePhase :: Int -> Phases
data RuleBndr
RuleVar :: Name -> RuleBndr
TypedRuleVar :: Name -> Type -> RuleBndr
data FunDep
FunDep :: [Name] -> [Name] -> FunDep
data FamFlavour
TypeFam :: FamFlavour
DataFam :: FamFlavour
data Fixity
Fixity :: Int -> FixityDirection -> Fixity
data FixityDirection
InfixL :: FixityDirection
InfixR :: FixityDirection
InfixN :: FixityDirection
-- | Default fixity: infixl 9
defaultFixity :: Fixity
-- | Highest allowed operator precedence for Fixity constructor
-- (answer: 9)
maxPrecedence :: Int
data Exp
-- |
-- { x }
--
VarE :: Name -> Exp
-- |
-- data T1 = C1 t1 t2; p = {C1} e1 e2
--
ConE :: Name -> Exp
-- |
-- { 5 or c}
--
LitE :: Lit -> Exp
-- |
-- { f x }
--
AppE :: Exp -> Exp -> Exp
-- |
-- {x + y} or {(x+)} or {(+ x)} or {(+)}
--
InfixE :: (Maybe Exp) -> Exp -> (Maybe Exp) -> Exp
-- |
-- {x + y}
--
--
-- See Language.Haskell.TH.Syntax#infix
UInfixE :: Exp -> Exp -> Exp -> Exp
-- |
-- { (e) }
--
--
-- See Language.Haskell.TH.Syntax#infix
ParensE :: Exp -> Exp
-- |
-- { p1 p2 -> e }
--
LamE :: [Pat] -> Exp -> Exp
-- |
-- { case m1; m2 }
--
LamCaseE :: [Match] -> Exp
-- |
-- { (e1,e2) }
--
TupE :: [Exp] -> Exp
-- |
-- { () }
--
UnboxedTupE :: [Exp] -> Exp
-- |
-- { if e1 then e2 else e3 }
--
CondE :: Exp -> Exp -> Exp -> Exp
-- |
-- { if | g1 -> e1 | g2 -> e2 }
--
MultiIfE :: [(Guard, Exp)] -> Exp
-- |
-- { let x=e1; y=e2 in e3 }
--
LetE :: [Dec] -> Exp -> Exp
-- |
-- { case e of m1; m2 }
--
CaseE :: Exp -> [Match] -> Exp
-- |
-- { do { p <- e1; e2 } }
--
DoE :: [Stmt] -> Exp
-- |
-- { [ (x,y) | x <- xs, y <- ys ] }
--
--
-- The result expression of the comprehension is the last of the
-- Stmts, and should be a NoBindS.
--
-- E.g. translation:
--
-- -- [ f x | x <- xs ] ---- --
-- CompE [BindS (VarP x) (VarE xs), NoBindS (AppE (VarE f) (VarE x))] --CompE :: [Stmt] -> Exp -- |
-- { [ 1 ,2 .. 10 ] }
--
ArithSeqE :: Range -> Exp
-- |
-- { [1,2,3] }
--
ListE :: [Exp] -> Exp
-- |
-- { e :: t }
--
SigE :: Exp -> Type -> Exp
-- |
-- { T { x = y, z = w } }
--
RecConE :: Name -> [FieldExp] -> Exp
-- |
-- { (f x) { z = w } }
--
RecUpdE :: Exp -> [FieldExp] -> Exp
data Match
-- |
-- case e of { pat -> body where decs }
--
Match :: Pat -> Body -> [Dec] -> Match
data Body
-- |
-- f p { | e1 = e2
-- | e3 = e4 }
-- where ds
--
GuardedB :: [(Guard, Exp)] -> Body
-- |
-- f p { = e } where ds
--
NormalB :: Exp -> Body
data Guard
-- |
-- f x { | odd x } = x
--
NormalG :: Exp -> Guard
-- |
-- f x { | Just y <- x, Just z <- y } = z
--
PatG :: [Stmt] -> Guard
data Stmt
BindS :: Pat -> Exp -> Stmt
LetS :: [Dec] -> Stmt
NoBindS :: Exp -> Stmt
ParS :: [[Stmt]] -> Stmt
data Range
FromR :: Exp -> Range
FromThenR :: Exp -> Exp -> Range
FromToR :: Exp -> Exp -> Range
FromThenToR :: Exp -> Exp -> Exp -> Range
data Lit
CharL :: Char -> Lit
StringL :: String -> Lit
-- | Used for overloaded and non-overloaded literals. We don't have a good
-- way to represent non-overloaded literals at the moment. Maybe that
-- doesn't matter?
IntegerL :: Integer -> Lit
RationalL :: Rational -> Lit
IntPrimL :: Integer -> Lit
WordPrimL :: Integer -> Lit
FloatPrimL :: Rational -> Lit
DoublePrimL :: Rational -> Lit
-- | A primitive C-style string, type Addr#
StringPrimL :: [Word8] -> Lit
-- | Pattern in Haskell given in {}
data Pat
-- |
-- { 5 or c }
--
LitP :: Lit -> Pat
-- |
-- { x }
--
VarP :: Name -> Pat
-- |
-- { (p1,p2) }
--
TupP :: [Pat] -> Pat
-- |
-- { () }
--
UnboxedTupP :: [Pat] -> Pat
-- |
-- data T1 = C1 t1 t2; {C1 p1 p1} = e
--
ConP :: Name -> [Pat] -> Pat
-- |
-- foo ({x :+ y}) = e
--
InfixP :: Pat -> Name -> Pat -> Pat
-- |
-- foo ({x :+ y}) = e
--
--
-- See Language.Haskell.TH.Syntax#infix
UInfixP :: Pat -> Name -> Pat -> Pat
-- |
-- {(p)}
--
--
-- See Language.Haskell.TH.Syntax#infix
ParensP :: Pat -> Pat
-- |
-- { ~p }
--
TildeP :: Pat -> Pat
-- |
-- { !p }
--
BangP :: Pat -> Pat
-- |
-- { x @ p }
--
AsP :: Name -> Pat -> Pat
-- |
-- { _ }
--
WildP :: Pat
-- |
-- f (Pt { pointx = x }) = g x
--
RecP :: Name -> [FieldPat] -> Pat
-- |
-- { [1,2,3] }
--
ListP :: [Pat] -> Pat
-- |
-- { p :: t }
--
SigP :: Pat -> Type -> Pat
-- |
-- { e -> p }
--
ViewP :: Exp -> Pat -> Pat
type FieldExp = (Name, Exp)
type FieldPat = (Name, Pat)
data Type
-- | -- forall <vars>. <ctxt> -> <type> --ForallT :: [TyVarBndr] -> Cxt -> Type -> Type -- |
-- T a b --AppT :: Type -> Type -> Type -- |
-- t :: k --SigT :: Type -> Kind -> Type -- |
-- a --VarT :: Name -> Type -- |
-- T --ConT :: Name -> Type -- |
-- 'T --PromotedT :: Name -> Type -- |
-- (,), (,,), etc. --TupleT :: Int -> Type -- |
-- (), (), etc. --UnboxedTupleT :: Int -> Type -- |
-- -> --ArrowT :: Type -- |
-- [] --ListT :: Type -- |
-- '(), '(,), '(,,), etc. --PromotedTupleT :: Int -> Type -- |
-- '[] --PromotedNilT :: Type -- |
-- (':)
--
PromotedConsT :: Type
-- | -- * --StarT :: Type -- |
-- Constraint --ConstraintT :: Type -- |
-- 0,1,2, etc. --LitT :: TyLit -> Type data TyVarBndr -- |
-- a --PlainTV :: Name -> TyVarBndr -- |
-- (a :: k) --KindedTV :: Name -> Kind -> TyVarBndr data TyLit -- |
-- 2 --NumTyLit :: Integer -> TyLit -- |
-- Hello --StrTyLit :: String -> TyLit -- | To avoid duplication between kinds and types, they are defined to be -- the same. Naturally, you would never have a type be StarT and -- you would never have a kind be SigT, but many of the other -- constructors are shared. Note that the kind Bool is denoted -- with ConT, not PromotedT. Similarly, tuple kinds are -- made with TupleT, not PromotedTupleT. type Kind = Type type Cxt = [Pred] data Pred -- |
-- Eq (Int, a) --ClassP :: Name -> [Type] -> Pred -- |
-- F a ~ Bool --EqualP :: Type -> Type -> Pred type InfoQ = Q Info type ExpQ = Q Exp type DecQ = Q Dec type DecsQ = Q [Dec] type ConQ = Q Con type TypeQ = Q Type type TyLitQ = Q TyLit type CxtQ = Q Cxt type PredQ = Q Pred 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 StrictTypeQ = Q StrictType type VarStrictTypeQ = Q VarStrictType type PatQ = Q Pat type FieldPatQ = Q FieldPat type RuleBndrQ = Q RuleBndr intPrimL :: Integer -> Lit wordPrimL :: Integer -> Lit floatPrimL :: Rational -> Lit doublePrimL :: Rational -> Lit integerL :: Integer -> Lit rationalL :: Rational -> Lit charL :: Char -> Lit stringL :: String -> Lit stringPrimL :: [Word8] -> Lit litP :: Lit -> PatQ varP :: Name -> PatQ tupP :: [PatQ] -> PatQ conP :: Name -> [PatQ] -> PatQ uInfixP :: PatQ -> Name -> PatQ -> PatQ parensP :: PatQ -> PatQ infixP :: PatQ -> Name -> PatQ -> PatQ tildeP :: PatQ -> PatQ bangP :: PatQ -> PatQ asP :: Name -> PatQ -> PatQ wildP :: PatQ recP :: Name -> [FieldPatQ] -> PatQ listP :: [PatQ] -> PatQ sigP :: PatQ -> TypeQ -> PatQ viewP :: ExpQ -> PatQ -> PatQ fieldPat :: Name -> PatQ -> FieldPatQ normalB :: ExpQ -> BodyQ guardedB :: [Q (Guard, Exp)] -> BodyQ normalG :: ExpQ -> GuardQ normalGE :: ExpQ -> ExpQ -> Q (Guard, Exp) patG :: [StmtQ] -> GuardQ patGE :: [StmtQ] -> ExpQ -> Q (Guard, Exp) -- | Use with caseE match :: PatQ -> BodyQ -> [DecQ] -> MatchQ -- | Use with funD clause :: [PatQ] -> BodyQ -> [DecQ] -> ClauseQ -- | Dynamically binding a variable (unhygenic) dyn :: String -> Q Exp global :: Name -> ExpQ varE :: Name -> ExpQ conE :: Name -> ExpQ litE :: Lit -> ExpQ appE :: ExpQ -> ExpQ -> ExpQ uInfixE :: ExpQ -> ExpQ -> ExpQ -> ExpQ parensE :: ExpQ -> ExpQ infixE :: Maybe ExpQ -> ExpQ -> Maybe ExpQ -> ExpQ infixApp :: ExpQ -> ExpQ -> ExpQ -> ExpQ sectionL :: ExpQ -> ExpQ -> ExpQ sectionR :: ExpQ -> ExpQ -> ExpQ lamE :: [PatQ] -> ExpQ -> ExpQ -- | Single-arg lambda lam1E :: PatQ -> ExpQ -> ExpQ lamCaseE :: [MatchQ] -> ExpQ tupE :: [ExpQ] -> ExpQ condE :: ExpQ -> ExpQ -> ExpQ -> ExpQ multiIfE :: [Q (Guard, Exp)] -> ExpQ letE :: [DecQ] -> ExpQ -> ExpQ caseE :: ExpQ -> [MatchQ] -> ExpQ appsE :: [ExpQ] -> ExpQ listE :: [ExpQ] -> ExpQ sigE :: ExpQ -> TypeQ -> ExpQ recConE :: Name -> [Q (Name, Exp)] -> ExpQ recUpdE :: ExpQ -> [Q (Name, Exp)] -> ExpQ stringE :: String -> ExpQ fieldExp :: Name -> ExpQ -> Q (Name, Exp) fromE :: ExpQ -> ExpQ fromThenE :: ExpQ -> ExpQ -> ExpQ fromToE :: ExpQ -> ExpQ -> ExpQ fromThenToE :: ExpQ -> ExpQ -> ExpQ -> ExpQ arithSeqE :: RangeQ -> ExpQ fromR :: ExpQ -> RangeQ fromThenR :: ExpQ -> ExpQ -> RangeQ fromToR :: ExpQ -> ExpQ -> RangeQ fromThenToR :: ExpQ -> ExpQ -> ExpQ -> RangeQ doE :: [StmtQ] -> ExpQ compE :: [StmtQ] -> ExpQ bindS :: PatQ -> ExpQ -> StmtQ letS :: [DecQ] -> StmtQ noBindS :: ExpQ -> StmtQ parS :: [[StmtQ]] -> StmtQ forallT :: [TyVarBndr] -> CxtQ -> TypeQ -> TypeQ varT :: Name -> TypeQ conT :: Name -> TypeQ appT :: TypeQ -> TypeQ -> TypeQ arrowT :: TypeQ listT :: TypeQ tupleT :: Int -> TypeQ sigT :: TypeQ -> Kind -> TypeQ litT :: TyLitQ -> TypeQ promotedT :: Name -> TypeQ promotedTupleT :: Int -> TypeQ promotedNilT :: TypeQ promotedConsT :: TypeQ numTyLit :: Integer -> TyLitQ strTyLit :: String -> TyLitQ isStrict, notStrict :: Q Strict strictType :: Q Strict -> TypeQ -> StrictTypeQ varStrictType :: Name -> StrictTypeQ -> VarStrictTypeQ cxt :: [PredQ] -> CxtQ classP :: Name -> [TypeQ] -> PredQ equalP :: TypeQ -> TypeQ -> PredQ normalC :: Name -> [StrictTypeQ] -> ConQ recC :: Name -> [VarStrictTypeQ] -> ConQ infixC :: Q (Strict, Type) -> Name -> Q (Strict, Type) -> ConQ forallC :: [TyVarBndr] -> CxtQ -> ConQ -> ConQ varK :: Name -> Kind conK :: Name -> Kind tupleK :: Int -> Kind arrowK :: Kind listK :: Kind appK :: Kind -> Kind -> Kind starK :: Kind constraintK :: Kind valD :: PatQ -> BodyQ -> [DecQ] -> DecQ funD :: Name -> [ClauseQ] -> DecQ tySynD :: Name -> [TyVarBndr] -> TypeQ -> DecQ dataD :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ newtypeD :: CxtQ -> Name -> [TyVarBndr] -> ConQ -> [Name] -> DecQ classD :: CxtQ -> Name -> [TyVarBndr] -> [FunDep] -> [DecQ] -> DecQ instanceD :: CxtQ -> TypeQ -> [DecQ] -> DecQ sigD :: Name -> TypeQ -> DecQ familyNoKindD :: FamFlavour -> Name -> [TyVarBndr] -> DecQ familyKindD :: FamFlavour -> Name -> [TyVarBndr] -> Kind -> DecQ dataInstD :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ newtypeInstD :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ tySynInstD :: Name -> [TypeQ] -> TypeQ -> DecQ typeFam, dataFam :: FamFlavour cCall, stdCall :: Callconv unsafe, safe :: Safety forImpD :: Callconv -> Safety -> String -> Name -> TypeQ -> DecQ ruleVar :: Name -> RuleBndrQ typedRuleVar :: Name -> TypeQ -> RuleBndrQ pragInlD :: Name -> Inline -> RuleMatch -> Phases -> DecQ pragSpecD :: Name -> TypeQ -> Phases -> DecQ pragSpecInlD :: Name -> TypeQ -> Inline -> Phases -> DecQ pragSpecInstD :: TypeQ -> DecQ pragRuleD :: String -> [RuleBndrQ] -> ExpQ -> ExpQ -> Phases -> DecQ class Ppr a where ppr_list = vcat . map ppr ppr :: Ppr a => a -> Doc ppr_list :: Ppr a => [a] -> Doc pprint :: Ppr a => a -> String pprExp :: Precedence -> Exp -> Doc pprLit :: Precedence -> Lit -> Doc pprPat :: Precedence -> Pat -> Doc pprParendType :: Type -> Doc