haskell-src-meta
Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Meta.Utils

Description

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

Synopsis

Documentation

applyT :: Type -> Type -> Type Source #

arityT :: Type -> Int Source #

The arity of a Type.

cleanNames :: Data a => a -> a Source #

conName :: Con -> Name Source #

conToConType :: Type -> Con -> Type Source #

conTypes :: Con -> [Type] Source #

dataDCons :: Dec -> [Con] Source #

decCons :: Dec -> [Con] Source #

decName :: Dec -> Maybe Name Source #

decTyVars :: Dec -> [TyVarBndrVis] Source #

eitherQ :: (e -> String) -> Either e a -> Q a Source #

foreignName :: Foreign -> Name Source #

fromDataConI :: Info -> Q (Maybe Exp) Source #

fromTyConI :: Info -> Maybe Dec Source #

functionT :: [TypeQ] -> TypeQ Source #

gpretty :: Data a => a -> String Source #

mkClauseQ :: [PatQ] -> ExpQ -> ClauseQ Source #

mkFunD :: Name -> [Pat] -> Exp -> Dec Source #

mkVarT :: String -> TypeQ Source #

myNames :: [Name] Source #

Infinite list of names composed of lowercase letters

nameSpaceOf :: Name -> Maybe NameSpace Source #

Randomly useful.

nameToRawCodeStr :: Name -> String Source #

normaliseName :: Name -> Name Source #

Remove qualification, etc.

normalizeT :: Data a => a -> a Source #

pp :: (Data a, Ppr a) => a -> String Source #

ppDoc :: (Data a, Ppr a) => a -> Doc 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.

recCName :: Con -> Maybe Name Source #

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 #

splitCon :: Con -> (Name, [Type]) Source #

strictTypeTy :: StrictType -> Type Source #

substT :: [(Name, Type)] -> [Name] -> Type -> 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.

toPatQ :: Show a => (String -> Q a) -> String -> PatQ Source #

typeToName :: Type -> Maybe Name Source #

unForall :: Type -> Type Source #

unsafeRunQ :: Q a -> a Source #

unsafeRunQ = unsafePerformIO . runQ

unwindE :: Exp -> [Exp] Source #

unwindT :: Type -> [Type] Source #

varStrictTypeTy :: VarStrictType -> Type Source #

(|$|) :: ExpQ -> ExpQ -> ExpQ infixr 0 Source #

(|->|) :: TypeQ -> TypeQ -> TypeQ infixr 9 Source #

(|.|) :: ExpQ -> ExpQ -> ExpQ infixr 9 Source #

Orphan instances

Show DecQ Source # 
Instance details

Methods

showsPrec :: Int -> DecQ -> ShowS

show :: DecQ -> String

showList :: [DecQ] -> ShowS

Show ExpQ Source # 
Instance details

Methods

showsPrec :: Int -> ExpQ -> ShowS

show :: ExpQ -> String

showList :: [ExpQ] -> ShowS

Show TypeQ Source # 
Instance details

Methods

showsPrec :: Int -> TypeQ -> ShowS

show :: TypeQ -> String

showList :: [TypeQ] -> ShowS

Show (Q Doc) Source # 
Instance details

Methods

showsPrec :: Int -> Q Doc -> ShowS

show :: Q Doc -> String

showList :: [Q Doc] -> ShowS

Show (Q String) Source # 
Instance details

Methods

showsPrec :: Int -> Q String -> ShowS

show :: Q String -> String

showList :: [Q String] -> ShowS

Show (Q [Dec]) Source # 
Instance details

Methods

showsPrec :: Int -> Q [Dec] -> ShowS

show :: Q [Dec] -> String

showList :: [Q [Dec]] -> ShowS