The Quipper System

Safe HaskellNone

Quipper.Utils.Template.LiftQ

Contents

Description

This module defines the state monad used in Lifting for Template Haskell term manipulation.

Synopsis

Documentation

data LiftState Source #

State of the monad.

Constructors

LiftState 

Fields

emptyLiftState :: LiftState Source #

An empty state.

type LiftQState = StateT LiftState ErrMsgQ Source #

Shortcut to StateT LiftState ErrMsgQ.

data LiftQ a Source #

The monad.

Constructors

LiftQ (LiftQState a) 
Instances
Monad LiftQ # 
Instance details

Defined in Quipper.Utils.Template.LiftQ

Methods

(>>=) :: LiftQ a -> (a -> LiftQ b) -> LiftQ b #

(>>) :: LiftQ a -> LiftQ b -> LiftQ b #

return :: a -> LiftQ a #

fail :: String -> LiftQ a #

Functor LiftQ # 
Instance details

Defined in Quipper.Utils.Template.LiftQ

Methods

fmap :: (a -> b) -> LiftQ a -> LiftQ b #

(<$) :: a -> LiftQ b -> LiftQ a #

Applicative LiftQ # 
Instance details

Defined in Quipper.Utils.Template.LiftQ

Methods

pure :: a -> LiftQ a #

(<*>) :: LiftQ (a -> b) -> LiftQ a -> LiftQ b #

liftA2 :: (a -> b -> c) -> LiftQ a -> LiftQ b -> LiftQ c #

(*>) :: LiftQ a -> LiftQ b -> LiftQ b #

(<*) :: LiftQ a -> LiftQ b -> LiftQ a #

getState :: LiftQ LiftState Source #

Retrieve the state from the monad.

setState :: LiftState -> LiftQ () Source #

Set the state of the monad.

Various functions to go back and forth between monads.

embedQ :: Q a -> LiftQ a Source #

From Q to LiftQ.

extractQ :: String -> LiftQ a -> Q a Source #

Get Q out of LiftQ

errorMsg :: String -> LiftQ a Source #

Set an error message.

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.

isBoundVar :: Name -> LiftQ Bool Source #

Say whether a given name is bound.

Other operations on monad state.

setPrefix :: String -> LiftQ () Source #

Set the template prefix.

getPrefix :: LiftQ String Source #

Get the template prefix.

setMonadName :: String -> LiftQ () Source #

Set the monad name.

getMonadName :: LiftQ String Source #

Get the monad name.

Functions dealing with variable names.

mkName :: String -> Name Source #

Make a name out of a string.

newName :: String -> LiftQ Name Source #

Make a name out of a string, monadic-style.

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_".

lookForTemplate :: Name -> LiftQ (Maybe Name) Source #

Look for the corresponding "template" name.

makeTemplateName :: Name -> LiftQ Name Source #

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] -> Bool Source #

Check that the list is a non-empty repetition of the same element.

clausesLengthPats :: [Clause] -> LiftQ Int Source #

Returns the length of the patterns in a list of clauses. Throw an error if the patterns do not have all the same size.