Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sanchayan Maity
GHC
Commits
fdce179c
Commit
fdce179c
authored
11 years ago
by
Geoffrey Mainland
Browse files
Options
Downloads
Patches
Plain Diff
Add support for Template Haskell state.
parent
646b6301
Branches
reword-readme
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
compiler/typecheck/TcRnMonad.lhs
+6
-0
6 additions, 0 deletions
compiler/typecheck/TcRnMonad.lhs
compiler/typecheck/TcRnTypes.lhs
+7
-0
7 additions, 0 deletions
compiler/typecheck/TcRnTypes.lhs
compiler/typecheck/TcSplice.lhs
+14
-0
14 additions, 0 deletions
compiler/typecheck/TcSplice.lhs
with
27 additions
and
0 deletions
compiler/typecheck/TcRnMonad.lhs
+
6
−
0
View file @
fdce179c
...
...
@@ -53,6 +53,10 @@ import Util
import Data.IORef
import qualified Data.Set as Set
import Control.Monad
#ifdef GHCI
import qualified Data.Map as Map
#endif
\end{code}
...
...
@@ -95,6 +99,7 @@ initTc hsc_env hsc_src keep_rn_syntax mod do_this
th_topdecls_var <- newIORef [] ;
th_topnames_var <- newIORef emptyNameSet ;
th_modfinalizers_var <- newIORef [] ;
th_state_var <- newIORef Map.empty ;
#endif /* GHCI */
let {
maybe_rn_syntax :: forall a. a -> Maybe a ;
...
...
@@ -107,6 +112,7 @@ initTc hsc_env hsc_src keep_rn_syntax mod do_this
tcg_th_topdecls = th_topdecls_var,
tcg_th_topnames = th_topnames_var,
tcg_th_modfinalizers = th_modfinalizers_var,
tcg_th_state = th_state_var,
#endif /* GHCI */
tcg_mod = mod,
...
...
This diff is collapsed.
Click to expand it.
compiler/typecheck/TcRnTypes.lhs
+
7
−
0
View file @
fdce179c
...
...
@@ -118,6 +118,10 @@ import Util
import Data.Set (Set)
#ifdef GHCI
import Data.Map ( Map )
import Data.Dynamic ( Dynamic )
import Data.Typeable ( TypeRep )
import qualified Language.Haskell.TH as TH
#endif
\end{code}
...
...
@@ -309,6 +313,9 @@ data TcGblEnv
tcg_th_modfinalizers :: TcRef [TH.Q ()],
-- ^ Template Haskell module finalizers
tcg_th_state :: TcRef (Map TypeRep Dynamic),
-- ^ Template Haskell state
#endif /* GHCI */
tcg_ev_binds :: Bag EvBind, -- Top-level evidence bindings
...
...
This diff is collapsed.
Click to expand it.
compiler/typecheck/TcSplice.lhs
+
14
−
0
View file @
fdce179c
...
...
@@ -84,6 +84,10 @@ import qualified Language.Haskell.TH.Syntax as TH
#ifdef GHCI
-- Because GHC.Desugar might not be in the base library of the bootstrapping compiler
import GHC.Desugar ( AnnotationWrapper(..) )
import qualified Data.Map as Map
import Data.Dynamic ( fromDynamic, toDyn )
import Data.Typeable ( typeOf )
#endif
import GHC.Exts ( unsafeCoerce# )
...
...
@@ -1089,6 +1093,16 @@ instance TH.Quasi (IOEnv (Env TcGblEnv TcLclEnv)) where
qAddModFinalizer fin = do
th_modfinalizers_var <- fmap tcg_th_modfinalizers getGblEnv
updTcRef th_modfinalizers_var (\fins -> fin:fins)
qGetQ = do
th_state_var <- fmap tcg_th_state getGblEnv
th_state <- readTcRef th_state_var
let x = Map.lookup (typeOf x) th_state >>= fromDynamic
return x
qPutQ x = do
th_state_var <- fmap tcg_th_state getGblEnv
updTcRef th_state_var (\m -> Map.insert (typeOf x) (toDyn x) m)
\end{code}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment