haskell-src-meta- Parse source to template-haskell abstract syntax.

Safe HaskellNone



This module is a staging ground for to-be-organized-and-merged-nicely code.



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

unQ :: Q a -> aSource

unQ = unsafePerformIO . runQ

myNames :: [Name]Source

Infinite list of names composed of lowercase letters

renameThings :: (t1 -> t2 -> t -> (a, t1, t2)) -> t1 -> t2 -> [a] -> [t] -> ([a], t1, t2)Source

Generalisation of renameTs

renameTs :: [(Name, Name)] -> [Name] -> [Type] -> [Type] -> ([Type], [(Name, Name)], [Name])Source

renameT applied to a list of types

renameT :: [(Name, Name)] -> [Name] -> Type -> (Type, [(Name, Name)], [Name])Source

Rename type variables in the Type according to the given association list. Normalise constructor names (remove qualification, etc.) If a name is not found in the association list, replace it with one from the fresh names list, and add this translation to the returned list. The fresh names list should be infinite; myNames is a good example.

normaliseName :: Name -> NameSource

Remove qualification, etc.

substT :: [(Name, Type)] -> [Name] -> Type -> TypeSource

deriveLiftPretty :: Name -> Q StringSource

Produces pretty code suitable for human consumption.

arityT :: Type -> IntSource

The arity of a Type.

nameSpaceOf :: Name -> Maybe NameSpaceSource

Randomly useful.

mkFunD :: Name -> [Pat] -> Exp -> DecSource

toExpQ :: Lift a => (String -> Q a) -> String -> ExpQSource

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.

toPatQ :: Show a => (String -> Q a) -> String -> PatQSource

eitherQ :: (e -> String) -> Either e a -> Q aSource

normalizeT :: Data a => a -> aSource