Safe Haskell | None |
---|
This module defines the state monad used in
Lifting
for Template Haskell
term manipulation.
Synopsis
- 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 :: LiftState Source #
An empty state.
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 a Source #
Run a computation with a particular name being bound.
withBoundVars :: [Name] -> LiftQ a -> LiftQ a Source #
Run a computation with a particular list of names being bound.
Other operations on monad state.
setMonadName :: String -> LiftQ () Source #
Set the monad name.
getMonadName :: LiftQ String Source #
Get the monad name.
Functions dealing with variable names.
sanitizeString :: String -> String Source #
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 String Source #
Take a string and make it into a valid Haskell name starting with
"template_"
.
Other functions.
clauseGetPats :: Clause -> [Pat] Source #
Project patterns out of a clause.
equalNEListElts :: Eq a => [a] -> Bool Source #
Check that the list is a non-empty repetition of the same element.