-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell Equational Reasoning Model-to-Implementation Tunnel -- -- HERMIT uses Haskell to express semi-formal models, efficient -- implementations, and provide a bridging DSL to describe via stepwise -- refinement the connection between these models and implementations. -- The key transformation in the bridging DSL is the worker/wrapper -- transformation. -- -- This is a pre-alpha `please give feedback' release. -- Shortcomings/gotchas include: -- -- -- -- Examples can be found in the examples sub-directory. -- --
--   $ cd examples/reverse
--   
-- -- Example of running a script. -- --
--   $ hermit Reverse.hs Reverse.hss resume
--   [starting HERMIT v0.2.0.0 on Reverse.hs]
--   % ghc Reverse.hs -fforce-recomp -O2 -dcore-lint -fexpose-all-unfoldings -fsimple-list-literals -fplugin=HERMIT -fplugin-opt=HERMIT:Main:Reverse.hss -fplugin-opt=HERMIT:Main:resume
--   [1 of 2] Compiling HList            ( HList.hs, HList.o )
--   Loading package ghc-prim ... linking ... done.
--   ...
--   Loading package hermit-0.2.0.0 ... linking ... done.
--   [2 of 2] Compiling Main             ( Reverse.hs, Reverse.o )
--   Linking Reverse ...
--   $ ./Reverse
--   ....
--   
-- -- Example of interactive use. -- --
--   $ hermit Reverse.hs
--   [starting HERMIT v0.2.0.0 on Reverse.hs]
--   % ghc Reverse.hs -fforce-recomp -O2 -dcore-lint -fexpose-all-unfoldings -fsimple-list-literals -fplugin=HERMIT -fplugin-opt=HERMIT:Main:
--   [1 of 2] Compiling HList            ( HList.hs, HList.o )
--   Loading package ghc-prim ... linking ... done.
--   ...
--   Loading package hermit-0.2.0.0 ... linking ... done.
--   [2 of 2] Compiling Main             ( Reverse.hs, Reverse.o )
--   ===================== Welcome to HERMIT =====================
--   HERMIT is a toolkit for the interactive transformation of GHC
--   core language programs. Documentation on HERMIT can be found
--   on the HERMIT web page at:
--   http://www.ittc.ku.edu/csdl/fpg/software/hermit.html
--   
--   You have just loaded the interactive shell. To exit, type
--   "abort" or "resume" to abort or resume GHC compilation.
--   
--   Type "help" for instructions on how to list or search the
--   available HERMIT commands.
--   
--   To get started, you could try the following:
--     - type "consider 'foo", where "foo" is a function
--       defined in the module;
--     - type "set-pp-type Show" to switch on typing information;
--     - use natural numbers such as "0" and "1" to descend into
--       the definition, and "up" to ascend;
--     - type "info" for more information about the current node;
--     - type "log" to display an activity log.
--   =============================================================
--   module main:Main where
--     rev ∷ ∀ a . [a] -> [a]
--     unwrap ∷ ∀ a . ([a] -> [a]) -> [a] -> H a
--     wrap ∷ ∀ a . ([a] -> H a) -> [a] -> [a]
--     main ∷ IO ()
--     main ∷ IO ()
--   hermit<0>
--   ...
--   
-- -- To resume compilation, use resume. -- --
--   ...
--   hermit<0> resume
--   hermit<0> Linking Reverse ...
--   $
--   
@package hermit @version 0.2.0.0 module Language.HERMIT.Plugin -- | Given a list of CommandLineOptions, produce the ModGuts -- to ModGuts function required to build a plugin. type HermitPass = PhaseInfo -> [CommandLineOption] -> ModGuts -> CoreM ModGuts -- | Build a hermit plugin. This mainly handles the per-module options. hermitPlugin :: HermitPass -> Plugin data CorePass FloatInwards :: CorePass LiberateCase :: CorePass PrintCore :: CorePass StaticArgs :: CorePass Strictness :: CorePass WorkerWrapper :: CorePass Specialising :: CorePass SpecConstr :: CorePass CSE :: CorePass Vectorisation :: CorePass Desugar :: CorePass DesugarOpt :: CorePass Tidy :: CorePass Prep :: CorePass Simplify :: CorePass FloatOutwards :: CorePass RuleCheck :: CorePass Passes :: CorePass PluginPass :: String -> CorePass NoOp :: CorePass Unknown :: CorePass getCorePass :: CoreToDo -> CorePass ghcPasses :: [(CorePass, CoreToDo)] data PhaseInfo PhaseInfo :: Int -> [CorePass] -> [CorePass] -> PhaseInfo phaseNum :: PhaseInfo -> Int phasesDone :: PhaseInfo -> [CorePass] phasesLeft :: PhaseInfo -> [CorePass] instance Read CorePass instance Show CorePass instance Eq CorePass instance Read PhaseInfo instance Show PhaseInfo instance Eq PhaseInfo module Language.HERMIT.Parser parseStmtsH :: String -> Either String [ExprH] unparseExprH :: ExprH -> String numStmtsH :: [ExprH] -> Int -- | A simple expression language AST, for things parsed from String -- or JSON structures. data ExprH -- | Variable names (refers to source code). SrcName :: String -> ExprH -- | Commands (to be looked up in Dictionary). CmdName :: String -> ExprH -- | Application. AppH :: ExprH -> ExprH -> ExprH -- | Core Fragment CoreH :: String -> ExprH -- | List of expressions ListH :: [ExprH] -> ExprH instance Eq ExprH instance Show ExprH instance Eq Token instance Show Token module Language.HERMIT.GHC -- | Pretty-print an identifier. ppIdInfo :: Id -> IdInfo -> SDoc -- | Convert a variable to a neat string for printing (unqualfied name). var2String :: Var -> String thRdrNameGuesses :: Name -> [RdrName] -- | Converts a GHC Name to a Template Haskell Name, going -- via a String. name2THName :: Name -> Name -- | Converts an Var to a Template Haskell Name, going via a -- String. var2THName :: Var -> Name -- | Compare a Name to a Name for equality. See -- cmpString2Name. cmpTHName2Name :: Name -> Name -> Bool -- | Compare a String to a Name for equality. Strings -- containing a period are assumed to be fully qualified names. cmpString2Name :: String -> Name -> Bool -- | Compare a Name to a Var for equality. See -- cmpString2Name. cmpTHName2Var :: Name -> Var -> Bool -- | Compare a String to a Var for equality. See -- cmpString2Name. cmpString2Var :: String -> Var -> Bool -- | Get the fully qualified name from a Name. fqName :: Name -> String -- | Get the unqualified name from a Name. uqName :: Name -> String -- | Find Names matching a given fully qualified or unqualified -- name. If given name is fully qualified, will only return first result, -- which is assumed unique. findNamesFromString :: GlobalRdrEnv -> String -> [Name] -- | Find Names matching a Name. See -- findNamesFromString. findNamesFromTH :: GlobalRdrEnv -> Name -> [Name] alphaTyVars :: [TyVar] -- | The key representation of types within the compiler data Type :: * -- | Vanilla type or kind variable (*never* a coercion variable) TyVarTy :: Var -> Type -- | Type application to something other than a TyCon. Parameters: -- -- 1) Function: must not be a TyConApp, must be another -- AppTy, or TyVarTy -- -- 2) Argument type AppTy :: Type -> Type -> Type -- | Application of a TyCon, including newtypes and synonyms. -- Invariant: saturated appliations of FunTyCon must use -- FunTy and saturated synonyms must use their own constructors. -- However, unsaturated FunTyCons do appear as -- TyConApps. Parameters: -- -- 1) Type constructor being applied to. -- -- 2) Type arguments. Might not have enough type arguments here to -- saturate the constructor. Even type synonyms are not necessarily -- saturated; for example unsaturated type synonyms can appear as the -- right hand side of a type synonym. TyConApp :: TyCon -> [KindOrType] -> Type -- | Special case of TyConApp: TyConApp FunTyCon [t1, t2] -- See Note [Equality-constrained types] FunTy :: Type -> Type -> Type -- | A polymorphic type ForAllTy :: Var -> Type -> Type -- | Type literals are simillar to type constructors. LitTy :: TyLit -> Type data TyLit :: * NumTyLit :: Integer -> TyLit StrTyLit :: FastString -> TyLit -- | GHC's own exception type error messages all take the form: -- --
--   location: error
--   
-- -- If the location is on the command line, or in GHC itself, then -- location=ghc. All of the error types below correspond to -- a location of ghc, except for ProgramError (where the -- string is assumed to contain a location already, so we don't print -- one). data GhcException :: * -- | An error in the user's code, probably. ProgramError :: String -> GhcException throwGhcException :: GhcException -> a -- | An approximate, fast, version of exprEtaExpandArity exprArity :: CoreExpr -> Arity coAxiomName :: CoAxiom -> Name module Language.HERMIT.Core -- | A program is a telescope of nested binding groups. That is, each -- binding scopes over the remainder of the program. In GHC Core, -- programs are encoded as [CoreBind]. This data type is -- isomorphic. data CoreProg -- | An empty program. ProgNil :: CoreProg -- | A binding group and the program it scopes over. ProgCons :: CoreBind -> CoreProg -> CoreProg -- | A (potentially recursive) definition is an identifier and an -- expression. In GHC Core, recursive definitions are encoded as -- (Id, CoreExpr) pairs. This data type is isomorphic. data CoreDef Def :: Id -> CoreExpr -> CoreDef -- | Unlike everything else, there is no synonym for Tickish -- Id provided by GHC, so we define one. type CoreTickish = Tickish Id -- | Convert a list of recursive definitions into an (isomorphic) recursive -- binding group. defsToRecBind :: [CoreDef] -> CoreBind -- | Convert a definition to an identifier/expression pair. defToIdExpr :: CoreDef -> (Id, CoreExpr) -- | Get the list of bindings in a program. progToBinds :: CoreProg -> [CoreBind] -- | Build a program from a list of bindings. Note that bindings earlier in -- the list are considered scope over bindings later in the list. bindsToProg :: [CoreBind] -> CoreProg -- | Extract the list of identifier/expression pairs from a binding group. bindToIdExprs :: CoreBind -> [(Id, CoreExpr)] -- | Returns True iff the expression is a Coercion -- expression at its top level. isCoArg :: CoreExpr -> Bool -- | GHC's exprType function throws an error if applied to a -- Type (but, inconsistently, return a Kind if applied to a -- type variable). This function returns the Kind of a -- Type, but otherwise behaves as exprType. exprTypeOrKind :: CoreExpr -> Type -- | Return the domain/codomain type of an endofunction expression. endoFunType :: Monad m => CoreExpr -> m Type -- | Return the domain and codomain types of a function expression. funArgResTypes :: Monad m => CoreExpr -> m (Type, Type) -- | Check two expressions have types a -> b and b -> -- a, returning (a,b). funsWithInverseTypes :: MonadCatch m => CoreExpr -> CoreExpr -> m (Type, Type) -- | Count the number of nested applications. appCount :: CoreExpr -> Int -- | Crumbs record a path through the tree, using descriptive constructor -- names. data Crumb ModGuts_Prog :: Crumb ProgCons_Head :: Crumb ProgCons_Tail :: Crumb NonRec_RHS :: Crumb NonRec_Var :: Crumb Rec_Def :: Int -> Crumb Def_Id :: Crumb Def_RHS :: Crumb Var_Id :: Crumb Lit_Lit :: Crumb App_Fun :: Crumb App_Arg :: Crumb Lam_Var :: Crumb Lam_Body :: Crumb Let_Bind :: Crumb Let_Body :: Crumb Case_Scrutinee :: Crumb Case_Binder :: Crumb Case_Type :: Crumb Case_Alt :: Int -> Crumb Cast_Expr :: Crumb Cast_Co :: Crumb Tick_Tick :: Crumb Tick_Expr :: Crumb Type_Type :: Crumb Co_Co :: Crumb Alt_Con :: Crumb Alt_Var :: Int -> Crumb Alt_RHS :: Crumb TyVarTy_TyVar :: Crumb LitTy_TyLit :: Crumb AppTy_Fun :: Crumb AppTy_Arg :: Crumb TyConApp_TyCon :: Crumb TyConApp_Arg :: Int -> Crumb FunTy_Dom :: Crumb FunTy_CoDom :: Crumb ForAllTy_Var :: Crumb ForAllTy_Body :: Crumb Refl_Type :: Crumb TyConAppCo_TyCon :: Crumb TyConAppCo_Arg :: Int -> Crumb AppCo_Fun :: Crumb AppCo_Arg :: Crumb ForAllCo_TyVar :: Crumb ForAllCo_Body :: Crumb CoVarCo_CoVar :: Crumb AxiomInstCo_Axiom :: Crumb AxiomInstCo_Index :: Crumb AxiomInstCo_Arg :: Int -> Crumb UnsafeCo_Left :: Crumb UnsafeCo_Right :: Crumb SymCo_Co :: Crumb TransCo_Left :: Crumb TransCo_Right :: Crumb NthCo_Int :: Crumb NthCo_Co :: Crumb InstCo_Co :: Crumb InstCo_Type :: Crumb LRCo_LR :: Crumb LRCo_Co :: Crumb showCrumbs :: [Crumb] -> String -- | Converts a Crumb into the Crumb pointing to its -- left-sibling, if a such a Crumb exists. This is for backwards -- compatibility purposes with the old Int representation. deprecatedLeftSibling :: Crumb -> Maybe Crumb -- | Converts a Crumb into the Crumb pointing to its -- right-sibling, if a such a Crumb exists. This is for backwards -- compatibility purposes with the old Int representation. deprecatedRightSibling :: Crumb -> Maybe Crumb instance Eq Crumb instance Read Crumb instance Show Crumb module Language.HERMIT.Kure.SumTypes -- | Core is a sum type for use by KURE. Core = ModGuts + CoreProg + -- CoreBind + CoreDef + CoreExpr + CoreAlt data Core -- | The module. GutsCore :: ModGuts -> Core -- | A program (a telescope of top-level binding groups). ProgCore :: CoreProg -> Core -- | A binding group. BindCore :: CoreBind -> Core -- | A recursive definition. DefCore :: CoreDef -> Core -- | An expression. ExprCore :: CoreExpr -> Core -- | A case alternative. AltCore :: CoreAlt -> Core -- | TyCo is a sum type for use by KURE. TyCo = Type + Coercion data TyCo -- | A type. TypeCore :: Type -> TyCo -- | A coercion. CoercionCore :: Coercion -> TyCo -- | CoreTC is a sum type for use by KURE. CoreTC = Core + TyCo data CoreTC Core :: Core -> CoreTC TyCo :: TyCo -> CoreTC instance Injection Coercion CoreTC instance Injection Type CoreTC instance Injection CoreExpr CoreTC instance Injection CoreAlt CoreTC instance Injection CoreDef CoreTC instance Injection CoreBind CoreTC instance Injection CoreProg CoreTC instance Injection ModGuts CoreTC instance Injection TyCo CoreTC instance Injection Core CoreTC instance Injection Coercion TyCo instance Injection Type TyCo instance Injection CoreExpr Core instance Injection CoreAlt Core instance Injection CoreDef Core instance Injection CoreBind Core instance Injection CoreProg Core instance Injection ModGuts Core module Language.HERMIT.Context -- | The HERMIT context, containing all bindings in scope and the current -- location in the AST. The bindings here are lazy by choice, so that we -- can avoid the cost of building the context if we never use it. data HermitC -- | Create the initial HERMIT HermitC by providing a -- ModGuts. initHermitC :: ModGuts -> HermitC -- | HERMIT's representation of variable bindings. Bound expressions cannot -- be inlined without checking for shadowing issues (using the depth -- information). data HermitBindingSite REC :: CoreExpr -> HermitBindingSite NONREC :: CoreExpr -> HermitBindingSite LAM :: HermitBindingSite CASEALT :: HermitBindingSite FORALL :: HermitBindingSite -- | We store both the scrutinised expression, and the case alternative -- AltCon (which can be converted to Constructor or Literal) and -- variables. CASEWILD :: CoreExpr -> (AltCon, [Var]) -> HermitBindingSite -- | The depth of a binding. Used, for example, to detect shadowing when -- inlining. type BindingDepth = Int type HermitBinding = (BindingDepth, HermitBindingSite) -- | Retrieve the expression in a HermitBindingSite, if there is -- one. hermitBindingSiteExpr :: HermitBindingSite -> Maybe CoreExpr -- | Retrieve the expression in a HermitBinding, if there is one. hermitBindingExpr :: HermitBinding -> Maybe CoreExpr -- | A class of contexts that can have HERMIT bindings added to them. class AddBindings c addHermitBindings :: AddBindings c => [(Var, HermitBindingSite)] -> c -> c -- | Add all bindings in a binding group to a context. addBindingGroup :: AddBindings c => CoreBind -> c -> c -- | Add a lambda bound variable to a context. All that is known is the -- variable, which may shadow something. If so, we don't worry about that -- here, it is instead checked during inlining. addLambdaBinding :: AddBindings c => Var -> c -> c -- | Add the variables bound by a DataCon in a case. They are all -- bound at the same depth. addAltBindings :: AddBindings c => [Var] -> c -> c -- | Add a wildcard binding for a specific case alternative. addCaseWildBinding :: AddBindings c => (Id, CoreExpr, CoreAlt) -> c -> c -- | Add a universally quantified type variable to a context. addForallBinding :: AddBindings c => TyVar -> c -> c -- | A class of contexts that stores the set of variables in scope that -- have been bound during the traversal. class BoundVars c boundVars :: BoundVars c => c -> Set Var -- | Determine if a variable is bound in a context. boundIn :: ReadBindings c => Var -> c -> Bool -- | List all variables bound in the context that match the given name. findBoundVars :: BoundVars c => Name -> c -> [Var] -- | A class of contexts from which HERMIT bindings can be retrieved. class BoundVars c => ReadBindings c hermitDepth :: ReadBindings c => c -> BindingDepth hermitBindings :: ReadBindings c => c -> Map Var HermitBinding -- | Lookup the binding for a variable in a context. lookupHermitBinding :: ReadBindings c => Var -> c -> Maybe HermitBinding -- | A class of contexts that store the Global Reader Environment. class HasGlobalRdrEnv c hermitGlobalRdrEnv :: HasGlobalRdrEnv c => c -> GlobalRdrEnv -- | A class of contexts that store GHC rewrite rules. class HasCoreRules c hermitCoreRules :: HasCoreRules c => c -> [CoreRule] instance HasGlobalRdrEnv HermitC instance HasCoreRules HermitC instance ReadBindings HermitC instance BoundVars HermitC instance AddBindings HermitC instance ExtendPath HermitC Crumb instance ReadPath HermitC Crumb instance AddBindings (SnocPath crumb) module Language.HERMIT.Monad -- | The HERMIT monad is kept abstract. data HermitM a -- | Eliminator for HermitM. runHM :: HermitMEnv -> DefStash -> (DefStash -> a -> CoreM b) -> (String -> CoreM b) -> HermitM a -> CoreM b -- | CoreM can be lifted to HermitM. liftCoreM :: CoreM a -> HermitM a -- | Make a unique identifier for a specified type based on a provided -- name. newIdH :: String -> Type -> HermitM Id -- | Make a unique type variable for a specified kind based on a provided -- name. newTyVarH :: String -> Kind -> HermitM TyVar -- | This gives an new version of a Var, with the same info, and a -- new textual name. cloneVarH :: (String -> String) -> Var -> HermitM Var -- | A label for individual definitions. type Label = String -- | A store of saved definitions. type DefStash = Map Label CoreDef -- | Save a definition for future use. saveDef :: Label -> CoreDef -> HermitM () -- | Lookup a previously saved definition. lookupDef :: Label -> HermitM CoreDef -- | Get the stash of saved definitions. getStash :: HermitM DefStash -- | A way of sending messages to top level newtype HermitMEnv HermitMEnv :: (DebugMessage -> HermitM ()) -> HermitMEnv hs_debugChan :: HermitMEnv -> DebugMessage -> HermitM () -- | A message packet. data DebugMessage DebugTick :: String -> DebugMessage -- | A postcard. DebugCore :: String -> HermitC -> Core -> DebugMessage mkHermitMEnv :: (DebugMessage -> HermitM ()) -> HermitMEnv sendDebugMessage :: DebugMessage -> HermitM () instance HasDynFlags HermitM instance MonadThings HermitM instance MonadUnique HermitM instance MonadIO HermitM instance MonadCatch HermitM instance Monad HermitM instance Applicative HermitM instance Functor HermitM module Language.HERMIT.Kure type TranslateH a b = Translate HermitC HermitM a b type RewriteH a = Rewrite HermitC HermitM a type BiRewriteH a = BiRewrite HermitC HermitM a type LensH a b = Lens HermitC HermitM a b type PathH = Path Crumb -- | Translate a module. Slightly different to the other congruence -- combinators: it passes in all of the original to the -- reconstruction function. modGutsT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreProg a -> (ModGuts -> a -> b) -> Translate c m ModGuts b -- | Rewrite the CoreProg child of a module. modGutsR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoreProg -> Rewrite c m ModGuts -- | Translate an empty list. progNilT :: Monad m => b -> Translate c m CoreProg b -- | Translate a program of the form: (CoreBind : -- CoreProg) progConsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreBind a1 -> Translate c m CoreProg a2 -> (a1 -> a2 -> b) -> Translate c m CoreProg b -- | Rewrite all children of a program of the form: (CoreBind -- : CoreProg) progConsAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m CoreBind -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Rewrite any children of a program of the form: (CoreBind -- : CoreProg) progConsAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreBind -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Rewrite one child of a program of the form: (CoreBind -- : CoreProg) progConsOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreBind -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Translate a binding group of the form: NonRec Var -- CoreExpr nonRecT :: (ExtendPath c Crumb, Monad m) => Translate c m Var a1 -> Translate c m CoreExpr a2 -> (a1 -> a2 -> b) -> Translate c m CoreBind b -- | Rewrite all children of a binding group of the form: NonRec -- Var CoreExpr nonRecAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreBind -- | Rewrite any children of a binding group of the form: NonRec -- Var CoreExpr nonRecAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreBind -- | Rewrite one child of a binding group of the form: NonRec -- Var CoreExpr nonRecOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreBind -- | Translate a binding group of the form: Rec [CoreDef] recT :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> Translate c m CoreDef a) -> ([a] -> b) -> Translate c m CoreBind b -- | Rewrite all children of a binding group of the form: Rec -- [CoreDef] recAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> Rewrite c m CoreDef) -> Rewrite c m CoreBind -- | Rewrite any children of a binding group of the form: Rec -- [CoreDef] recAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> Rewrite c m CoreDef) -> Rewrite c m CoreBind -- | Rewrite one child of a binding group of the form: Rec -- [CoreDef] recOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> Rewrite c m CoreDef) -> Rewrite c m CoreBind -- | Translate a recursive definition of the form: Def Id -- CoreExpr defT :: (ExtendPath c Crumb, Monad m) => Translate c m Id a1 -> Translate c m CoreExpr a2 -> (a1 -> a2 -> b) -> Translate c m CoreDef b -- | Rewrite all children of a recursive definition of the form: -- Def Id CoreExpr defAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Id -> Rewrite c m CoreExpr -> Rewrite c m CoreDef -- | Rewrite any children of a recursive definition of the form: -- Def Id CoreExpr defAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Id -> Rewrite c m CoreExpr -> Rewrite c m CoreDef -- | Rewrite one child of a recursive definition of the form: Def -- Id CoreExpr defOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Id -> Rewrite c m CoreExpr -> Rewrite c m CoreDef -- | Translate a case alternative of the form: (AltCon, -- [Var], CoreExpr) altT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m AltCon a1 -> (Int -> Translate c m Var a2) -> Translate c m CoreExpr a3 -> (a1 -> [a2] -> a3 -> b) -> Translate c m CoreAlt b -- | Rewrite all children of a case alternative of the form: -- (AltCon, Id, CoreExpr) altAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m AltCon -> (Int -> Rewrite c m Var) -> Rewrite c m CoreExpr -> Rewrite c m CoreAlt -- | Rewrite any children of a case alternative of the form: -- (AltCon, Id, CoreExpr) altAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m AltCon -> (Int -> Rewrite c m Var) -> Rewrite c m CoreExpr -> Rewrite c m CoreAlt -- | Rewrite one child of a case alternative of the form: (AltCon, -- Id, CoreExpr) altOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m AltCon -> (Int -> Rewrite c m Var) -> Rewrite c m CoreExpr -> Rewrite c m CoreAlt -- | Translate an expression of the form: Var Id varT :: (ExtendPath c Crumb, Monad m) => Translate c m Id b -> Translate c m CoreExpr b -- | Rewrite the Id child in an expression of the form: Var -- Id varR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Id -> Rewrite c m CoreExpr -- | Translate an expression of the form: Lit Literal litT :: (ExtendPath c Crumb, Monad m) => Translate c m Literal b -> Translate c m CoreExpr b -- | Rewrite the Literal child in an expression of the form: -- Lit Literal litR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Literal -> Rewrite c m CoreExpr -- | Translate an expression of the form: App CoreExpr -- CoreExpr appT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreExpr a1 -> Translate c m CoreExpr a2 -> (a1 -> a2 -> b) -> Translate c m CoreExpr b -- | Rewrite all children of an expression of the form: App -- CoreExpr CoreExpr appAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoreExpr -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: App -- CoreExpr CoreExpr appAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m CoreExpr -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite one child of an expression of the form: App -- CoreExpr CoreExpr appOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m CoreExpr -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Translate an expression of the form: Lam Var -- CoreExpr lamT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m Var a1 -> Translate c m CoreExpr a2 -> (a1 -> a2 -> b) -> Translate c m CoreExpr b -- | Rewrite all children of an expression of the form: Lam -- Var CoreExpr lamAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: Lam -- Var CoreExpr lamAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite one child of an expression of the form: Lam -- Var CoreExpr lamOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Translate an expression of the form: Let CoreBind -- CoreExpr letT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreBind a1 -> Translate c m CoreExpr a2 -> (a1 -> a2 -> b) -> Translate c m CoreExpr b -- | Rewrite all children of an expression of the form: Let -- CoreBind CoreExpr letAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m CoreBind -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: Let -- CoreBind CoreExpr letAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreBind -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite one child of an expression of the form: Let -- CoreBind CoreExpr letOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreBind -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Translate an expression of the form: Case CoreExpr -- Id Type [CoreAlt] caseT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr e -> Translate c m Id w -> Translate c m Type ty -> (Int -> Translate c m CoreAlt alt) -> (e -> w -> ty -> [alt] -> b) -> Translate c m CoreExpr b -- | Rewrite all children of an expression of the form: Case -- CoreExpr Id Type [CoreAlt] caseAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m CoreExpr -> Rewrite c m Id -> Rewrite c m Type -> (Int -> Rewrite c m CoreAlt) -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: Case -- CoreExpr Id Type [CoreAlt] caseAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr -> Rewrite c m Id -> Rewrite c m Type -> (Int -> Rewrite c m CoreAlt) -> Rewrite c m CoreExpr -- | Rewrite one child of an expression of the form: Case -- CoreExpr Id Type [CoreAlt] caseOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr -> Rewrite c m Id -> Rewrite c m Type -> (Int -> Rewrite c m CoreAlt) -> Rewrite c m CoreExpr -- | Translate an expression of the form: Cast CoreExpr -- Coercion castT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreExpr a1 -> Translate c m Coercion a2 -> (a1 -> a2 -> b) -> Translate c m CoreExpr b -- | Rewrite all children of an expression of the form: Cast -- CoreExpr Coercion castAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoreExpr -> Rewrite c m Coercion -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: Cast -- CoreExpr Coercion castAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m CoreExpr -> Rewrite c m Coercion -> Rewrite c m CoreExpr -- | Rewrite one child of an expression of the form: Cast -- CoreExpr Coercion castOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m CoreExpr -> Rewrite c m Coercion -> Rewrite c m CoreExpr -- | Translate an expression of the form: Tick CoreTickish -- CoreExpr tickT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreTickish a1 -> Translate c m CoreExpr a2 -> (a1 -> a2 -> b) -> Translate c m CoreExpr b -- | Rewrite all children of an expression of the form: Tick -- CoreTickish CoreExpr tickAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoreTickish -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: Tick -- CoreTickish CoreExpr tickAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m CoreTickish -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: Tick -- CoreTickish CoreExpr tickOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m CoreTickish -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Translate an expression of the form: Type Type typeT :: (ExtendPath c Crumb, Monad m) => Translate c m Type b -> Translate c m CoreExpr b -- | Rewrite the Type child in an expression of the form: -- Type Type typeR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Type -> Rewrite c m CoreExpr -- | Translate an expression of the form: Coercion Coercion coercionT :: (ExtendPath c Crumb, Monad m) => Translate c m Coercion b -> Translate c m CoreExpr b -- | Rewrite the Coercion child in an expression of the form: -- Coercion Coercion coercionR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Coercion -> Rewrite c m CoreExpr -- | Translate a binding group of the form: Rec [(Id, -- CoreExpr)] recDefT :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> (Translate c m Id a1, Translate c m CoreExpr a2)) -> ([(a1, a2)] -> b) -> Translate c m CoreBind b -- | Rewrite all children of a binding group of the form: Rec -- [(Id, CoreExpr)] recDefAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> (Rewrite c m Id, Rewrite c m CoreExpr)) -> Rewrite c m CoreBind -- | Rewrite any children of a binding group of the form: Rec -- [(Id, CoreExpr)] recDefAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> (Rewrite c m Id, Rewrite c m CoreExpr)) -> Rewrite c m CoreBind -- | Rewrite one child of a binding group of the form: Rec -- [(Id, CoreExpr)] recDefOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> (Rewrite c m Id, Rewrite c m CoreExpr)) -> Rewrite c m CoreBind -- | Translate an expression of the form: Let (NonRec -- Var CoreExpr) CoreExpr letNonRecT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m Var a1 -> Translate c m CoreExpr a2 -> Translate c m CoreExpr a3 -> (a1 -> a2 -> a3 -> b) -> Translate c m CoreExpr b -- | Rewrite all children of an expression of the form: Let -- (NonRec Var CoreExpr) CoreExpr letNonRecAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: Let -- (NonRec Var CoreExpr) CoreExpr letNonRecAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite one child of an expression of the form: Let -- (NonRec Var CoreExpr) CoreExpr letNonRecOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Translate an expression of the form: Let (Rec -- [CoreDef]) CoreExpr letRecT :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> Translate c m CoreDef a1) -> Translate c m CoreExpr a2 -> ([a1] -> a2 -> b) -> Translate c m CoreExpr b -- | Rewrite all children of an expression of the form: Let -- (Rec [CoreDef]) CoreExpr letRecAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> Rewrite c m CoreDef) -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: Let -- (Rec [CoreDef]) CoreExpr letRecAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> Rewrite c m CoreDef) -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite one child of an expression of the form: Let -- (Rec [CoreDef]) CoreExpr letRecOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> Rewrite c m CoreDef) -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Translate an expression of the form: Let (Rec -- [(Id, CoreExpr)]) CoreExpr letRecDefT :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> (Translate c m Id a1, Translate c m CoreExpr a2)) -> Translate c m CoreExpr a3 -> ([(a1, a2)] -> a3 -> b) -> Translate c m CoreExpr b -- | Rewrite all children of an expression of the form: Let -- (Rec [(Id, CoreExpr)]) CoreExpr letRecDefAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> (Rewrite c m Id, Rewrite c m CoreExpr)) -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: Let -- (Rec [(Id, CoreExpr)]) CoreExpr letRecDefAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> (Rewrite c m Id, Rewrite c m CoreExpr)) -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Rewrite one child of an expression of the form: Let -- (Rec [(Id, CoreExpr)]) CoreExpr letRecDefOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> (Rewrite c m Id, Rewrite c m CoreExpr)) -> Rewrite c m CoreExpr -> Rewrite c m CoreExpr -- | Translate a program of the form: (NonRec Var -- CoreExpr) : CoreProg consNonRecT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m Var a1 -> Translate c m CoreExpr a2 -> Translate c m CoreProg a3 -> (a1 -> a2 -> a3 -> b) -> Translate c m CoreProg b -- | Rewrite all children of an expression of the form: (NonRec -- Var CoreExpr) : CoreProg consNonRecAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Rewrite any children of an expression of the form: (NonRec -- Var CoreExpr) : CoreProg consNonRecAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Rewrite one child of an expression of the form: (NonRec -- Var CoreExpr) : CoreProg consNonRecOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Var -> Rewrite c m CoreExpr -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Translate an expression of the form: (Rec [CoreDef]) -- : CoreProg consRecT :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> Translate c m CoreDef a1) -> Translate c m CoreProg a2 -> ([a1] -> a2 -> b) -> Translate c m CoreProg b -- | Rewrite all children of an expression of the form: (Rec -- [CoreDef]) : CoreProg consRecAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> Rewrite c m CoreDef) -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Rewrite any children of an expression of the form: (Rec -- [CoreDef]) : CoreProg consRecAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> Rewrite c m CoreDef) -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Rewrite one child of an expression of the form: (Rec -- [CoreDef]) : CoreProg consRecOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> Rewrite c m CoreDef) -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Translate an expression of the form: (Rec [(Id, -- CoreExpr)]) : CoreProg consRecDefT :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> (Translate c m Id a1, Translate c m CoreExpr a2)) -> Translate c m CoreProg a3 -> ([(a1, a2)] -> a3 -> b) -> Translate c m CoreProg b -- | Rewrite all children of an expression of the form: (Rec -- [(Id, CoreExpr)]) : CoreProg consRecDefAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => (Int -> (Rewrite c m Id, Rewrite c m CoreExpr)) -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Rewrite any children of an expression of the form: (Rec -- [(Id, CoreExpr)]) : CoreProg consRecDefAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> (Rewrite c m Id, Rewrite c m CoreExpr)) -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Rewrite one child of an expression of the form: (Rec -- [(Id, CoreExpr)]) : CoreProg consRecDefOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => (Int -> (Rewrite c m Id, Rewrite c m CoreExpr)) -> Rewrite c m CoreProg -> Rewrite c m CoreProg -- | Translate an expression of the form: Case CoreExpr -- Id Type [(AltCon, [Var], CoreExpr)] caseAltT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr sc -> Translate c m Id w -> Translate c m Type ty -> (Int -> (Translate c m AltCon con, Int -> Translate c m Var v, Translate c m CoreExpr rhs)) -> (sc -> w -> ty -> [(con, [v], rhs)] -> b) -> Translate c m CoreExpr b -- | Rewrite all children of an expression of the form: Case -- CoreExpr Id Type [(AltCon, [Var], -- CoreExpr)] caseAltAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m CoreExpr -> Rewrite c m Id -> Rewrite c m Type -> (Int -> (Rewrite c m AltCon, Int -> Rewrite c m Var, Rewrite c m CoreExpr)) -> Rewrite c m CoreExpr -- | Rewrite any children of an expression of the form: Case -- CoreExpr Id Type [(AltCon, [Var], -- CoreExpr)] caseAltAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr -> Rewrite c m Id -> Rewrite c m Type -> (Int -> (Rewrite c m AltCon, Int -> Rewrite c m Var, Rewrite c m CoreExpr)) -> Rewrite c m CoreExpr -- | Rewrite one child of an expression of the form: Case -- CoreExpr Id Type [(AltCon, [Var], -- CoreExpr)] caseAltOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr -> Rewrite c m Id -> Rewrite c m Type -> (Int -> (Rewrite c m AltCon, Int -> Rewrite c m Var, Rewrite c m CoreExpr)) -> Rewrite c m CoreExpr -- | Translate a type of the form: TyVarTy TyVar tyVarT :: (ExtendPath c Crumb, Monad m) => Translate c m TyVar b -> Translate c m Type b -- | Rewrite the TyVar child of a type of the form: TyVarTy -- TyVar tyVarR :: (ExtendPath c Crumb, Monad m) => Rewrite c m TyVar -> Rewrite c m Type -- | Translate a type of the form: LitTy TyLit litTyT :: (ExtendPath c Crumb, Monad m) => Translate c m TyLit b -> Translate c m Type b -- | Rewrite the TyLit child of a type of the form: LitTy -- TyLit litTyR :: (ExtendPath c Crumb, Monad m) => Rewrite c m TyLit -> Rewrite c m Type -- | Translate a type of the form: AppTy Type Type appTyT :: (ExtendPath c Crumb, Monad m) => Translate c m Type a1 -> Translate c m Type a2 -> (a1 -> a2 -> b) -> Translate c m Type b -- | Rewrite all children of a type of the form: AppTy Type -- Type appTyAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Type -> Rewrite c m Type -> Rewrite c m Type -- | Rewrite any children of a type of the form: AppTy Type -- Type appTyAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Type -> Rewrite c m Type -> Rewrite c m Type -- | Rewrite one child of a type of the form: AppTy Type -- Type appTyOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Type -> Rewrite c m Type -> Rewrite c m Type -- | Translate a type of the form: FunTy Type Type funTyT :: (ExtendPath c Crumb, Monad m) => Translate c m Type a1 -> Translate c m Type a2 -> (a1 -> a2 -> b) -> Translate c m Type b -- | Rewrite all children of a type of the form: FunTy Type -- Type funTyAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Type -> Rewrite c m Type -> Rewrite c m Type -- | Rewrite any children of a type of the form: FunTy Type -- Type funTyAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Type -> Rewrite c m Type -> Rewrite c m Type -- | Rewrite one child of a type of the form: FunTy Type -- Type funTyOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Type -> Rewrite c m Type -> Rewrite c m Type -- | Translate a type of the form: ForAllTy Var Type forAllTyT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m Var a1 -> Translate c m Type a2 -> (a1 -> a2 -> b) -> Translate c m Type b -- | Rewrite all children of a type of the form: ForAllTy -- Var Type forAllTyAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m Var -> Rewrite c m Type -> Rewrite c m Type -- | Rewrite any children of a type of the form: ForAllTy -- Var Type forAllTyAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Var -> Rewrite c m Type -> Rewrite c m Type -- | Rewrite one child of a type of the form: ForAllTy Var -- Type forAllTyOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Var -> Rewrite c m Type -> Rewrite c m Type -- | Translate a type of the form: TyConApp TyCon -- [KindOrType] tyConAppT :: (ExtendPath c Crumb, Monad m) => Translate c m TyCon a1 -> (Int -> Translate c m KindOrType a2) -> (a1 -> [a2] -> b) -> Translate c m Type b -- | Rewrite all children of a type of the form: TyConApp -- TyCon [KindOrType] tyConAppAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m TyCon -> (Int -> Rewrite c m KindOrType) -> Rewrite c m Type -- | Rewrite any children of a type of the form: TyConApp -- TyCon [KindOrType] tyConAppAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m TyCon -> (Int -> Rewrite c m KindOrType) -> Rewrite c m Type -- | Rewrite one child of a type of the form: TyConApp -- TyCon [KindOrType] tyConAppOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m TyCon -> (Int -> Rewrite c m KindOrType) -> Rewrite c m Type -- | Translate a coercion of the form: Refl Type reflT :: (ExtendPath c Crumb, Monad m) => Translate c m Type b -> Translate c m Coercion b -- | Rewrite the Type child of a coercion of the form: Refl -- Type reflR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Type -> Rewrite c m Coercion -- | Translate a coercion of the form: TyConAppCo TyCon -- [Coercion] tyConAppCoT :: (ExtendPath c Crumb, Monad m) => Translate c m TyCon a1 -> (Int -> Translate c m Coercion a2) -> (a1 -> [a2] -> b) -> Translate c m Coercion b -- | Rewrite all children of a coercion of the form: TyConAppCo -- TyCon [Coercion] tyConAppCoAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m TyCon -> (Int -> Rewrite c m Coercion) -> Rewrite c m Coercion -- | Rewrite any children of a coercion of the form: TyConAppCo -- TyCon [Coercion] tyConAppCoAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m TyCon -> (Int -> Rewrite c m Coercion) -> Rewrite c m Coercion -- | Rewrite one child of a coercion of the form: TyConAppCo -- TyCon [Coercion] tyConAppCoOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m TyCon -> (Int -> Rewrite c m Coercion) -> Rewrite c m Coercion -- | Translate a coercion of the form: AppCo Coercion -- Coercion appCoT :: (ExtendPath c Crumb, Monad m) => Translate c m Coercion a1 -> Translate c m Coercion a2 -> (a1 -> a2 -> b) -> Translate c m Coercion b -- | Rewrite all children of a coercion of the form: AppCo -- Coercion Coercion appCoAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Coercion -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Rewrite any children of a coercion of the form: AppCo -- Coercion Coercion appCoAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Coercion -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Rewrite one child of a coercion of the form: AppCo -- Coercion Coercion appCoOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Coercion -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Translate a coercion of the form: ForAllCo TyVar -- Coercion forAllCoT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m TyVar a1 -> Translate c m Coercion a2 -> (a1 -> a2 -> b) -> Translate c m Coercion b -- | Rewrite all children of a coercion of the form: ForAllCo -- TyVar Coercion forAllCoAllR :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m TyVar -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Rewrite any children of a coercion of the form: ForAllCo -- TyVar Coercion forAllCoAnyR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m TyVar -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Rewrite one child of a coercion of the form: ForAllCo -- TyVar Coercion forAllCoOneR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m TyVar -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Translate a coercion of the form: CoVarCo CoVar coVarCoT :: (ExtendPath c Crumb, Monad m) => Translate c m CoVar b -> Translate c m Coercion b -- | Rewrite the CoVar child of a coercion of the form: -- CoVarCo CoVar coVarCoR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoVar -> Rewrite c m Coercion -- | Translate a coercion of the form: AxiomInstCo CoAxiom -- [Coercion] axiomInstCoT :: (ExtendPath c Crumb, Monad m) => Translate c m CoAxiom a1 -> (Int -> Translate c m Coercion a2) -> (a1 -> [a2] -> b) -> Translate c m Coercion b -- | Rewrite all children of a coercion of the form: AxiomInstCo -- CoAxiom [Coercion] axiomInstCoAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoAxiom -> (Int -> Rewrite c m Coercion) -> Rewrite c m Coercion -- | Rewrite any children of a coercion of the form: AxiomInstCo -- CoAxiom [Coercion] axiomInstCoAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m CoAxiom -> (Int -> Rewrite c m Coercion) -> Rewrite c m Coercion -- | Rewrite one child of a coercion of the form: AxiomInstCo -- CoAxiom [Coercion] axiomInstCoOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m CoAxiom -> (Int -> Rewrite c m Coercion) -> Rewrite c m Coercion -- | Translate a coercion of the form: UnsafeCo Type -- Type unsafeCoT :: (ExtendPath c Crumb, Monad m) => Translate c m Type a1 -> Translate c m Type a2 -> (a1 -> a2 -> b) -> Translate c m Coercion b -- | Rewrite all children of a coercion of the form: UnsafeCo -- Type Type unsafeCoAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Type -> Rewrite c m Type -> Rewrite c m Coercion -- | Rewrite any children of a coercion of the form: UnsafeCo -- Type Type unsafeCoAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Type -> Rewrite c m Type -> Rewrite c m Coercion -- | Rewrite one child of a coercion of the form: UnsafeCo -- Type Type unsafeCoOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Type -> Rewrite c m Type -> Rewrite c m Coercion -- | Translate a coercion of the form: SymCo Coercion symCoT :: (ExtendPath c Crumb, Monad m) => Translate c m Coercion b -> Translate c m Coercion b -- | Rewrite the Coercion child of a coercion of the form: -- SymCo Coercion symCoR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Coercion -> Rewrite c m Coercion -- | Translate a coercion of the form: TransCo Coercion -- Coercion transCoT :: (ExtendPath c Crumb, Monad m) => Translate c m Coercion a1 -> Translate c m Coercion a2 -> (a1 -> a2 -> b) -> Translate c m Coercion b -- | Rewrite all children of a coercion of the form: TransCo -- Coercion Coercion transCoAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Coercion -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Rewrite any children of a coercion of the form: TransCo -- Coercion Coercion transCoAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Coercion -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Rewrite one child of a coercion of the form: TransCo -- Coercion Coercion transCoOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Coercion -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Translate a coercion of the form: NthCo Int -- Coercion nthCoT :: (ExtendPath c Crumb, Monad m) => Translate c m Int a1 -> Translate c m Coercion a2 -> (a1 -> a2 -> b) -> Translate c m Coercion b -- | Rewrite all children of a coercion of the form: NthCo -- Int Coercion nthCoAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Int -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Rewrite any children of a coercion of the form: NthCo -- Int Coercion nthCoAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Int -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Rewrite one child of a coercion of the form: NthCo Int -- Coercion nthCoOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Int -> Rewrite c m Coercion -> Rewrite c m Coercion -- | Translate a coercion of the form: InstCo Coercion -- Type instCoT :: (ExtendPath c Crumb, Monad m) => Translate c m Coercion a1 -> Translate c m Type a2 -> (a1 -> a2 -> b) -> Translate c m Coercion b -- | Rewrite all children of a coercion of the form: InstCo -- Coercion Type instCoAllR :: (ExtendPath c Crumb, Monad m) => Rewrite c m Coercion -> Rewrite c m Type -> Rewrite c m Coercion -- | Rewrite any children of a coercion of the form: InstCo -- Coercion Type instCoAnyR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Coercion -> Rewrite c m Type -> Rewrite c m Coercion -- | Rewrite one child of a coercion of the form: InstCo -- Coercion Type instCoOneR :: (ExtendPath c Crumb, MonadCatch m) => Rewrite c m Coercion -> Rewrite c m Type -> Rewrite c m Coercion -- | Promote a rewrite on ModGuts to a rewrite on Core. promoteModGutsR :: (ExtendPath c Crumb, Monad m) => Rewrite c m ModGuts -> Rewrite c m Core -- | Promote a rewrite on CoreProg to a rewrite on Core. promoteProgR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoreProg -> Rewrite c m Core -- | Promote a rewrite on CoreBind to a rewrite on Core. promoteBindR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoreBind -> Rewrite c m Core -- | Promote a rewrite on CoreDef to a rewrite on Core. promoteDefR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoreDef -> Rewrite c m Core -- | Promote a rewrite on CoreExpr to a rewrite on Core. promoteExprR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoreExpr -> Rewrite c m Core -- | Promote a rewrite on CoreAlt to a rewrite on Core. promoteAltR :: (ExtendPath c Crumb, Monad m) => Rewrite c m CoreAlt -> Rewrite c m Core -- | Promote a bidirectional rewrite on CoreExpr to a bidirectional -- rewrite on Core. promoteExprBiR :: (ExtendPath c Crumb, Monad m) => BiRewrite c m CoreExpr -> BiRewrite c m Core -- | Promote a translate on ModGuts to a translate on Core. promoteModGutsT :: (ExtendPath c Crumb, Monad m) => Translate c m ModGuts b -> Translate c m Core b -- | Promote a translate on CoreProg to a translate on Core. promoteProgT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreProg b -> Translate c m Core b -- | Promote a translate on CoreBind to a translate on Core. promoteBindT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreBind b -> Translate c m Core b -- | Promote a translate on CoreDef to a translate on Core. promoteDefT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreDef b -> Translate c m Core b -- | Promote a translate on CoreExpr to a translate on Core. promoteExprT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreExpr b -> Translate c m Core b -- | Promote a translate on CoreAlt to a translate on Core. promoteAltT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreAlt b -> Translate c m Core b -- | Earlier versions of HERMIT used Int as the crumb type. This -- translation maps an Int to the corresponding Crumb, for -- backwards compatibility purposes. deprecatedIntToCrumbT :: Monad m => Int -> Translate c m Core Crumb -- | Builds a path to the first child, based on the old numbering system. deprecatedIntToPathT :: Monad m => Int -> Translate c m Core PathH instance (ExtendPath c Crumb, AddBindings c) => Walker c CoreTC instance (ExtendPath c Crumb, AddBindings c) => Walker c TyCo instance (ExtendPath c Crumb, AddBindings c) => Walker c Coercion instance (ExtendPath c Crumb, AddBindings c) => Walker c Type instance (ExtendPath c Crumb, AddBindings c) => Walker c Core module Language.HERMIT.External -- | An External is a Dynamic value with some associated -- meta-data (name, help string and tags). data External -- | External names are just strings. type ExternalName = String -- | Help information for Externals is stored as a list of strings, -- designed for multi-line displaying. type ExternalHelp = [String] -- | Get the name of an External. externName :: External -> ExternalName -- | Get the Dynamic value stored in an External. externFun :: External -> Dynamic -- | Get the list of help Strings for an External. externHelp :: External -> ExternalHelp -- | Build a Map from names to Dynamic values. toDictionary :: [External] -> Map ExternalName [Dynamic] -- | Build a Map from names to help information. toHelp :: [External] -> Map ExternalName ExternalHelp -- | The primitive way to build an External. external :: Extern a => ExternalName -> a -> ExternalHelp -> External -- | The class of things that can be made into Externals. To be an -- Extern there must exist an isomorphic Box type that is -- an instance of Typeable. class Typeable (Box a) => Extern a where type family Box a box :: Extern a => a -> Box a unbox :: Extern a => Box a -> a -- | Get all the Externals which match a given tag predicate and box -- a Translate of the appropriate type. matchingExternals :: (Extern tr, Tag t) => t -> [External] -> [(External, tr)] -- | Requirement: commands cannot have the same name as any CmdTag -- (or the help function will not find it). These should be user -- facing, because they give the user a way of sub-dividing our -- confusing array of commands. data CmdTag -- | Shell-specific command. Shell :: CmdTag -- | The arrow of evaluation (reduces a term). Eval :: CmdTag -- | KURE command. KURE :: CmdTag -- | Command may operate multiple times. Loop :: CmdTag -- | Command may make a deep change, can be O(n). Deep :: CmdTag -- | Command operates on local nodes only, O(1). Shallow :: CmdTag -- | Uses Path or Lens to focus onto something. Navigation :: CmdTag -- | A question we ask. Query :: CmdTag -- | Something that passes or fails. Predicate :: CmdTag -- | Introduce something, like a new name. Introduce :: CmdTag -- | Commute is when you swap nested terms. Commute :: CmdTag -- | Operation has a (perhaps undocumented) precondition. PreCondition :: CmdTag -- | Commands specifically to help debugging. Debug :: CmdTag -- | Version control for Core syntax. VersionControl :: CmdTag -- | Commands that are run by bash. Bash :: CmdTag -- | A command that uses its context, such as inlining. Context :: CmdTag -- | Commands that are not type safe (may cause Core Lint to fail), or may -- otherwise change the semantics of the program. Unsafe :: CmdTag -- | An incomplete or potentially buggy command. TODO :: CmdTag -- | Things we are trying out. Experiment :: CmdTag -- | A command that will be removed in a future release; it has probably -- been renamed or subsumed by another command. Deprecated :: CmdTag -- | A data type of logical operations on tags. data TagE :: * -- | Tags are meta-data that we add to Externals to make them -- sortable and searchable. class Tag a (.+) :: Tag a => External -> a -> External remTag :: Tag a => a -> External -> External tagMatch :: Tag a => a -> External -> Bool -- | An "and" on Tags. (.&) :: (Tag a, Tag b) => a -> b -> TagE -- | An "or" on Tags. (.||) :: (Tag a, Tag b) => a -> b -> TagE -- | A "not" on Tags. notT :: Tag a => a -> TagE -- | List all the CmdTags associated with an External externTags :: External -> [CmdTag] -- | Lists all the tags paired with a short description of what they're -- about. dictionaryOfTags :: [(CmdTag, String)] data TagBox TagBox :: TagE -> TagBox data IntBox IntBox :: Int -> IntBox data RewriteCoreBox RewriteCoreBox :: (RewriteH Core) -> RewriteCoreBox data RewriteCoreTCBox RewriteCoreTCBox :: (RewriteH CoreTC) -> RewriteCoreTCBox data BiRewriteCoreBox BiRewriteCoreBox :: (BiRewriteH Core) -> BiRewriteCoreBox data TranslateCoreStringBox TranslateCoreStringBox :: (TranslateH Core String) -> TranslateCoreStringBox data TranslateCoreTCStringBox TranslateCoreTCStringBox :: (TranslateH CoreTC String) -> TranslateCoreTCStringBox data TranslateCoreCheckBox TranslateCoreCheckBox :: (TranslateH Core ()) -> TranslateCoreCheckBox data NameBox NameBox :: (Name) -> NameBox newtype CoreString CoreString :: String -> CoreString unCoreString :: CoreString -> String data CoreBox CoreBox :: CoreString -> CoreBox data CrumbBox CrumbBox :: Crumb -> CrumbBox data PathBox PathBox :: PathH -> PathBox data TranslateCorePathBox TranslateCorePathBox :: (TranslateH Core PathH) -> TranslateCorePathBox data StringBox StringBox :: String -> StringBox data NameListBox NameListBox :: [Name] -> NameListBox data StringListBox StringListBox :: [String] -> StringListBox instance Typeable TagBox instance Typeable IntBox instance Typeable RewriteCoreBox instance Typeable RewriteCoreTCBox instance Typeable BiRewriteCoreBox instance Typeable TranslateCoreTCStringBox instance Typeable TranslateCoreStringBox instance Typeable TranslateCoreCheckBox instance Typeable NameBox instance Typeable CrumbBox instance Typeable PathBox instance Typeable TranslateCorePathBox instance Typeable CoreBox instance Typeable StringBox instance Typeable NameListBox instance Typeable StringListBox instance Eq CmdTag instance Show CmdTag instance Read CmdTag instance Bounded CmdTag instance Enum CmdTag instance Extern [String] instance Extern [Name] instance Extern String instance Extern CoreString instance Extern (TranslateH Core PathH) instance Extern PathH instance Extern Crumb instance Extern Name instance Extern (TranslateH Core ()) instance Extern (TranslateH Core String) instance Extern (TranslateH CoreTC String) instance Extern (BiRewriteH Core) instance Extern (RewriteH CoreTC) instance Extern (RewriteH Core) instance Extern Int instance Extern TagE instance (Extern a, Extern b) => Extern (a -> b) instance Tag CmdTag instance Tag TagE module Language.HERMIT.Primitive.Navigation.Crumbs -- | Externals for individual Crumbs. crumbExternals :: [External] module Language.HERMIT.Primitive.Kure externals :: [External] module Language.HERMIT.Primitive.Navigation -- | Externals involving navigating to named entities. externals :: [External] -- | Verify that this is a binding group defining the given name. bindGroup :: Name -> Core -> Bool -- | Verify that this is the definition of the given name. namedBinding :: Name -> Core -> Bool -- | Find the path to the RHS of the binding group of the given name. bindingGroupOf :: (AddBindings c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m) => Name -> Translate c m Core PathH -- | Find the path to the definiiton of the provided name. considerName :: (AddBindings c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m) => Name -> Translate c m Core PathH -- | Find the path to the RHS of the definition of the given name. rhsOf :: (ExtendPath c Crumb, AddBindings c, ReadPath c Crumb, MonadCatch m) => Name -> Translate c m Core PathH -- | Find the names of all the variables that could be targets of -- "consider". considerTargets :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m Core [String] -- | Language constructs that can be zoomed to. data Considerable Binding :: Considerable Definition :: Considerable CaseAlt :: Considerable Variable :: Considerable Literal :: Considerable Application :: Considerable Lambda :: Considerable LetIn :: Considerable CaseOf :: Considerable Casty :: Considerable Ticky :: Considerable TypeVar :: Considerable Coerce :: Considerable -- | Lookup table for constructs that can be considered; the keys are the -- arguments the user can give to the "consider" command. considerables :: [(String, Considerable)] -- | Find the path to the first matching construct. considerConstructT :: (AddBindings c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m) => Considerable -> Translate c m Core PathH -- | Construct a path to the (n-1)th argument in a nested sequence of -- Apps. nthArgPath :: Monad m => Int -> Translate c m CoreExpr PathH module Language.HERMIT.Interp -- | An Interp a is a possible means of converting a -- Typeable value to a value of type a. data Interp :: * -> * -- | The primitive way of building an Interp. interp :: Typeable a => (a -> b) -> Interp b -- | Interpret an ExprH by looking up the appropriate -- Dynamic(s) in the provided Map, then interpreting the -- Dynamic(s) with the provided Interps, returning the -- first interpretation to succeed (or an error string if none succeed). interpExprH :: Map String [Dynamic] -> [Interp a] -> ExprH -> Either String a instance Functor Interp module Language.HERMIT.Primitive.Debug -- | Exposed debugging Externals. externals :: [External] -- | Show before and after a rewrite. bracketR :: Injection a Core => String -> RewriteH a -> RewriteH a -- | Print out the Core, with a message. observeR :: Injection a Core => String -> RewriteH a -- | If the Rewrite fails, print out the Core, with a -- message. observeFailureR :: Injection a Core => String -> RewriteH a -> RewriteH a -- | Just say something, every time the rewrite is done. traceR :: String -> RewriteH a module Language.HERMIT.Primitive.GHC -- | Externals that reflect GHC functions, or are derived from GHC -- functions. externals :: [External] -- | Top-down traversal tuned to matching function calls. anyCallR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Core -> Rewrite c m Core -- | List all free identifiers (value-level free variables) in the -- expression. coreExprFreeIds :: CoreExpr -> Set Id -- | List all free variables (including types) in the expression. coreExprFreeVars :: CoreExpr -> Set Var -- | List all free variables in a type. typeFreeVars :: Type -> Set Var -- | Lifted version of coreExprFreeIds. freeIdsT :: Monad m => Translate c m CoreExpr (Set Id) -- | Lifted version of coreExprFreeVars. freeVarsT :: Monad m => Translate c m CoreExpr (Set Var) -- | Lifted version of typeFreeVars. freeTyVarsT :: Monad m => Translate c m Type (Set Var) -- | The free variables in a case alternative, which excludes any -- identifiers bound in the alternative. altFreeVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreAlt (Set Var) -- | A variant of altFreeVarsT that returns a function that accepts -- the case wild-card binder before giving a result. This is so we can -- use this with congruence combinators, for example: -- -- caseT id (const altFreeVarsT) $ _ wild _ fvs -> [ f wild | f <- -- fvs ] altFreeVarsExclWildT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreAlt (Id -> Set Var) -- | Substitute all occurrences of a variable with an expression, in either -- a program or an expression. substR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Var -> CoreExpr -> Rewrite c m Core -- | Substitute all occurrences of a variable with an expression, in an -- expression. substExprR :: Monad m => Var -> CoreExpr -> Rewrite c m CoreExpr -- | (let x = e1 in e2) ==> (e2[e1/x]), x must not be free in e1. letSubstR :: MonadCatch m => Rewrite c m CoreExpr -- | This is quite expensive (O(n) for the size of the sub-tree). safeLetSubstR :: (ReadBindings c, MonadCatch m) => Rewrite c m CoreExpr -- | safeLetSubstPlusR tries to inline a stack of bindings, stopping -- when reaches the end of the stack of lets. safeLetSubstPlusR :: (ExtendPath c Crumb, AddBindings c, ReadBindings c, MonadCatch m) => Rewrite c m CoreExpr exprEqual :: CoreExpr -> CoreExpr -> Bool exprsEqual :: [CoreExpr] -> Bool coreEqual :: Core -> Core -> Maybe Bool -- | Determine whether an identifier is in scope. inScope :: ReadBindings c => c -> Id -> Bool -- | Show a human-readable version of a list of Vars. showVars :: [Var] -> String -- | Lookup a rule and attempt to construct a corresponding rewrite. rule :: (ReadBindings c, HasCoreRules c) => String -> Rewrite c HermitM CoreExpr rules :: (ReadBindings c, HasCoreRules c) => [String] -> Rewrite c HermitM CoreExpr equivalent :: (a -> a -> Bool) -> [a] -> Bool -- | Note: this can miss several things that a whole-module core lint will -- find. For instance, running this on the RHS of a binding, the type of -- the RHS will not be checked against the type of the binding. Running -- on the whole let expression will catch that however. lintExprT :: (BoundVars c, Monad m, HasDynFlags m) => Translate c m CoreExpr String lintProgramT :: TranslateH CoreProg String -- | Run the Core Lint typechecker. Fails on errors, with error messages. -- Succeeds returning warnings. lintModuleT :: TranslateH ModGuts String specConstrR :: RewriteH ModGuts module Language.HERMIT.PrettyPrinter.Common type DocH = MDoc HermitMark data Attr PathAttr :: PathH -> Attr Color :: SyntaxForColor -> Attr SpecialFont :: Attr attrP :: PathH -> DocH -> DocH coText :: String -> DocH tyText :: String -> DocH coercionColor :: DocH -> DocH idColor :: DocH -> DocH keywordColor :: DocH -> DocH markColor :: SyntaxForColor -> DocH -> DocH typeColor :: DocH -> DocH data ShowOption Show :: ShowOption Abstract :: ShowOption Omit :: ShowOption Kind :: ShowOption specialFont :: DocH -> DocH data SpecialSymbol LambdaSymbol :: SpecialSymbol TypeOfSymbol :: SpecialSymbol RightArrowSymbol :: SpecialSymbol CastSymbol :: SpecialSymbol CoercionSymbol :: SpecialSymbol CoercionBindSymbol :: SpecialSymbol TypeSymbol :: SpecialSymbol TypeBindSymbol :: SpecialSymbol ForallSymbol :: SpecialSymbol data SyntaxForColor KeywordColor :: SyntaxForColor SyntaxColor :: SyntaxForColor IdColor :: SyntaxForColor CoercionColor :: SyntaxForColor TypeColor :: SyntaxForColor LitColor :: SyntaxForColor WarningColor :: SyntaxForColor coreRenders :: [(String, Handle -> PrettyOptions -> DocH -> IO ())] renderCode :: RenderCode a => PrettyOptions -> DocH -> a class (RenderSpecial a, Monoid a) => RenderCode a where rStart = mempty rEnd = mempty rStart :: RenderCode a => a rEnd :: RenderCode a => a rDoHighlight :: RenderCode a => Bool -> [Attr] -> a rPutStr :: RenderCode a => String -> a class RenderSpecial a renderSpecial :: RenderSpecial a => SpecialSymbol -> a newtype Unicode Unicode :: Char -> Unicode type PrettyH a = Translate PrettyC HermitM a DocH liftPrettyH :: (ReadBindings c, ReadPath c Crumb) => PrettyH a -> Translate c HermitM a DocH -- | Context for PrettyH translations. data PrettyC initPrettyC :: PrettyC liftPrettyC :: (ReadBindings c, ReadPath c Crumb) => c -> PrettyC newtype TranslateDocH a TranslateDocH :: (PrettyH a -> TranslateH a DocH) -> TranslateDocH a unTranslateDocH :: TranslateDocH a -> PrettyH a -> TranslateH a DocH data TranslateCoreTCDocHBox TranslateCoreTCDocHBox :: (TranslateDocH CoreTC) -> TranslateCoreTCDocHBox data PrettyOptions PrettyOptions :: Bool -> ShowOption -> ShowOption -> ShowOption -> Maybe PathH -> Maybe Int -> Bool -> Float -> Int -> PrettyOptions -- | Do you show fully qualified names? po_fullyQualified :: PrettyOptions -> Bool -- | Do you hide types, and type arguments, as ? po_exprTypes :: PrettyOptions -> ShowOption -- | Do you hide coercions? po_coercions :: PrettyOptions -> ShowOption -- | Do you give the types for all bindings? po_typesForBinders :: PrettyOptions -> ShowOption -- | This region should be highlighted (for sub-expression) po_highlight :: PrettyOptions -> Maybe PathH -- | below this depth are ..., Nothing => infinite po_depth :: PrettyOptions -> Maybe Int -- | notes might be added to output po_notes :: PrettyOptions -> Bool po_ribbon :: PrettyOptions -> Float po_width :: PrettyOptions -> Int updateTypeShowOption :: ShowOption -> PrettyOptions -> PrettyOptions updateCoShowOption :: ShowOption -> PrettyOptions -> PrettyOptions -- | like vcat and hcat, only make the list syntax explicit hlist :: [MDoc a] -> MDoc a -- | like vcat and hcat, only make the list syntax explicit vlist :: [MDoc a] -> MDoc a instance Typeable TranslateCoreTCDocHBox instance Show SyntaxForColor instance Show Attr instance Show HermitMark instance Eq ShowOption instance Ord ShowOption instance Show ShowOption instance Read ShowOption instance Show PrettyOptions instance Show SpecialSymbol instance Eq SpecialSymbol instance Ord SpecialSymbol instance Bounded SpecialSymbol instance Enum SpecialSymbol instance RenderCode DebugPretty instance Monoid DebugPretty instance RenderSpecial DebugPretty instance RenderCode ASCII instance RenderCode HTML instance RenderCode LaTeX instance RenderSpecial HTML instance Monoid HTML instance RenderSpecial LaTeX instance Monoid LaTeX instance RenderSpecial Unicode instance RenderSpecial ASCII instance Monoid ASCII instance RenderSpecial Char instance Default PrettyOptions instance BoundVars PrettyC instance AddBindings PrettyC instance ExtendPath PrettyC Crumb instance ReadPath PrettyC Crumb instance Extern (TranslateDocH CoreTC) -- | Output the raw Expr constructors. Helpful for writing pattern matching -- rewrites. module Language.HERMIT.PrettyPrinter.AST -- | Pretty print a fragment of GHC Core using HERMIT's "AST" pretty -- printer. This displays the tree of constructors using nested -- indentation. corePrettyH :: PrettyOptions -> PrettyH CoreTC -- | Output the raw Expr constructors. Helpful for writing pattern matching -- rewrites. module Language.HERMIT.PrettyPrinter.GHC -- | This pretty printer is just a reflection of GHC's standard pretty -- printer. corePrettyH :: PrettyOptions -> PrettyH CoreTC module Language.HERMIT.Kernel -- | A handle for a specific version of the ModGuts. data AST -- | A Kernel is a repository for complete Core syntax trees -- (ModGuts). For now, operations on a Kernel are -- sequential, but later it will be possible to have two applyKs -- running in parallel. data Kernel -- | Start a HERMIT client by providing an IO function that takes the -- initial Kernel and inital AST handle. The -- Modguts to CoreM Modguts' function required by GHC -- Plugins is returned. The callback is only ever called once. hermitKernel :: (Kernel -> AST -> IO ()) -> ModGuts -> CoreM ModGuts -- | Halt the Kernel and return control to GHC, which compiles the -- specified AST. resumeK :: Kernel -> AST -> IO () -- | Halt the Kernel and abort GHC without compiling. abortK :: Kernel -> IO () -- | Apply a Rewrite to the specified AST and return a handle -- to the resulting AST. applyK :: Kernel -> AST -> RewriteH ModGuts -> HermitMEnv -> IO (KureM AST) -- | Apply a TranslateH to the AST and return the resulting -- value. queryK :: Kernel -> forall a. AST -> TranslateH ModGuts a -> HermitMEnv -> IO (KureM a) -- | Delete the internal record of the specified AST. deleteK :: Kernel -> AST -> IO () -- | List all the ASTs tracked by the Kernel. listK :: Kernel -> IO [AST] instance Eq AST instance Ord AST instance Show AST module Language.HERMIT.Kernel.Scoped -- | A primitive means of denoting navigation of a tree (within a local -- scope). data Direction -- | Left L :: Direction -- | Right R :: Direction -- | Up U :: Direction -- | Top T :: Direction -- | The path within the current local scope. type LocalPath = SnocPath -- | Movement confined within the local scope. moveLocally :: Direction -> LocalPathH -> LocalPathH -- | Add a Path to the end of a LocalPath. extendLocalPath :: Path crumb -> LocalPath crumb -> LocalPath crumb -- | An alternative HERMIT kernel, that provides scoping. data ScopedKernel ScopedKernel :: (SAST -> IO (KureM ())) -> IO () -> (forall g. (Injection ModGuts g, Walker HermitC g) => SAST -> RewriteH g -> HermitMEnv -> IO (KureM SAST)) -> (forall a g. (Injection ModGuts g, Walker HermitC g) => SAST -> TranslateH g a -> HermitMEnv -> IO (KureM a)) -> (SAST -> IO (KureM ())) -> IO [SAST] -> (SAST -> IO (KureM [PathH])) -> (SAST -> (LocalPathH -> LocalPathH) -> HermitMEnv -> IO (KureM SAST)) -> (SAST -> IO (KureM SAST)) -> (SAST -> IO (KureM SAST)) -> Kernel -> (SAST -> IO (KureM AST)) -> ScopedKernel resumeS :: ScopedKernel -> SAST -> IO (KureM ()) abortS :: ScopedKernel -> IO () applyS :: ScopedKernel -> forall g. (Injection ModGuts g, Walker HermitC g) => SAST -> RewriteH g -> HermitMEnv -> IO (KureM SAST) queryS :: ScopedKernel -> forall a g. (Injection ModGuts g, Walker HermitC g) => SAST -> TranslateH g a -> HermitMEnv -> IO (KureM a) deleteS :: ScopedKernel -> SAST -> IO (KureM ()) listS :: ScopedKernel -> IO [SAST] pathS :: ScopedKernel -> SAST -> IO (KureM [PathH]) modPathS :: ScopedKernel -> SAST -> (LocalPathH -> LocalPathH) -> HermitMEnv -> IO (KureM SAST) beginScopeS :: ScopedKernel -> SAST -> IO (KureM SAST) endScopeS :: ScopedKernel -> SAST -> IO (KureM SAST) kernelS :: ScopedKernel -> Kernel toASTS :: ScopedKernel -> SAST -> IO (KureM AST) -- | A handle for an AST combined with scoping information. newtype SAST SAST :: Int -> SAST -- | Start a HERMIT client by providing an IO function that takes the -- initial ScopedKernel and inital SAST handle. The -- Modguts to CoreM Modguts' function required by GHC -- Plugins is returned. scopedKernel :: (ScopedKernel -> SAST -> IO ()) -> ModGuts -> CoreM ModGuts instance Eq Direction instance Show Direction instance Eq SAST instance Ord SAST instance Show SAST -- | Note: this module should NOT export externals. It is for common -- transformations needed by the other primitive modules. module Language.HERMIT.Primitive.Common -- | Apply a transformation to a value in the current context. applyInContextT :: Translate c m a b -> a -> Translate c m x b -- | Lift GHC's collectArgs callT :: Monad m => Translate c m CoreExpr (CoreExpr, [CoreExpr]) callPredT :: Monad m => (Id -> [CoreExpr] -> Bool) -> Translate c m CoreExpr (CoreExpr, [CoreExpr]) -- | Succeeds if we are looking at an application of given function -- returning zero or more arguments to which it is applied. callNameT :: MonadCatch m => Name -> Translate c m CoreExpr (CoreExpr, [CoreExpr]) -- | Succeeds if we are looking at a fully saturated function call. callSaturatedT :: Monad m => Translate c m CoreExpr (CoreExpr, [CoreExpr]) -- | Succeeds if we are looking at an application of given function callNameG :: MonadCatch m => Name -> Translate c m CoreExpr () -- | Succeeds if we are looking at an application of a data constructor. callDataConT :: MonadCatch m => Translate c m CoreExpr (DataCon, [Type], [CoreExpr]) -- | Succeeds if we are looking at an application of a named data -- constructor. callDataConNameT :: MonadCatch m => Name -> Translate c m CoreExpr (DataCon, [Type], [CoreExpr]) -- | Apply a rewrite to all applications of a given function in a top-down -- manner, pruning on success. callsR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Name -> Rewrite c m CoreExpr -> Rewrite c m Core -- | Apply a translate to all applications of a given function in a -- top-down manner, pruning on success, collecting the results. callsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Name -> Translate c m CoreExpr b -> Translate c m Core [b] -- | List all identifiers bound at the top-level in a program. progIdsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreProg [Id] -- | List the identifiers bound by the top-level binding group at the head -- of the program. consIdsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreProg [Id] -- | List the identifiers bound by a recursive top-level binding group at -- the head of the program. consRecIdsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreProg [Id] -- | Return the identifier bound by a non-recursive top-level binding at -- the head of the program. consNonRecIdT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreProg Id -- | List all variables bound in a binding group. bindVarsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreBind [Var] -- | Return the variable bound by a non-recursive let expression. nonRecVarT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreBind Var -- | List all identifiers bound in a recursive binding group. recIdsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreBind [Id] -- | Return the identifier bound by a recursive definition. defIdT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreDef Id -- | Return the variable bound by a lambda expression. lamVarT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr Var -- | List the variables bound by a let expression. letVarsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreExpr [Var] -- | List the identifiers bound by a recursive let expression. letRecIdsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr [Id] -- | Return the variable bound by a non-recursive let expression. letNonRecVarT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr Var -- | List all variables bound by a case expression (in the alternatives and -- the wildcard binder). caseVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr [Var] -- | Return the case wildcard binder. caseWildIdT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr Id -- | List the variables bound by all alternatives in a case expression. caseAltVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr [[Var]] -- | List the variables bound by a case alternative. altVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreAlt [Var] -- | Lifted version of boundVars. boundVarsT :: (BoundVars c, Monad m) => Translate c m a (Set Var) -- | Find the unique variable bound in the context that matches the given -- name, failing if it is not unique. findBoundVarT :: (BoundVars c, MonadCatch m) => Name -> Translate c m a Var -- | Lookup the name in the context first, then, failing that, in GHC's -- global reader environment. findIdT :: (BoundVars c, HasGlobalRdrEnv c, HasDynFlags m, MonadThings m, MonadCatch m) => Name -> Translate c m a Id findId :: (BoundVars c, HasGlobalRdrEnv c, HasDynFlags m, MonadThings m) => Name -> c -> m Id -- | Constructs a common error message. Argument String should be -- the desired form of the expression. wrongExprForm :: String -> String -- | Determine if a list contains no duplicated elements. nodups :: Eq a => [a] -> Bool mapAlts :: (CoreExpr -> CoreExpr) -> [CoreAlt] -> [CoreAlt] module Language.HERMIT.Primitive.AlphaConversion -- | Externals for alpha-renaming. externals :: [External] -- | Alpha rename any bindings at this node. Note: does not rename case -- alternatives unless invoked on the alternative. alpha :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => Rewrite c HermitM Core -- | Alpha rename a lambda binder. Optionally takes a suggested new name. alphaLam :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => Maybe Name -> Rewrite c HermitM CoreExpr -- | Alpha rename a case binder. Optionally takes a suggested new name. alphaCaseBinder :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => Maybe Name -> Rewrite c HermitM CoreExpr -- | Rename the variables bound in a case alternative with the given list -- of suggested names. alphaAltWith :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => [Name] -> Rewrite c HermitM CoreAlt -- | Rename the specified variables in a case alternative. alphaAltVars :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => [Var] -> Rewrite c HermitM CoreAlt -- | Rename all identifiers bound in a case alternative. alphaAlt :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => Rewrite c HermitM CoreAlt -- | Rename all identifiers bound in a case expression. alphaCase :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => Rewrite c HermitM CoreExpr -- | Rename the identifiers bound in a Let with the given list of suggested -- names. alphaLetWith :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => [Name] -> Rewrite c HermitM CoreExpr -- | Rename the specified variables bound in a let. alphaLetVars :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => [Var] -> Rewrite c HermitM CoreExpr -- | Rename all identifiers bound in a Let. alphaLet :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => Rewrite c HermitM CoreExpr -- | Rename the identifiers bound in the top-level binding at the head of -- the program with the given list of suggested names. alphaConsWith :: (ExtendPath c Crumb, AddBindings c) => [Name] -> Rewrite c HermitM CoreProg -- | Rename local variables with manifestly unique names (x, x0, x1, ...). -- Does not rename top-level definitions. unshadow :: (ExtendPath c Crumb, AddBindings c, BoundVars c) => Rewrite c HermitM Core -- | List all visible identifiers (in the expression or the context). visibleVarsT :: (BoundVars c, Monad m) => Translate c m CoreExpr (Set Var) -- | If a name is provided replace the string with that, otherwise modify -- the string making sure to not clash with any visible variables. freshNameGenT :: (BoundVars c, Monad m) => Maybe Name -> Translate c m CoreExpr (String -> String) -- | Use the optional argument if given, otherwise generate a new name -- avoiding clashes with the list of variables. freshNameGenAvoiding :: Maybe Name -> Set Var -> (String -> String) -- | Replace all occurrences of a specified variable. Arguments are the -- variable to replace and the replacement variable, respectively. replaceVarR :: (ExtendPath c Crumb, AddBindings c, Injection a Core, MonadCatch m) => Var -> Var -> Rewrite c m a module Language.HERMIT.Primitive.Inline -- | Externals for inlining variables. externals :: [External] getUnfolding :: ReadBindings c => Bool -> Bool -> Id -> c -> HermitM (CoreExpr, Int) -- | Inline the current variable. inline :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | If the current variable matches the given name, then inline it. inlineName :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Name -> Rewrite c HermitM CoreExpr -- | Inline the current variable, using the scrutinee rather than the case -- alternative if it is a case wild-card binder. inlineScrutinee :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | If the current variable is a case wild-card binder, then inline it. inlineCaseBinder :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | Get list of possible inline targets. Used by shell for completion. inlineTargets :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Translate c HermitM Core [String] module Language.HERMIT.Primitive.Fold externals :: [External] foldR :: ReadBindings c => Name -> Rewrite c HermitM CoreExpr stashFoldR :: ReadBindings c => Label -> Rewrite c HermitM CoreExpr stashFoldAnyR :: ReadBindings c => Rewrite c HermitM CoreExpr module Language.HERMIT.Primitive.Unfold externals :: [External] -- | cleanupUnfoldR cleans a unfold operation (for example, an inline or -- rule application) It is used at the level of the top-redex. Invariant: -- will not introduce let bindings cleanupUnfoldR :: MonadCatch m => Rewrite c m CoreExpr -- | Stash a binding with a name for later use. Allows us to look at past -- definitions. rememberR :: Label -> Rewrite c HermitM Core showStashT :: Injection CoreDef a => PrettyH a -> Translate c HermitM a DocH -- | A more powerful inline. Matches two cases: Var ==> inlines -- App ==> inlines the head of the function call for the app tree unfoldR :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr unfoldPredR :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => (Id -> [CoreExpr] -> Bool) -> Rewrite c HermitM CoreExpr unfoldNameR :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Name -> Rewrite c HermitM CoreExpr unfoldAnyR :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => [Name] -> Rewrite c HermitM CoreExpr unfoldSaturatedR :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | Stash a binding with a name for later use. Allows us to look at past -- definitions. rememberR :: String -> Translate c m Core () rememberR -- label = contextfreeT $ core -> case core of DefCore def -> -- saveDef label def BindCore (NonRec i e) -> saveDef label (Def i e) -- _ -> fail remember: not a binding -- -- Apply a stashed definition (like inline, but looks in stash instead of -- context). unfoldStashR :: ReadBindings c => String -> Rewrite c HermitM CoreExpr specializeR :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr module Language.HERMIT.PrettyPrinter.Clean -- | Pretty print a fragment of GHC Core using HERMIT's "Clean" pretty -- printer. corePrettyH :: PrettyOptions -> PrettyH CoreTC module Language.HERMIT.ParserCore parseCore :: CoreString -> HermitC -> HermitM CoreExpr instance Eq Token instance Show Token module Language.HERMIT.Primitive.Local.Case -- | Externals relating to Case expressions. externals :: [External] -- | case s of w; C vs -> e ==> e if w and vs are not free in e caseElim :: Rewrite c HermitM CoreExpr -- | (case s of alt1 -> e1; alt2 -> e2) v ==> case s of alt1 -> -- e1 v; alt2 -> e2 v caseFloatApp :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | f (case s of alt1 -> e1; alt2 -> e2) ==> case s -- of alt1 -> f e1; alt2 -> f e2 Only safe if f is -- strict. caseFloatArg :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | case (case s1 of alt11 -> e11; alt12 -> e12) of alt21 -> e21; -- alt22 -> e22 ==> case s1 of alt11 -> case e11 of alt21 -> -- e21; alt22 -> e22 alt12 -> case e12 of alt21 -> e21; alt22 -- -> e22 caseFloatCase :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | cast (case s of p -> e) co ==> case s of p -> cast e co caseFloatCast :: MonadCatch m => Rewrite c m CoreExpr -- | let v = case s of alt1 -> e1 in e ==> case s of alt1 -> let v -- = e1 in e caseFloatLet :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | Float a Case whatever the context. caseFloat :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | Unfloat a Case whatever the context. caseUnfloat :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr -- | Unimplemented! caseUnfloatApp :: Monad m => Rewrite c m CoreExpr caseUnfloatArgs :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr caseReduce :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | Case-of-known-constructor rewrite. caseReduceDatacon :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr caseReduceLiteral :: MonadCatch m => Rewrite c m CoreExpr -- | Case split a free variable in an expression: -- -- Assume expression e which mentions x :: [a] -- -- e ==> case x of x [] -> e (a:b) -> e caseSplit :: Name -> Rewrite c HermitM CoreExpr -- | Like caseSplit, but additionally inlines the constructor applications -- for each occurance of the named variable. -- --
--   caseSplitInline nm = caseSplit nm >>> anybuR (inlineName nm)
--   
caseSplitInline :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Name -> Rewrite c HermitM Core module Language.HERMIT.Primitive.Local.Cast -- | Externals relating to Case expressions. externals :: [External] castElimRefl :: MonadCatch m => Rewrite c m CoreExpr castElimSym :: MonadCatch m => Rewrite c m CoreExpr castFloatApp :: MonadCatch m => Rewrite c m CoreExpr castElimSymPlus :: (ExtendPath c Crumb, AddBindings c, Monad m) => Rewrite c m CoreExpr module Language.HERMIT.Primitive.Local.Let -- | Externals relating to Let expressions. externals :: [External] letElim :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr -- | e ==> (let v = e in v), name of v is provided letIntro :: Name -> Rewrite c HermitM CoreExpr -- | (let v = ev in e) x ==> let v = ev in e x letFloatApp :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | f (let v = ev in e) ==> let v = ev in f e letFloatArg :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | let v = (let w = ew in ev) in e ==> let w = ew in let -- v = ev in e letFloatLet :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | ( v1 -> let v2 = e1 in e2) ==> let v2 = e1 in ( v1 -- -> e2) Fails if v1 occurs in e1. If -- v1 = v2 then v1 will be alpha-renamed. letFloatLam :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | case (let bnds in e) of wild alts ==> let bnds in -- (case e of wild alts) Fails if any variables bound in -- bnds occurs in alts. letFloatCase :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | cast (let bnds in e) co ==> let bnds in cast e co letFloatCast :: MonadCatch m => Rewrite c m CoreExpr -- | Float a Let through an expression, whatever the context. letFloatExpr :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | ProgCons (NonRec v (Let (NonRec w ew) ev)) p ==> -- ProgCons (NonRec w ew) (ProgCons (NonRec v ev) p) letFloatLetTop :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreProg -- | Remove an unused non-recursive let binding. let v = E1 in E2 -- ==> E2, if v is not free in E2 letNonRecElim :: MonadCatch m => Rewrite c m CoreExpr -- | Remove all unused recursive let bindings in the current group. letRecElim :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr -- | let v = ev in e ==> case ev of v -> e letToCase :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExpr -- | Unfloat a Let if possible. letUnfloat :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr -- | let v = ev in f a ==> (let v = ev in f) (let v = ev in -- a) letUnfloatApp :: MonadCatch m => Rewrite c m CoreExpr -- | let v = ev in case s of p -> e ==> case (let v = ev -- in s) of p -> let v = ev in e, if v does not shadow a -- pattern binder in p letUnfloatCase :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr -- | let v = ev in x -> e ==> x -> let v = ev in -- e if v does not shadow x letUnfloatLam :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr -- | Re-order a sequence of nested non-recursive let bindings. The argument -- list should contain the let-bound variables, in the desired order. reorderNonRecLets :: MonadCatch m => [Name] -> Rewrite c m CoreExpr module Language.HERMIT.Primitive.Local -- | Externals for local structural manipulations. (Many taken from Chapter -- 3 of Andre Santos' dissertation.) externals :: [External] -- | Abstract over a variable using a lambda. e ==> ( x. e) x abstract :: (ReadBindings c, MonadCatch m) => Name -> Rewrite c m CoreExpr -- | NonRec v e ==> Rec [Def v e] nonrecToRec :: MonadCatch m => Rewrite c m CoreBind -- | ((\ v -> e1) e2) ==> (let v = e2 in e1) This form of -- beta-reduction is safe if e2 is an arbitrary expression (won't -- duplicate work). betaReduce :: MonadCatch m => Rewrite c m CoreExpr -- | Perform one or more beta-reductions. betaReducePlus :: MonadCatch m => Rewrite c m CoreExpr -- | (let v = e1 in e2) ==> (\ v -> e2) e1 betaExpand :: MonadCatch m => Rewrite c m CoreExpr -- | (\ v -> e1 v) ==> e1 etaReduce :: MonadCatch m => Rewrite c m CoreExpr -- | e1 ==> (\ v -> e1 v) etaExpand :: String -> Rewrite c HermitM CoreExpr -- | Perform multiple eta-expansions. multiEtaExpand :: (ExtendPath c Crumb, AddBindings c) => [String] -> Rewrite c HermitM CoreExpr -- | Flatten all the top-level binding groups in the module to a single -- recursive binding group. flattenModule :: (ExtendPath c Crumb, Monad m) => Rewrite c m ModGuts -- | Flatten all the top-level binding groups in a program to a program -- containing a single recursive binding group. flattenProgramR :: Monad m => Rewrite c m CoreProg -- | Flatten all the top-level binding groups in a program to a single -- recursive binding group. flattenProgramT :: Monad m => Translate c m CoreProg CoreBind module Language.HERMIT.Primitive.New externals :: [External] isVar :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Name -> Translate c m CoreExpr () simplifyR :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM Core collectLets :: CoreExpr -> ([(Var, CoreExpr)], CoreExpr) -- | Combine nested non-recursive lets into case of a tuple. letTupleR :: Name -> Rewrite c HermitM CoreExpr staticArg :: (ExtendPath c Crumb, AddBindings c) => Rewrite c HermitM CoreDef testQuery :: MonadCatch m => Rewrite c m Core -> Translate c m Core String -- | Push a function through a Case or Let expression. Unsafe if the -- function is not strict. push :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Name -> Rewrite c HermitM CoreExpr parseCoreExprT :: CoreString -> TranslateH a CoreExpr unsafeReplace :: CoreString -> RewriteH CoreExpr unsafeReplaceStash :: String -> RewriteH CoreExpr inlineAll :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => [Name] -> Rewrite c HermitM Core module Language.HERMIT.Primitive.FixPoint -- | Externals for manipulating fixed points, and for the worker/wrapper -- transformation. externals :: [External] -- | f = e ==> f = fix (\ f -> e) fixIntro :: RewriteH CoreDef -- | fix ty f <==> f (fix ty f) fixComputationRule :: BiRewriteH CoreExpr -- | fix tyA (\ a -> f (g a)) <==> f (fix tyB (\ b -- -> g (f b)) rollingRule :: BiRewriteH CoreExpr module Language.HERMIT.Dictionary -- | A Dictionary is a collection of Dynamics. Looking up a -- Dynamic (via a String key) returns a list, as there can -- be multiple Dynamics with the same name. type Dictionary = Map String [Dynamic] -- | List of all Externals provided by HERMIT. externals :: [External] -- | Create a dictionary from a list of Externals. mkDict :: [External] -> Dictionary -- | The pretty-printing dictionaries. pp_dictionary :: Map String (PrettyOptions -> PrettyH CoreTC) bashR :: [External] -> RewriteH Core bashDebugR :: Bool -> [External] -> RewriteH Core module Language.HERMIT.Shell.Command -- | The first argument is a list of files to load. commandLine :: [FilePath] -> Behavior -> [External] -> ScopedKernel -> SAST -> IO () unicodeConsole :: Handle -> PrettyOptions -> DocH -> IO () instance Typeable AstEffect instance Typeable MetaCommand instance Typeable QueryFun instance Typeable ShellEffect instance Typeable ShellCommandBox instance Show Navigation instance Show CompletionType instance RenderCode UnicodeTerminal instance Monoid UnicodeTerminal instance RenderSpecial UnicodeTerminal instance Extern ShellCommand instance Extern ShellEffect instance Extern MetaCommand instance Extern QueryFun instance Extern AstEffect module HERMIT.Driver hermit_version :: String ghcFlags :: [String] module Language.HERMIT.Optimize optimize :: ([CommandLineOption] -> OM ()) -> Plugin query :: (Injection ModGuts g, Walker HermitC g) => TranslateH g a -> OM a run :: RewriteH Core -> OM () interactive :: [External] -> [CommandLineOption] -> OM () display :: OM () setPretty :: (PrettyOptions -> PrettyH CoreTC) -> OM () setPrettyOptions :: PrettyOptions -> OM () at :: TranslateH Core PathH -> OM () -> OM () phase :: Int -> OM () -> OM () after :: CorePass -> OM () -> OM () before :: CorePass -> OM () -> OM () allPhases :: OM () -> OM () firstPhase :: OM () -> OM () lastPhase :: OM () -> OM () module HERMIT plugin :: Plugin