| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Haskell.Meta.Utils
Contents
Description
This module is a staging ground for to-be-organized-and-merged-nicely code.
Synopsis
- applyT :: Type -> Type -> Type
- arityT :: Type -> Int
- cleanNames :: Data a => a -> a
- conName :: Con -> Name
- conToConType :: Type -> Con -> Type
- conTypes :: Con -> [Type]
- dataDCons :: Dec -> [Con]
- decCons :: Dec -> [Con]
- decName :: Dec -> Maybe Name
- decTyVars :: Dec -> [TyVarBndrVis]
- eitherQ :: (e -> String) -> Either e a -> Q a
- foreignName :: Foreign -> Name
- fromDataConI :: Info -> Q (Maybe Exp)
- fromTyConI :: Info -> Maybe Dec
- functionT :: [TypeQ] -> TypeQ
- gpretty :: Data a => a -> String
- mkClauseQ :: [PatQ] -> ExpQ -> ClauseQ
- mkFunD :: Name -> [Pat] -> Exp -> Dec
- mkVarT :: String -> TypeQ
- myNames :: [Name]
- nameSpaceOf :: Name -> Maybe NameSpace
- nameToRawCodeStr :: Name -> String
- normaliseName :: Name -> Name
- normalizeT :: Data a => a -> a
- pp :: (Data a, Ppr a) => a -> String
- ppDoc :: (Data a, Ppr a) => a -> Doc
- pretty :: Show a => a -> String
- recCName :: Con -> Maybe Name
- renameT :: [(Name, Name)] -> [Name] -> Type -> (Type, [(Name, Name)], [Name])
- renameThings :: (t1 -> t2 -> a1 -> (a2, t1, t2)) -> t1 -> t2 -> [a2] -> [a1] -> ([a2], t1, t2)
- renameTs :: [(Name, Name)] -> [Name] -> [Type] -> [Type] -> ([Type], [(Name, Name)], [Name])
- showToPatQ :: Show a => a -> PatQ
- splitCon :: Con -> (Name, [Type])
- strictTypeTy :: StrictType -> Type
- substT :: [(Name, Type)] -> [Name] -> Type -> Type
- toExpQ :: Lift a => (String -> Q a) -> String -> ExpQ
- toPatQ :: Show a => (String -> Q a) -> String -> PatQ
- typeToName :: Type -> Maybe Name
- unForall :: Type -> Type
- unsafeRunQ :: Q a -> a
- unwindE :: Exp -> [Exp]
- unwindT :: Type -> [Type]
- varStrictTypeTy :: VarStrictType -> Type
- (|$|) :: ExpQ -> ExpQ -> ExpQ
- (|->|) :: TypeQ -> TypeQ -> TypeQ
- (|.|) :: ExpQ -> ExpQ -> ExpQ
Documentation
cleanNames :: Data a => a -> a Source #
conToConType :: Type -> Con -> Type Source #
foreignName :: Foreign -> Name Source #
fromDataConI :: Info -> Q (Maybe Exp) Source #
fromTyConI :: Info -> Maybe Dec Source #
nameSpaceOf :: Name -> Maybe NameSpace Source #
Randomly useful.
nameToRawCodeStr :: Name -> String Source #
normaliseName :: Name -> Name Source #
Remove qualification, etc.
normalizeT :: Data a => a -> a Source #
pretty :: Show a => a -> String Source #
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.
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.
renameThings :: (t1 -> t2 -> a1 -> (a2, t1, t2)) -> t1 -> t2 -> [a2] -> [a1] -> ([a2], t1, t2) Source #
Generalisation of renameTs
renameTs :: [(Name, Name)] -> [Name] -> [Type] -> [Type] -> ([Type], [(Name, Name)], [Name]) Source #
renameT applied to a list of types
showToPatQ :: Show a => a -> PatQ Source #
strictTypeTy :: StrictType -> Type Source #
toExpQ :: Lift a => (String -> Q a) -> String -> ExpQ 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.
typeToName :: Type -> Maybe Name Source #
unsafeRunQ :: Q a -> a Source #
unsafeRunQ = unsafePerformIO . runQ
varStrictTypeTy :: VarStrictType -> Type Source #