-- 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.1.2.0 on Reverse.hs]
--   % ghc Reverse.hs -fforce-recomp -O2 -dcore-lint -fsimple-list-literals -fplugin=HERMIT -fplugin-opt=HERMIT:main:Main: -fplugin-opt=HERMIT:main:Main:resume
--   [1 of 2] Compiling HList            ( HList.hs, HList.o )
--   Loading package ghc-prim ... linking ... done.
--   ...
--   Loading package hermit-0.1.2.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.1.2.0 on Reverse.hs]
--   % ghc Reverse.hs -fforce-recomp -O2 -dcore-lint -fsimple-list-literals -fplugin=HERMIT -fplugin-opt=HERMIT:main:Main:
--   [1 of 2] Compiling HList            ( HList.hs, HList.o )
--   Loading package ghc-prim ... linking ... done.
--   ...
--   Loading package hermit-0.1.2.0 ... linking ... done.
--   [2 of 2] Compiling Main             ( Reverse.hs, Reverse.o )
--   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 compile, use resume. -- --
--   ...
--   hermit<0> resume
--   hermit<0> Linking Reverse ...
--   $
--   
@package hermit @version 0.1.2.0 module Language.HERMIT.Primitive.Utils appCount :: CoreExpr -> Int module Language.HERMIT.Expr -- | 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 -- | Nested lists to represent scoping structure. data StmtH expr ExprH :: expr -> StmtH expr ScopeH :: [StmtH expr] -> StmtH expr -- | Parse an expression. parseExprH :: String -> Either String ExprH -- | Parse a list of statements, seperated by semicolons. parseStmtsH :: String -> Either String [StmtH ExprH] unparseExprH :: ExprH -> String unparseStmtH :: StmtH ExprH -> String unparseStmtsH :: [StmtH ExprH] -> String -- | Count the total number of statements. numStmtsH :: [StmtH expr] -> Int instance Eq ExprH instance Show ExprH instance Show expr => Show (StmtH expr) instance Show e => Show (Box e) module Language.HERMIT.CoreExtra -- | Core is the sum type of all nodes in the AST that we wish to be able -- to traverse. All Node instances in HERMIT define their -- Generic type to be Core. data Core -- | The module. ModGutsCore :: ModGuts -> Core -- | A program (list of top-level bindings). ProgramCore :: CoreProgram -> Core -- | A binding group. BindCore :: CoreBind -> Core -- | A recursive definition. DefCore :: CoreDef -> Core -- | An expression. ExprCore :: CoreExpr -> Core -- | A case alternative. AltCore :: CoreAlt -> Core -- | 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 provide one. type CoreTickish = Tickish Id -- | Convert a list of recursive definitions into an (isomorphic) recursive -- binding group. defToRecBind :: [CoreDef] -> CoreBind module Language.HERMIT.Context -- | HERMIT's representation of variable bindings. data HermitBinding -- | Binding depth, whether it is recursive, and the bound value (which -- cannot be inlined without checking for scoping issues). BIND :: Int -> Bool -> CoreExpr -> HermitBinding -- | For a lambda binding you only know the depth. LAM :: Int -> HermitBinding -- | For case wildcard binders. First expr points to scrutinee, second to -- AltCon (which can be converted to Constructor or Literal). CASE :: Int -> CoreExpr -> (AltCon, [Id]) -> HermitBinding -- | Get the depth of a binding. hermitBindingDepth :: HermitBinding -> Int -- | 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 Context -- | Create the initial HERMIT Context by providing a -- ModGuts. initContext :: ModGuts -> Context -- | Update the context by extending the stored AbsolutePath to a -- child. (@@) :: Context -> Int -> Context -- | Add the Ids bound by a DataCon in a case. Like lambda bindings, in -- that we know nothing about them, but all bound at the same depth, so -- we cannot just fold addLambdaBinding over the list. addAltBindings :: [Id] -> Context -> Context -- | Add all bindings in a binding group to the Context. addBinding :: CoreBind -> Context -> Context -- | Add the bindings for a specific case alternative. addCaseBinding :: (Id, CoreExpr, CoreAlt) -> Context -> Context -- | Add a binding that you know nothing about, except that it may shadow -- something. If so, do not worry about it here, just remember the -- binding and the depth. When we want to inline a value from the -- environment, we then check to see what is free in the inlinee, and see -- if any of the frees will stop the validity of the inlining. addLambdaBinding :: Id -> Context -> Context -- | All (important) bindings in scope. hermitBindings :: Context -> Map Id HermitBinding -- | The depth of the bindings. hermitDepth :: Context -> Int -- | The AbsolutePath to the current node from the root. hermitPath :: Context -> AbsolutePath -- | The ModGuts of the current module. hermitModGuts :: Context -> ModGuts -- | Lookup the binding for an identifier in a Context. lookupHermitBinding :: Id -> Context -> Maybe HermitBinding -- | List all the identifiers bound in the Context. listBindings :: Context -> [Id] -- | Determine if an identifier is bound in the Context. boundIn :: Id -> Context -> Bool instance PathContext Context 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. newVarH :: String -> Type -> HermitM Id -- | Make a unique type variable for a specified kind based on a provided -- name. newTypeVarH :: String -> Kind -> HermitM TyVar cloneIdH :: (String -> String) -> Id -> HermitM Id -- | A label for individual defintions. 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 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 DebugCore :: String -> Context -> 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 -- | A basic error Monad. KURE users may use either KureMonad -- or their own Monad(s). data KureMonad a :: * -> * -- | Eliminator for KureMonad. runKureMonad :: (a -> b) -> (String -> b) -> KureMonad a -> b -- | Get the value from a KureMonad, providing a function to handle -- the error case. fromKureMonad :: (String -> a) -> KureMonad a -> a type TranslateH a b = Translate Context HermitM a b type RewriteH a = Rewrite Context HermitM a type LensH a b = Lens Context HermitM a b -- | A synonym for the identity rewrite. Convienient to avoid importing -- Control.Category. idR :: RewriteH a -- | Core is the sum type of all nodes in the AST that we wish to be able -- to traverse. All Node instances in HERMIT define their -- Generic type to be Core. data Core -- | The module. ModGutsCore :: ModGuts -> Core -- | A program (list of top-level bindings). ProgramCore :: CoreProgram -> Core -- | A binding group. BindCore :: CoreBind -> Core -- | A recursive definition. DefCore :: CoreDef -> Core -- | An expression. ExprCore :: CoreExpr -> Core -- | A case alternative. AltCore :: CoreAlt -> Core -- | 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 -- | Translate a module. Slightly different to the other congruence -- combinators: it passes in *all* of the original to the reconstruction -- function. modGutsT :: TranslateH CoreProgram a -> (ModGuts -> a -> b) -> TranslateH ModGuts b -- | Rewrite the CoreProgram child of a module. modGutsR :: RewriteH CoreProgram -> RewriteH ModGuts -- | Translate an empty list. nilT :: b -> TranslateH [a] b -- | Translate a program of the form: (CoreBind : -- CoreProgram) consBindT :: TranslateH CoreBind a1 -> TranslateH CoreProgram a2 -> (a1 -> a2 -> b) -> TranslateH CoreProgram b -- | Rewrite all children of a program of the form: (CoreBind -- : CoreProgram) consBindAllR :: RewriteH CoreBind -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Rewrite any children of a program of the form: (CoreBind -- : CoreProgram) consBindAnyR :: RewriteH CoreBind -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Rewrite one child of a program of the form: (CoreBind -- : CoreProgram) consBindOneR :: RewriteH CoreBind -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Translate a binding group of the form: NonRec Id -- CoreExpr nonRecT :: TranslateH CoreExpr a -> (Id -> a -> b) -> TranslateH CoreBind b -- | Rewrite the CoreExpr child of a binding group of the form: -- NonRec Id CoreExpr nonRecR :: RewriteH CoreExpr -> RewriteH CoreBind -- | Translate a binding group of the form: Rec [CoreDef] recT :: (Int -> TranslateH CoreDef a) -> ([a] -> b) -> TranslateH CoreBind b -- | Rewrite all children of a binding group of the form: Rec -- [CoreDef] recAllR :: (Int -> RewriteH CoreDef) -> RewriteH CoreBind -- | Rewrite any children of a binding group of the form: Rec -- [CoreDef] recAnyR :: (Int -> RewriteH CoreDef) -> RewriteH CoreBind -- | Rewrite one child of a binding group of the form: Rec -- [CoreDef] recOneR :: (Int -> RewriteH CoreDef) -> RewriteH CoreBind -- | Translate a recursive definition of the form: Def Id -- CoreExpr defT :: TranslateH CoreExpr a -> (Id -> a -> b) -> TranslateH CoreDef b -- | Rewrite the CoreExpr child of a recursive definition of the -- form: Def Id CoreExpr defR :: RewriteH CoreExpr -> RewriteH CoreDef -- | Translate a case alternative of the form: (AltCon, [Id], -- CoreExpr) altT :: TranslateH CoreExpr a -> (AltCon -> [Id] -> a -> b) -> TranslateH CoreAlt b -- | Rewrite the CoreExpr child of a case alternative of the form: -- (AltCon, Id, CoreExpr) altR :: RewriteH CoreExpr -> RewriteH CoreAlt -- | Translate an expression of the form: Var Id varT :: (Id -> b) -> TranslateH CoreExpr b -- | Translate an expression of the form: Lit Literal litT :: (Literal -> b) -> TranslateH CoreExpr b -- | Translate an expression of the form: App CoreExpr -- CoreExpr appT :: TranslateH CoreExpr a1 -> TranslateH CoreExpr a2 -> (a1 -> a2 -> b) -> TranslateH CoreExpr b -- | Rewrite all children of an expression of the form: App -- CoreExpr CoreExpr appAllR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Rewrite any children of an expression of the form: App -- CoreExpr CoreExpr appAnyR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Rewrite one child of an expression of the form: App -- CoreExpr CoreExpr appOneR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Translate an expression of the form: Lam Id -- CoreExpr lamT :: TranslateH CoreExpr a -> (Id -> a -> b) -> TranslateH CoreExpr b -- | Rewrite the CoreExpr child of an expression of the form: -- Lam Id CoreExpr lamR :: RewriteH CoreExpr -> RewriteH CoreExpr -- | Translate an expression of the form: Let CoreBind -- CoreExpr letT :: TranslateH CoreBind a1 -> TranslateH CoreExpr a2 -> (a1 -> a2 -> b) -> TranslateH CoreExpr b -- | Rewrite all children of an expression of the form: Let -- CoreBind CoreExpr letAllR :: RewriteH CoreBind -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Rewrite any children of an expression of the form: Let -- CoreBind CoreExpr letAnyR :: RewriteH CoreBind -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Rewrite one child of an expression of the form: Let -- CoreBind CoreExpr letOneR :: RewriteH CoreBind -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Translate an expression of the form: Case CoreExpr -- Id Type [CoreAlt] caseT :: TranslateH CoreExpr a1 -> (Int -> TranslateH CoreAlt a2) -> (a1 -> Id -> Type -> [a2] -> b) -> TranslateH CoreExpr b -- | Rewrite all children of an expression of the form: Case -- CoreExpr Id Type [CoreAlt] caseAllR :: RewriteH CoreExpr -> (Int -> RewriteH CoreAlt) -> RewriteH CoreExpr -- | Rewrite any children of an expression of the form: Case -- CoreExpr Id Type [CoreAlt] caseAnyR :: RewriteH CoreExpr -> (Int -> RewriteH CoreAlt) -> RewriteH CoreExpr -- | Rewrite one child of an expression of the form: Case -- CoreExpr Id Type [CoreAlt] caseOneR :: RewriteH CoreExpr -> (Int -> RewriteH CoreAlt) -> RewriteH CoreExpr -- | Translate an expression of the form: Cast CoreExpr -- Coercion castT :: TranslateH CoreExpr a -> (a -> Coercion -> b) -> TranslateH CoreExpr b -- | Rewrite the CoreExpr child of an expression of the form: -- Cast CoreExpr Coercion castR :: RewriteH CoreExpr -> RewriteH CoreExpr -- | Translate an expression of the form: Tick CoreTickish -- CoreExpr tickT :: TranslateH CoreExpr a -> (CoreTickish -> a -> b) -> TranslateH CoreExpr b -- | Rewrite the CoreExpr child of an expression of the form: -- Tick CoreTickish CoreExpr tickR :: RewriteH CoreExpr -> RewriteH CoreExpr -- | Translate an expression of the form: Type Type typeT :: (Type -> b) -> TranslateH CoreExpr b -- | Translate an expression of the form: Coercion Coercion coercionT :: (Coercion -> b) -> TranslateH CoreExpr b -- | Translate a binding group of the form: Rec [(Id, -- CoreExpr)] recDefT :: (Int -> TranslateH CoreExpr a1) -> ([(Id, a1)] -> b) -> TranslateH CoreBind b -- | Rewrite all children of a binding group of the form: Rec -- [(Id, CoreExpr)] recDefAllR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreBind -- | Rewrite any children of a binding group of the form: Rec -- [(Id, CoreExpr)] recDefAnyR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreBind -- | Rewrite one child of a binding group of the form: Rec -- [(Id, CoreExpr)] recDefOneR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreBind -- | Translate an expression of the form: Let (NonRec -- Id CoreExpr) CoreExpr letNonRecT :: TranslateH CoreExpr a1 -> TranslateH CoreExpr a2 -> (Id -> a1 -> a2 -> b) -> TranslateH CoreExpr b -- | Rewrite all children of an expression of the form: Let -- (NonRec Id CoreExpr) CoreExpr letNonRecAllR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Rewrite any children of an expression of the form: Let -- (NonRec Id CoreExpr) CoreExpr letNonRecAnyR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Rewrite one child of an expression of the form: Let -- (NonRec Id CoreExpr) CoreExpr letNonRecOneR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Translate an expression of the form: Let (Rec -- [CoreDef]) CoreExpr letRecT :: (Int -> TranslateH CoreDef a1) -> TranslateH CoreExpr a2 -> ([a1] -> a2 -> b) -> TranslateH CoreExpr b -- | Rewrite all children of an expression of the form: Let -- (Rec [CoreDef]) CoreExpr letRecAllR :: (Int -> RewriteH CoreDef) -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Rewrite any children of an expression of the form: Let -- (Rec [CoreDef]) CoreExpr letRecAnyR :: (Int -> RewriteH CoreDef) -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Rewrite one child of an expression of the form: Let -- (Rec [CoreDef]) CoreExpr letRecOneR :: (Int -> RewriteH CoreDef) -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Translate an expression of the form: Let (Rec -- [(Id, CoreExpr)]) CoreExpr letRecDefT :: (Int -> TranslateH CoreExpr a1) -> TranslateH CoreExpr a2 -> ([(Id, a1)] -> a2 -> b) -> TranslateH CoreExpr b -- | Rewrite all children of an expression of the form: Let -- (Rec [(Id, CoreExpr)]) CoreExpr letRecDefAllR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Rewrite any children of an expression of the form: Let -- (Rec [(Id, CoreExpr)]) CoreExpr letRecDefAnyR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Rewrite one child of an expression of the form: Let -- (Rec [(Id, CoreExpr)]) CoreExpr letRecDefOneR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -> RewriteH CoreExpr -- | Translate a program of the form: (NonRec Id -- CoreExpr) : CoreProgram consNonRecT :: TranslateH CoreExpr a1 -> TranslateH CoreProgram a2 -> (Id -> a1 -> a2 -> b) -> TranslateH CoreProgram b -- | Rewrite all children of an expression of the form: (NonRec -- Id CoreExpr) : CoreProgram consNonRecAllR :: RewriteH CoreExpr -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Rewrite any children of an expression of the form: (NonRec -- Id CoreExpr) : CoreProgram consNonRecAnyR :: RewriteH CoreExpr -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Rewrite one child of an expression of the form: (NonRec -- Id CoreExpr) : CoreProgram consNonRecOneR :: RewriteH CoreExpr -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Translate an expression of the form: (Rec [CoreDef]) -- : CoreProgram consRecT :: (Int -> TranslateH CoreDef a1) -> TranslateH CoreProgram a2 -> ([a1] -> a2 -> b) -> TranslateH CoreProgram b -- | Rewrite all children of an expression of the form: (Rec -- [CoreDef]) : CoreProgram consRecAllR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Rewrite any children of an expression of the form: (Rec -- [CoreDef]) : CoreProgram consRecAnyR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Rewrite one child of an expression of the form: (Rec -- [CoreDef]) : CoreProgram consRecOneR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Translate an expression of the form: (Rec [(Id, -- CoreExpr)]) : CoreProgram consRecDefT :: (Int -> TranslateH CoreExpr a1) -> TranslateH CoreProgram a2 -> ([(Id, a1)] -> a2 -> b) -> TranslateH CoreProgram b -- | Rewrite all children of an expression of the form: (Rec -- [(Id, CoreExpr)]) : CoreProgram consRecDefAllR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Rewrite any children of an expression of the form: (Rec -- [(Id, CoreExpr)]) : CoreProgram consRecDefAnyR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Rewrite one child of an expression of the form: (Rec -- [(Id, CoreExpr)]) : CoreProgram consRecDefOneR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProgram -> RewriteH CoreProgram -- | Translate an expression of the form: Case CoreExpr -- Id Type [(AltCon, [Id], CoreExpr)] caseAltT :: TranslateH CoreExpr a1 -> (Int -> TranslateH CoreExpr a2) -> (a1 -> Id -> Type -> [(AltCon, [Id], a2)] -> b) -> TranslateH CoreExpr b -- | Rewrite all children of an expression of the form: Case -- CoreExpr Id Type [(AltCon, [Id], -- CoreExpr)] caseAltAllR :: RewriteH CoreExpr -> (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -- | Rewrite any children of an expression of the form: Case -- CoreExpr Id Type [(AltCon, [Id], -- CoreExpr)] caseAltAnyR :: RewriteH CoreExpr -> (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -- | Rewrite one child of an expression of the form: Case -- CoreExpr Id Type [(AltCon, [Id], -- CoreExpr)] caseAltOneR :: RewriteH CoreExpr -> (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -- | Promote a rewrite on ModGuts to a rewrite on Core. promoteModGutsR :: RewriteH ModGuts -> RewriteH Core -- | Promote a rewrite on CoreProgram to a rewrite on Core. promoteProgramR :: RewriteH CoreProgram -> RewriteH Core -- | Promote a rewrite on CoreBind to a rewrite on Core. promoteBindR :: RewriteH CoreBind -> RewriteH Core -- | Promote a rewrite on CoreDef to a rewrite on Core. promoteDefR :: RewriteH CoreDef -> RewriteH Core -- | Promote a rewrite on CoreExpr to a rewrite on Core. promoteExprR :: RewriteH CoreExpr -> RewriteH Core -- | Promote a rewrite on CoreAlt to a rewrite on Core. promoteAltR :: RewriteH CoreAlt -> RewriteH Core -- | Promote a translate on ModGuts to a translate on Core. promoteModGutsT :: TranslateH ModGuts b -> TranslateH Core b -- | Promote a translate on CoreProgram to a translate on -- Core. promoteProgramT :: TranslateH CoreProgram b -> TranslateH Core b -- | Promote a translate on CoreBind to a translate on Core. promoteBindT :: TranslateH CoreBind b -> TranslateH Core b -- | Promote a translate on CoreDef to a translate on Core. promoteDefT :: TranslateH CoreDef b -> TranslateH Core b -- | Promote a translate on CoreExpr to a translate on Core. promoteExprT :: TranslateH CoreExpr b -> TranslateH Core b -- | Promote a translate on CoreAlt to a translate on Core. promoteAltT :: TranslateH CoreAlt b -> TranslateH Core b instance Walker Context HermitM CoreExpr instance Node CoreExpr instance Injection CoreExpr Core instance Walker Context HermitM CoreAlt instance Node CoreAlt instance Injection CoreAlt Core instance Walker Context HermitM CoreDef instance Node CoreDef instance Injection CoreDef Core instance Walker Context HermitM CoreBind instance Node CoreBind instance Injection CoreBind Core instance Walker Context HermitM CoreProgram instance Node CoreProgram instance Injection CoreProgram Core instance Walker Context HermitM ModGuts instance Node ModGuts instance Injection ModGuts Core instance Walker Context HermitM Core instance Node 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 -- | 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 command. Shell :: CmdTag -- | The arrow of evaluation (reduces a term). Eval :: CmdTag -- | KURE command. KURE :: CmdTag -- | Command may operate multiple times. Loop :: CmdTag -- | O(n) Deep :: CmdTag -- | 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 -- | It's all about the commute. Commute :: CmdTag -- | Operation has a precondition. PreCondition :: CmdTag -- | Commands to help debugging. Debug :: CmdTag -- | Version control. VersionControl :: CmdTag -- | Commands that are run by bash. Bash :: CmdTag -- | a command that uses its context, like inline Context :: CmdTag -- | TODO: check before the release. TODO :: CmdTag -- | Something is not finished yet, do not use. Unimplemented :: CmdTag -- | Things we are trying out. Experiment :: 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 TranslateCoreStringBox TranslateCoreStringBox :: (TranslateH Core String) -> TranslateCoreStringBox data TranslateCoreCheckBox TranslateCoreCheckBox :: (TranslateH Core ()) -> TranslateCoreCheckBox data NameBox NameBox :: (Name) -> NameBox data TranslateCorePathBox TranslateCorePathBox :: (TranslateH Core Path) -> TranslateCorePathBox data StringBox StringBox :: String -> StringBox instance Typeable TagBox instance Typeable IntBox instance Typeable RewriteCoreBox instance Typeable TranslateCoreStringBox instance Typeable TranslateCoreCheckBox instance Typeable NameBox instance Typeable TranslateCorePathBox instance Typeable StringBox instance Eq CmdTag instance Show CmdTag instance Read CmdTag instance Bounded CmdTag instance Enum CmdTag instance Extern String instance Extern (TranslateH Core Path) instance Extern Name instance Extern (TranslateH Core ()) instance Extern (TranslateH Core String) 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.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.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 :: Name -> TranslateH Core Path -- | Find the path to the definiiton of the provided name. considerName :: Name -> TranslateH Core Path -- | Find the path to the RHS of the definition of the given name. rhsOf :: Name -> TranslateH Core Path -- | 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 all the possible targets of "consider". considerTargets :: TranslateH Core [String] module Language.HERMIT.PrettyPrinter type DocH = MDoc HermitMark data HermitMark PushAttr :: Attr -> HermitMark PopAttr :: HermitMark data Attr PathAttr :: Path -> Attr Color :: SyntaxForColor -> Attr SpecialFont :: Attr data SyntaxForColor KeywordColor :: SyntaxForColor SyntaxColor :: SyntaxForColor VarColor :: SyntaxForColor TypeColor :: SyntaxForColor LitColor :: SyntaxForColor attr :: Attr -> DocH -> DocH attrP :: Path -> DocH -> DocH varColor :: DocH -> DocH keywordColor :: DocH -> DocH markColor :: SyntaxForColor -> DocH -> DocH specialFont :: DocH -> DocH type PrettyH a = TranslateH a DocH data PrettyOptions PrettyOptions :: Bool -> ShowOption -> ShowOption -> Maybe Path -> Maybe Int -> Bool -> Float -> Int -> PrettyOptions po_fullyQualified :: PrettyOptions -> Bool po_exprTypes :: PrettyOptions -> ShowOption po_typesForBinders :: PrettyOptions -> ShowOption po_highlight :: PrettyOptions -> Maybe Path po_depth :: PrettyOptions -> Maybe Int -- | notes might be added to output po_notes :: PrettyOptions -> Bool po_ribbon :: PrettyOptions -> Float po_width :: PrettyOptions -> Int data ShowOption Show :: ShowOption Abstract :: ShowOption Omit :: ShowOption data SpecialSymbol LambdaSymbol :: SpecialSymbol TypeOfSymbol :: SpecialSymbol RightArrowSymbol :: SpecialSymbol TypeSymbol :: SpecialSymbol TypeBindSymbol :: SpecialSymbol ForallSymbol :: SpecialSymbol class RenderSpecial a renderSpecial :: RenderSpecial a => SpecialSymbol -> a newtype ASCII ASCII :: String -> ASCII newtype Unicode Unicode :: Char -> Unicode newtype LaTeX LaTeX :: String -> LaTeX newtype HTML HTML :: String -> HTML renderSpecialFont :: RenderSpecial a => Char -> Maybe a specialFontMap :: Map Char SpecialSymbol 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 data PrettyState PrettyState :: Path -> Maybe SyntaxForColor -> PrettyState prettyPath :: PrettyState -> Path prettyColor :: PrettyState -> Maybe SyntaxForColor renderCode :: RenderCode a => PrettyOptions -> DocH -> a ghcCorePrettyH :: PrettyH Core coreRenders :: [(String, Handle -> PrettyOptions -> DocH -> IO ())] latexVerbatim :: String -> LaTeX -> LaTeX latexToString :: LaTeX -> String data DebugPretty DebugPretty :: String -> DebugPretty 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 -- | Output the raw Expr constructors. Helpful for writing pattern matching -- rewrites. module Language.HERMIT.PrettyPrinter.AST listify :: (MDoc a -> MDoc a -> MDoc a) -> [MDoc a] -> MDoc a -- | like vcat and hcat, only make the list syntax explicit vlist :: [MDoc a] -> MDoc a -- | like vcat and hcat, only make the list syntax explicit hlist :: [MDoc a] -> MDoc a corePrettyH :: PrettyOptions -> PrettyH Core -- | Output the raw Expr constructors. Helpful for writing pattern matching -- rewrites. module Language.HERMIT.PrettyPrinter.Clean listify :: (MDoc a -> MDoc a -> MDoc a) -> [MDoc a] -> MDoc a -- | like vcat and hcat, only make the list syntax explicit vlist :: [MDoc a] -> MDoc a -- | like vcat and hcat, only make the list syntax explicit hlist :: [MDoc a] -> MDoc a data RetExpr RetLam :: [DocH] -> DocH -> RetExpr RetLet :: [DocH] -> DocH -> RetExpr RetApp :: DocH -> [RetExpr] -> RetExpr RetExpr :: DocH -> RetExpr RetAtom :: DocH -> RetExpr RetEmpty :: RetExpr isAtom :: RetExpr -> Bool specialSymbol :: SpecialSymbol -> DocH symbol :: Char -> DocH keyword :: String -> DocH ppParens :: DocH -> DocH atomExpr :: RetExpr -> DocH normalExpr :: RetExpr -> DocH typeSymbol :: DocH typeBindSymbol :: DocH corePrettyH :: PrettyOptions -> PrettyH Core -- | Output the raw Expr constructors. Helpful for writing pattern matching -- rewrites. module Language.HERMIT.PrettyPrinter.GHC listify :: (MDoc a -> MDoc a -> MDoc a) -> [MDoc a] -> MDoc a -- | like vcat and hcat, only make the list syntax explicit vlist :: [MDoc a] -> MDoc a -- | like vcat and hcat, only make the list syntax explicit hlist :: [MDoc a] -> MDoc a corePrettyH :: PrettyOptions -> PrettyH Core -- | JSON pretty printer module Language.HERMIT.PrettyPrinter.JSON corePrettyH :: PrettyOptions -> TranslateH Core Value module Language.HERMIT.Primitive.Debug -- | Exposed debugging Externals. externals :: [External] -- | Just say something, every time the rewrite is done. traceR :: String -> RewriteH a -- | Print out the Core, with a message. observeR :: (Injection a Core, Generic a ~ Core) => String -> RewriteH a -- | If the Rewrite fails, print out the Core, with a -- message. observeFailureR :: (Injection a Core, Generic a ~ Core) => String -> RewriteH a -> RewriteH a module Language.HERMIT.Primitive.GHC externals :: [External] substR :: Id -> CoreExpr -> RewriteH Core substExprR :: Id -> CoreExpr -> RewriteH CoreExpr substTopBindR :: Id -> CoreExpr -> RewriteH CoreProgram letSubstR :: RewriteH CoreExpr letSubstNR :: Int -> RewriteH Core safeLetSubstR :: RewriteH CoreExpr -- | safeLetSubstPlusR tries to inline a stack of bindings, stopping -- when reaches the end of the stack of lets. safeLetSubstPlusR :: RewriteH CoreExpr -- | Output a list of all free variables in an expression. freeIdsQuery :: TranslateH CoreExpr String -- | Show a human-readable version of a Var. showVar :: DynFlags -> Var -> String -- | Show a human-readable version of a list of Vars. showVars :: DynFlags -> [Var] -> String freeIdsT :: TranslateH CoreExpr [Id] freeVarsT :: TranslateH CoreExpr [Var] coreExprFreeVars :: CoreExpr -> [Var] coreExprFreeIds :: CoreExpr -> [Id] -- | -- -- (Actually, within a single type there might still be shadowing, -- because substTy is a no-op for the empty substitution, but -- that's probably OK.) deShadowBindsR :: RewriteH CoreProgram rulesToEnv :: [CoreRule] -> Map String (RewriteH CoreExpr) rulesToRewriteH :: [CoreRule] -> RewriteH CoreExpr -- | See whether an identifier is in scope. inScope :: Context -> Id -> Bool rules :: String -> RewriteH CoreExpr getHermitRules :: Generic a ~ Core => TranslateH a [(String, [CoreRule])] rules_help :: TranslateH Core String makeRule :: String -> Id -> CoreExpr -> CoreRule addCoreBindAsRule :: String -> Name -> RewriteH ModGuts flattenModule :: RewriteH ModGuts mergeBinds :: RewriteH CoreProgram occurAnalyseExpr :: CoreExpr -> CoreExpr occurAnalyseExprR :: RewriteH CoreExpr exprEqual :: CoreExpr -> CoreExpr -> Bool bindEqual :: CoreBind -> CoreBind -> Maybe Bool coreEqual :: Core -> Core -> Maybe Bool compareValues :: Name -> Name -> TranslateH Core () arityOf :: Context -> Id -> Int castElimination :: RewriteH CoreExpr module Language.HERMIT.Primitive.Unfold externals :: [External] -- | Stash a binding with a name for later use. Allows us to look at past -- definitions. stashDef :: String -> RewriteH Core -- | Stash a binding with a name for later use. Allows us to look at past -- definitions. stashDef :: String -> TranslateH Core () stashDef -- label = contextfreeT $ core -> case core of DefCore def -> -- saveDef label def BindCore (NonRec i e) -> saveDef label (Def i e) -- _ -> fail stashDef: not a binding -- -- Apply a stashed definition (like inline, but looks in stash instead of -- context). stashApply :: String -> RewriteH CoreExpr getUnfolding :: Monad m => Bool -> Bool -> Id -> Context -> m (CoreExpr, Int) module Language.HERMIT.Primitive.Inline externals :: [External] inlineName :: Name -> RewriteH CoreExpr inline :: RewriteH CoreExpr inlineScrutinee :: RewriteH CoreExpr inlineCaseBinder :: RewriteH CoreExpr -- | The implementation of inline, an important transformation. This *only* -- works on a Var of the given name. It can trivially be prompted to more -- general cases. configurableInline :: Bool -> Bool -> RewriteH CoreExpr -- | Ensure all the free variables in an expression were bound above a -- given depth. Assumes minimum depth is 0. ensureDepth :: Int -> TranslateH Core Bool -- | Get list of possible inline targets. Used by shell for completion. inlineTargets :: TranslateH Core [String] module Language.HERMIT.Primitive.Fold externals :: [External] foldR :: Name -> RewriteH CoreExpr stashFoldR :: String -> RewriteH CoreExpr module Language.HERMIT.Primitive.AlphaConversion externals :: [External] visibleIds :: TranslateH CoreExpr [Id] freshNameGen :: (Maybe Name) -> [Id] -> (String -> String) freshNameGenT :: (Maybe Name) -> TranslateH CoreExpr (String -> String) inventNames :: [Id] -> String -> String shadowedNamesT :: TranslateH CoreExpr [String] -- | Output a list of all variables that shadowed by bindings in the is -- expression. shadowedNamesQuery :: TranslateH CoreExpr String ifShadowingR :: RewriteH CoreExpr -- | Arguments are the original identifier and the replacement identifier, -- respectively. renameIdR :: (Injection a Core, Generic a ~ Core) => Id -> Id -> RewriteH a -- | Given an identifier to replace, and a replacement, produce an -- Id -> Id function that acts as in identity -- for all Ids except the one to replace, for which it returns the -- replacment. Don't export this, it'll likely just cause confusion. replaceId :: Id -> Id -> (Id -> Id) -- | Alpha rename a lambda binder. Optionally takes a suggested new name. alphaLam :: Maybe Name -> RewriteH CoreExpr -- | Alpha rename a case binder. Optionally takes a suggested new name. alphaCaseBinder :: Maybe Name -> RewriteH CoreExpr -- | Rename the specified identifier in a case alternative. Optionally -- takes a suggested new name. alphaAltId :: Maybe Name -> Id -> RewriteH CoreAlt -- | Rename all identifiers bound in a case alternative. alphaAlt :: RewriteH CoreAlt -- | Rename all identifiers bound in a case expression. alphaCase :: RewriteH CoreExpr -- | Alpha rename a non-recursive let binder. Optionally takes a suggested -- new name. alphaLetNonRec :: Maybe Name -> RewriteH CoreExpr -- | Rename the specified identifier bound in a recursive let. Optionally -- takes a suggested new name. alphaLetRecId :: Maybe Name -> Id -> RewriteH CoreExpr -- | Rename all identifiers bound in a recursive let. alphaLetRec :: RewriteH CoreExpr -- | Rename the identifier bound in a recursive let with a single -- recursively bound identifier. Optionally takes a suggested new name. alphaLetRecOne :: Maybe Name -> RewriteH CoreExpr -- | Rename the identifier bound in a let with a single bound identifier. -- Optionally takes a suggested new name. alphaLetOne :: Maybe Name -> RewriteH CoreExpr -- | Rename all identifiers bound in a Let. alphaLet :: RewriteH CoreExpr -- | Alpha rename a non-recursive top-level binder. Optionally takes a -- suggested new name. alphaConsNonRec :: Maybe Name -> RewriteH CoreProgram -- | Rename the specified identifier bound in a recursive top-level binder. -- Optionally takes a suggested new name. alphaConsRecId :: Maybe Name -> Id -> RewriteH CoreProgram -- | Rename all identifiers bound in a recursive top-level binder. alphaConsRec :: RewriteH CoreProgram -- | Rename the identifier bound in a recursive top-level binder with a -- single recursively bound identifier. Optionally takes a suggested new -- name. alphaConsRecOne :: Maybe Name -> RewriteH CoreProgram -- | Rename the identifier bound in a top-level binder with a single bound -- identifier. Optionally takes a suggested new name. alphaConsOne :: Maybe Name -> RewriteH CoreProgram -- | Rename all identifiers bound in a Let. alphaCons :: RewriteH CoreProgram -- | Alpha rename any bindings at this node. Note: does not rename case -- alternatives unless invoked on the alternative. alpha :: RewriteH Core unshadow :: RewriteH Core wrongFormForAlpha :: String -> String module Language.HERMIT.Kernel -- | A handle for a specific version of the ModGuts. data AST -- | A Kernel is a repository for Core syntax trees. 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 Core -> HermitMEnv -> IO (KureMonad AST) -- | Apply a TranslateH to the AST and return the resulting -- value. queryK :: Kernel -> forall a. AST -> TranslateH Core a -> HermitMEnv -> IO (KureMonad 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 -- | Down D :: Direction -- | Top T :: Direction -- | The path within the current local scope. data LocalPath -- | Movement confined within the local scope. moveLocally :: Direction -> LocalPath -> LocalPath -- | Add a Path to the end of a LocalPath. extendLocalPath :: Path -> LocalPath -> LocalPath -- | An alternative HERMIT kernel, that provides scoping. data ScopedKernel ScopedKernel :: (SAST -> IO ()) -> IO () -> (SAST -> RewriteH Core -> HermitMEnv -> IO (KureMonad SAST)) -> (forall a. SAST -> TranslateH Core a -> HermitMEnv -> IO (KureMonad a)) -> (SAST -> IO ()) -> IO [SAST] -> (SAST -> IO [Path]) -> (SAST -> (LocalPath -> LocalPath) -> HermitMEnv -> IO (KureMonad SAST)) -> (SAST -> IO SAST) -> (SAST -> IO SAST) -> ScopedKernel resumeS :: ScopedKernel -> SAST -> IO () abortS :: ScopedKernel -> IO () applyS :: ScopedKernel -> SAST -> RewriteH Core -> HermitMEnv -> IO (KureMonad SAST) queryS :: ScopedKernel -> forall a. SAST -> TranslateH Core a -> HermitMEnv -> IO (KureMonad a) deleteS :: ScopedKernel -> SAST -> IO () listS :: ScopedKernel -> IO [SAST] pathS :: ScopedKernel -> SAST -> IO [Path] modPathS :: ScopedKernel -> SAST -> (LocalPath -> LocalPath) -> HermitMEnv -> IO (KureMonad SAST) beginScopeS :: ScopedKernel -> SAST -> IO SAST endScopeS :: ScopedKernel -> SAST -> IO SAST -- | 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 LocalPath instance Eq SAST instance Ord SAST instance Show SAST instance Show LocalPath module Language.HERMIT.Primitive.Local.Case -- | Externals relating to Case expressions. externals :: [External] -- | case (let v = e1 in e2) of alts ==> let v = e1 in case e2 of alts letFloatCase :: RewriteH CoreExpr -- | (case s of alt1 -> e1; alt2 -> e2) v ==> case s of alt1 -> -- e1 v; alt2 -> e2 v caseFloatApp :: RewriteH 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 :: RewriteH 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 :: RewriteH CoreExpr -- | let v = case ec of alt1 -> e1 in e ==> case ec of alt1 -> let -- v = e1 in e caseFloatLet :: RewriteH CoreExpr -- | Float a Case whatever the context. caseFloat :: RewriteH CoreExpr -- | Case-of-known-constructor rewrite. caseReduce :: RewriteH 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 -> RewriteH CoreExpr -- | Like caseSplit, but additionally inlines the constructor applications -- for each occurance of the named variable. -- --
--   caseSplitInline nm = caseSplit nm >>> anybuR (inlineName nm)
--   
caseSplitInline :: Name -> RewriteH Core module Language.HERMIT.Primitive.Local.Let -- | Externals relating to Let expressions. externals :: [External] -- | e => (let v = e in v), name of v is provided letIntro :: Name -> RewriteH CoreExpr -- | (let v = ev in e) x ==> let v = ev in e x letFloatApp :: RewriteH CoreExpr -- | f (let v = ev in e) ==> let v = ev in f e letFloatArg :: RewriteH CoreExpr -- | let v = (let w = ew in ev) in e ==> let w = ew in let v = ev in e letFloatLet :: RewriteH CoreExpr -- | Float a Let through an expression, whatever the context. letFloatExpr :: RewriteH CoreExpr -- | NonRec v (Let (NonRec w ew) ev) : bds ==> NonRec w ew : NonRec v ev -- : bds letFloatLetTop :: RewriteH CoreProgram -- | let v = ev in e ==> case ev of v -> e letToCase :: RewriteH CoreExpr module Language.HERMIT.Primitive.Local externals :: [External] betaReduce :: RewriteH CoreExpr multiBetaReduce :: (Int -> Bool) -> RewriteH CoreExpr betaReducePlus :: RewriteH CoreExpr betaExpand :: RewriteH CoreExpr etaReduce :: RewriteH CoreExpr etaExpand :: Name -> RewriteH CoreExpr multiEtaExpand :: [Name] -> RewriteH CoreExpr dce :: RewriteH CoreExpr module Language.HERMIT.Primitive.New externals :: [External] isVar :: Name -> TranslateH CoreExpr () simplifyR :: RewriteH Core letPairR :: Name -> RewriteH CoreExpr letTupleR :: Name -> RewriteH CoreExpr info :: TranslateH Core String exprTypeT :: TranslateH CoreExpr String showExprType :: DynFlags -> CoreExpr -> String showIdInfo :: DynFlags -> Id -> String coreNode :: Core -> String coreConstructor :: Core -> String testQuery :: RewriteH Core -> TranslateH Core String findId :: (MonadUnique m, MonadIO m, MonadThings m, HasDynFlags m) => Context -> String -> m Id findIdMG :: (MonadUnique m, MonadIO m, MonadThings m, HasDynFlags m) => ModGuts -> String -> m Id -- | f = e ==> f = fix ( f -> e) fixIntro :: RewriteH CoreDef fixSpecialization :: RewriteH CoreExpr fixSpecialization' :: RewriteH CoreExpr -- | cleanupUnfold cleans a unfold operation (for example, an inline or -- rule application) It is used at the level of the top-redex. cleanupUnfold :: RewriteH CoreExpr unfold :: Name -> RewriteH CoreExpr withUnfold :: RewriteH Core -> RewriteH Core -- | Push a function through a Case or Let expression. Unsafe if the -- function is not strict. push :: Name -> RewriteH CoreExpr -- | Abstract over a variable using a lambda. e ==> ( x. e) x abstract :: Name -> RewriteH CoreExpr module Language.HERMIT.Dictionary -- | Augment a list of Externals by adding all of HERMIT's primitive -- Externals, plus any GHC RULES pragmas in the module. all_externals :: [External] -> [External] -- | Create the dictionary. dictionary :: [External] -> Map String [Dynamic] -- | The pretty-printing dictionaries. pp_dictionary :: Map String (PrettyOptions -> PrettyH Core) module Language.HERMIT.Plugin -- | Given a list of CommandLineOptions, produce the ModGuts -- to ModGuts function required to build a plugin. type HermitPass = [CommandLineOption] -> ModGuts -> CoreM ModGuts -- | Build a hermit plugin. This mainly handles the per-module options. hermitPlugin :: HermitPass -> Plugin module Language.HERMIT.Shell.Command -- | The first argument is a list of files to load. commandLine :: [String] -> Behavior -> ModGuts -> CoreM ModGuts 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 plugin :: Plugin