Commit bb89c59f authored by gmainland's avatar gmainland
Browse files

Add support for top-level finalizers

parent 18f2e523
......@@ -64,6 +64,8 @@ class (Monad m, Applicative m) => Quasi m where
qAddTopDecls :: [Dec] -> m ()
qAddModFinalizer :: Q () -> m ()
-----------------------------------------------------
-- The IO instance of Quasi
--
......@@ -91,6 +93,7 @@ instance Quasi IO where
qRecover _ _ = badIO "recover" -- Maybe we could fix this?
qAddDependentFile _ = badIO "addDependentFile"
qAddTopDecls _ = badIO "addTopDecls"
qAddModFinalizer _ = badIO "addModFinalizer"
qRunIO m = m
......@@ -346,6 +349,11 @@ addDependentFile fp = Q (qAddDependentFile fp)
addTopDecls :: [Dec] -> Q ()
addTopDecls ds = Q (qAddTopDecls ds)
-- | Add a finalizer that will run in the Q monad after the current module has
-- been type checked. This only makes sense when run within a top-level splice.
addModFinalizer :: Q () -> Q ()
addModFinalizer act = Q (qAddModFinalizer (unQ act))
instance Quasi Q where
qNewName = newName
qReport = report
......@@ -358,6 +366,7 @@ instance Quasi Q where
qRunIO = runIO
qAddDependentFile = addDependentFile
qAddTopDecls = addTopDecls
qAddModFinalizer = addModFinalizer
----------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment