Safe Haskell | None |
---|
Libraries.Template.LiftQ
Contents
Description
This module defines the state monad used in
Lifting
for Template Haskell
term manipulation.
- data LiftState = LiftState {}
- emptyLiftState :: LiftState
- type LiftQState = StateT LiftState ErrMsgQ
- data LiftQ a = LiftQ (LiftQState a)
- getState :: LiftQ LiftState
- setState :: LiftState -> LiftQ ()
- embedErrMsgQ :: ErrMsgQ a -> LiftQ a
- embedQ :: Q a -> LiftQ a
- extractQ :: String -> LiftQ a -> Q a
- errorMsg :: String -> LiftQ a
- addToBoundVar :: Name -> LiftQ ()
- removeFromBoundVar :: Name -> LiftQ ()
- withBoundVar :: Name -> LiftQ a -> LiftQ a
- withBoundVars :: [Name] -> LiftQ a -> LiftQ a
- isBoundVar :: Name -> LiftQ Bool
- setPrefix :: String -> LiftQ ()
- getPrefix :: LiftQ String
- setMonadName :: String -> LiftQ ()
- getMonadName :: LiftQ String
- mkName :: String -> Name
- newName :: String -> LiftQ Name
- sanitizeString :: String -> String
- templateString :: String -> LiftQ String
- lookForTemplate :: Name -> LiftQ (Maybe Name)
- makeTemplateName :: Name -> LiftQ Name
- prettyPrint :: Ppr a => LiftQ a -> IO ()
- clauseGetPats :: Clause -> [Pat]
- equalNEListElts :: Eq a => [a] -> Bool
- clausesLengthPats :: [Clause] -> LiftQ Int
Documentation
State of the monad.
emptyLiftState :: LiftStateSource
An empty state.
type LiftQState = StateT LiftState ErrMsgQSource
Shortcut to StateT LiftState ErrMsgQ
.
Various functions to go back and forth between monads.
Working with variable names.
addToBoundVar :: Name -> LiftQ ()Source
Increase the number of binds of a variable name.
removeFromBoundVar :: Name -> LiftQ ()Source
Decrease the number of binds of a variable name.
withBoundVar :: Name -> LiftQ a -> LiftQ aSource
Run a computation with a particular name being bound.
withBoundVars :: [Name] -> LiftQ a -> LiftQ aSource
Run a computation with a particular list of names being bound.
isBoundVar :: Name -> LiftQ BoolSource
Say whether a given name is bound.
Other operations on monad state.
setMonadName :: String -> LiftQ ()Source
Set the monad name.
getMonadName :: LiftQ StringSource
Get the monad name.
Functions dealing with variable names.
sanitizeString :: String -> StringSource
Make any string into a string containing only [0-9a-zA-Z_.]
.
For example, it replaces any occurrence of "+"
with
"symb_plus_"
.
templateString :: String -> LiftQ StringSource
Take a string and make it into a valid Haskell name starting with
"template_"
.
makeTemplateName :: Name -> LiftQ NameSource
Make a the template version of a given name.
Other functions.
prettyPrint :: Ppr a => LiftQ a -> IO ()Source
Print on the terminal a monadic, printable object.
clauseGetPats :: Clause -> [Pat]Source
Project patterns out of a clause.
equalNEListElts :: Eq a => [a] -> BoolSource
Check that the list is a non-empty repetition of the same element.
clausesLengthPats :: [Clause] -> LiftQ IntSource
Returns the length of the patterns in a list of clauses. Throw an error if the patterns do not have all the same size.