haskell-src-meta-0.0.6: Parse source to template-haskell abstract syntax.Source codeContentsIndex
Language.Haskell.Meta.Utils
Description
This module is a staging ground for to-be-organized-and-merged-nicely code.
Synopsis
cleanNames :: Data a => a -> a
pretty :: Show a => a -> String
pp :: (Data a, Ppr a) => a -> String
ppDoc :: (Data a, Ppr a) => a -> Doc
gpretty :: Data a => a -> String
unQ :: Q a -> a
nameToRawCodeStr :: Name -> String
(|$|) :: ExpQ -> ExpQ -> ExpQ
(|.|) :: ExpQ -> ExpQ -> ExpQ
(|->|) :: TypeQ -> TypeQ -> TypeQ
unForall :: Type -> Type
functionT :: [TypeQ] -> TypeQ
mkVarT :: String -> TypeQ
myNames :: [Name]
renameT :: [(Name, Name)] -> [Name] -> Type -> (Type, [(Name, Name)], [Name])
applyT :: Type -> Type -> Type
substT :: [(Name, Type)] -> [Name] -> Type -> Type
deriveLift :: Name -> Q Dec
deriveLiftPretty :: Name -> Q String
splitCon :: Con -> (Name, [Type])
strictTypeTy :: StrictType -> Type
varStrictTypeTy :: VarStrictType -> Type
conTypes :: Con -> [Type]
conToConType :: Type -> Con -> Type
decCons :: Dec -> [Con]
decTyVars :: Dec -> [Name]
decName :: Dec -> Maybe Name
foreignName :: Foreign -> Name
unwindT :: Type -> [Type]
unwindE :: Exp -> [Exp]
arityT :: Type -> Int
typeToName :: Type -> Maybe Name
nameSpaceOf :: Name -> Maybe NameSpace
conName :: Con -> Name
recCName :: Con -> Maybe Name
dataDCons :: Dec -> [Con]
fromDataConI :: Info -> Q (Maybe Exp)
fromTyConI :: Info -> Maybe Dec
mkFunD :: Name -> [Pat] -> Exp -> Dec
mkClauseQ :: [PatQ] -> ExpQ -> ClauseQ
data Quoter a = Quoter {
expQ :: Lift a => String -> Q a
patQ :: Show a => String -> Q a
}
quasify :: (Show a, Lift a) => Quoter a -> QuasiQuoter
toExpQ :: Lift a => (String -> Q a) -> String -> ExpQ
toPatQ :: Show a => (String -> Q a) -> String -> PatQ
showToPatQ :: Show a => a -> PatQ
eitherQ :: (e -> String) -> Either e a -> Q a
normalizeT :: Data a => a -> a
Documentation
cleanNames :: Data a => a -> aSource
pretty :: Show a => a -> StringSource
The type passed in must have a Show instance which produces a valid Haskell expression. Returns an empty String if this is not the case. This is not TH-specific, but useful in general.
pp :: (Data a, Ppr a) => a -> StringSource
ppDoc :: (Data a, Ppr a) => a -> DocSource
gpretty :: Data a => a -> StringSource
unQ :: Q a -> aSource
unQ = unsafePerformIO . runQ
nameToRawCodeStr :: Name -> StringSource
(|$|) :: ExpQ -> ExpQ -> ExpQSource
(|.|) :: ExpQ -> ExpQ -> ExpQSource
(|->|) :: TypeQ -> TypeQ -> TypeQSource
unForall :: Type -> TypeSource
functionT :: [TypeQ] -> TypeQSource
mkVarT :: String -> TypeQSource
myNames :: [Name]Source
renameT :: [(Name, Name)] -> [Name] -> Type -> (Type, [(Name, Name)], [Name])Source
applyT :: Type -> Type -> TypeSource
substT :: [(Name, Type)] -> [Name] -> Type -> TypeSource
deriveLift :: Name -> Q DecSource
Stolen from Igloo's th-lift.
deriveLiftPretty :: Name -> Q StringSource
Produces pretty code suitable for human consumption.
splitCon :: Con -> (Name, [Type])Source
strictTypeTy :: StrictType -> TypeSource
varStrictTypeTy :: VarStrictType -> TypeSource
conTypes :: Con -> [Type]Source
conToConType :: Type -> Con -> TypeSource
decCons :: Dec -> [Con]Source
decTyVars :: Dec -> [Name]Source
decName :: Dec -> Maybe NameSource
foreignName :: Foreign -> NameSource
unwindT :: Type -> [Type]Source
unwindE :: Exp -> [Exp]Source
arityT :: Type -> IntSource
The arity of a Type.
typeToName :: Type -> Maybe NameSource
nameSpaceOf :: Name -> Maybe NameSpaceSource
Randomly useful.
conName :: Con -> NameSource
recCName :: Con -> Maybe NameSource
dataDCons :: Dec -> [Con]Source
fromDataConI :: Info -> Q (Maybe Exp)Source
fromTyConI :: Info -> Maybe DecSource
mkFunD :: Name -> [Pat] -> Exp -> DecSource
mkClauseQ :: [PatQ] -> ExpQ -> ClauseQSource
data Quoter a Source
The strategy for producing QuasiQuoters which this datatype aims to facilitate is as follows. Given a collection of datatypes which make up the to-be-quasiquoted languages AST, make each type in this collection an instance of at least Show and Lift. Now, assuming parsePat and parseExp, both of type String -> Q a (where a is the top level type of the AST), are the pair of functions you wish to use for parsing in pattern and expression context respectively, put them inside a Quoter datatype and pass this to quasify.
Constructors
Quoter
expQ :: Lift a => String -> Q a
patQ :: Show a => String -> Q a
quasify :: (Show a, Lift a) => Quoter a -> QuasiQuoterSource
toExpQ :: Lift a => (String -> Q a) -> String -> ExpQSource
toPatQ :: Show a => (String -> Q a) -> String -> PatQSource
showToPatQ :: Show a => a -> PatQSource
eitherQ :: (e -> String) -> Either e a -> Q aSource
normalizeT :: Data a => a -> aSource
Produced by Haddock version 2.4.2