Yicho: A Combinator Library for Program TransformationContentsIndex
Yicho
Portabilityportable
Stabilityexperimental
Maintaineryokoyama@ipl.t.u-tokyo.ac.jp
Contents
Type Declarations
Basic Combinators
Lifted Match and Lifted Rule
Derivative Combinators
Directives
Variable Generation
Beta-reduce
Lifting
Manipulating Monads
Pretty Printer
Show
Light Pretty Printer
Tracer
Description
Yicho: a combinator library for program transformation. Yicho web site is http://www.ipl.t.u-tokyo.ac.jp/yicho/
Synopsis
type RuleY = ExpQ -> ExpY
type ExpY = Y ExpQ
(<==) :: ExpQ -> ExpQ -> Y ()
(==>) :: ExpQ -> ExpQ -> RuleY
caseM :: ExpQ -> [RuleY] -> ExpY
class Choice a where
(<+) :: a -> a -> a
(<===) :: ExpQ -> ExpY -> Y ()
(===>) :: ExpQ -> ExpY -> RuleY
try :: RuleY -> RuleY
using :: ExpY -> (String, Q [Dec]) -> ExpY
mkrules :: String -> Q [Dec] -> RuleY
mkunfold :: String -> Q [Dec] -> RuleY -> RuleY
pvar :: String -> Y ExpQ
pvars :: [String] -> Y [ExpQ]
genPE :: String -> Int -> ([PatQ], [ExpQ])
betareduce :: Exp -> Exp
liftY :: Q a -> Y a
runY :: Y (Q e) -> Q e
(@@) :: Monad m => (a -> m b) -> (t -> m a) -> t -> m b
ret :: ExpQ -> ExpY
ret2 :: ExpQ -> ExpY
prettyQ :: (Ppr a, Show a) => Q a -> IO ()
prettyY :: (Ppr a, Show a) => Y (Q a) -> IO ()
prettyExpY :: ExpY -> IO ()
prettySubstY :: Y () -> IO ()
prettyExpQ :: ExpQ -> IO ()
putExpQ :: ExpQ -> IO ()
putExpY :: ExpY -> IO ()
putQ :: Show a => Q a -> IO ()
putY :: Show a => Y (Q a) -> IO ()
prettyQL :: (Ppr a, Show a) => Q a -> IO ()
prettyYL :: (Ppr a, Show a) => Y (Q a) -> IO ()
prettyExpYL :: ExpY -> IO ()
traceExpQ :: ExpQ -> ExpY
traceExpY :: ExpY -> ExpY
traceExpQL :: ExpQ -> ExpY
traceExpYL :: ExpY -> ExpY
Type Declarations
type RuleY = ExpQ -> ExpY
rule
type ExpY = Y ExpQ
an expression with the environment and failuire manipulation
Basic Combinators
(<==)
:: ExpQPattern
-> ExpQTerm
-> Y ()
Match
(==>)
:: ExpQPattern
-> ExpQExpression to be replaced with
-> RuleY
Rule
caseM :: ExpQ -> [RuleY] -> ExpY
Meta Case
class Choice a where
Methods
(<+) :: a -> a -> a
Deterministic Choice
show/hide Instances
Lifted Match and Lifted Rule
(<===)
:: ExpQPattern
-> ExpYLifted term
-> Y ()
Lifted Match
(===>)
:: ExpQPattern
-> ExpYLifted expression to be replaced with
-> RuleY
Lifted Rule
Derivative Combinators
try :: RuleY -> RuleY
try attempts to apply rule r, if possible. Otherwise, let it be.
Directives
using :: ExpY -> (String, Q [Dec]) -> ExpY
Setting definitions together with its module name in Y monad
mkrules
:: StringModule Name
-> Q [Dec]Declarations
-> RuleY
Make rules from declarations
mkunfold
:: StringModule Name
-> Q [Dec]Declarations
-> RuleY
-> RuleY
Variable Generation
pvar :: String -> Y ExpQ

Generating a pattern variable

The following code changes the names each time it is called.

   pvar = return . join . genvar . ($:)
 
pvars :: [String] -> Y [ExpQ]
Generating pattern variables
genPE :: String -> Int -> ([PatQ], [ExpQ])
Beta-reduce
betareduce :: Exp -> Exp
Lifting
liftY :: Q a -> Y a
ExpQ -> ExpY : the inverse of runY
Manipulating Monads
runY :: Y (Q e) -> Q e
ExpY -> ExpQ : the inverse of liftY
(@@) :: Monad m => (a -> m b) -> (t -> m a) -> t -> m b
Monad composition
ret :: ExpQ -> ExpY
Lift from ExpQ to ExpY with instanciating bound variables in environment and unfolding definitions kept in Y monad
ret2 :: ExpQ -> ExpY
Lift from ExpQ to ExpY with instanciating bound variables in environment
Pretty Printer
prettyQ :: (Ppr a, Show a) => Q a -> IO ()
prettyY :: (Ppr a, Show a) => Y (Q a) -> IO ()
prettyExpY :: ExpY -> IO ()
prettySubstY :: Y () -> IO ()
prettyExpQ :: ExpQ -> IO ()
putExpQ :: ExpQ -> IO ()
putExpY :: ExpY -> IO ()
Show
putQ :: Show a => Q a -> IO ()
putY :: Show a => Y (Q a) -> IO ()
Light Pretty Printer
Pretty printing functions ending L print out expressions without module names of variables
prettyQL :: (Ppr a, Show a) => Q a -> IO ()
prettyYL :: (Ppr a, Show a) => Y (Q a) -> IO ()
prettyExpYL :: ExpY -> IO ()
Tracer
traceExpQ :: ExpQ -> ExpY
traceExpY :: ExpY -> ExpY
traceExpQL :: ExpQ -> ExpY
traceExpYL :: ExpY -> ExpY
Produced by Haddock version 0.6